R
Raphael Frei
Guest
I'm using Progress 12.8 to create a custom class that will work as an object to communicate our system into some APIs for another web system.
The program itself is already working, but now I'm doing some work to optimize the code.
My questions is: Is possible to iterate thru all temp-tables inside the class without having to call each one individually?
I know that from a regular table, we can consume _FILE table
For example, this is what I'm doing:
The problem with this, is that for each new table I would need to modify the UploadData to include new ones.
Is there more of an automatic way to do this? Thanks!
Continue reading...
The program itself is already working, but now I'm doing some work to optimize the code.
My questions is: Is possible to iterate thru all temp-tables inside the class without having to call each one individually?
I know that from a regular table, we can consume _FILE table
For example, this is what I'm doing:
Code:
// ----- TEMP TABLES
DEFINE TEMP-TABLE TT-PartNumber NO-UNDO SERIALIZE-NAME "2"
FIELD TT-Code AS CHARACTER SERIALIZE-NAME "code"
FIELD TT-Name AS CHARACTER SERIALIZE-NAME "name".
DEFINE TEMP-TABLE TT-DownTime NO-UNDO SERIALIZE-NAME "3"
FIELD TT-Cell AS CHARACTER SERIALIZE-NAME "cell"
FIELD TT-InitialDate AS CHARACTER SERIALIZE-NAME "initialDate"
FIELD TT-EndDate AS CHARACTER SERIALIZE-NAME "endDate".
// Function that gets each table
METHOD PUBLIC VOID UploadData():
FOR FIRST TT-PartNumber NO-LOCK:
LoadTableJSON(INPUT TEMP-TABLE TT-PartNumber:HANDLE,
INPUT TRUE).
END.
// -----
FOR FIRST TT-DownTime NO-LOCK:
LoadTableJSON(INPUT TEMP-TABLE TT-DownTime:HANDLE,
INPUT TRUE).
END.
END METHOD.
// -----
METHOD PRIVATE CHARACTER LoadTableJSON(INPUT hTable AS HANDLE,
INPUT lUpload AS LOGICAL):
DEFINE VARIABLE cTableName AS CHARACTER NO-UNDO.
DEFINE VARIABLE iTableID AS INTEGER NO-UNDO.
DEFINE VARIABLE lcJson AS LONGCHAR NO-UNDO.
DEFINE VARIABLE cResult AS CHARACTER NO-UNDO.
ASSIGN cTableName = hTable:NAME
iTableID = INT(hTable:SERIALIZE-NAME).
WriteLog(SUBSTITUTE("Processing &1", cTableName)).
hTable:WRITE-JSON("LONGCHAR", lcJson, TRUE).
ASSIGN cResult = TransformJSON(STRING(lcJson)).
WriteLog(SUBSTITUTE("JSON Loaded - &1", cResult)).
IF lUpload THEN
PostData(INPUT cResult, INPUT iTableID).
WriteLog("Processing Finished").
END METHOD.
The problem with this, is that for each new table I would need to modify the UploadData to include new ones.
Is there more of an automatic way to do this? Thanks!
Continue reading...