I have a program that takes a temp-table, reads it into a json object then uses that Json to call a rest service i need to tweak it so that it only sends on record at a time until all the records are sent.
is there anyway to do this dynamically, or do i need to break the data and build the json myself? (i would love an example)
thanks
is there anyway to do this dynamically, or do i need to break the data and build the json myself? (i would love an example)
thanks
Code:
DEFINE TEMP-TABLE Cust
FIELD custid AS INTEGER
FIELD test1 AS CHAR
FIELD test2 AS CHAR
FIELD test3 AS INTEGER.
PROCEDURE "doJson.ip":
/* Create new JsonObject */
oJson = NEW JsonObject().
/* Fill with properties representing each field in each record of temp-table */
counter = 0.
FOR EACH Cust BREAK BY cust.custid.
IF AVAILABLE cust THEN
DO:
counter = counter + 1.
lReturnValue = oJson:Read( TEMP-TABLE Cust:HANDLE ).
oJson:Write(lcTest).
COPY-LOB FROM lcTest TO FILE "/Cust" + STRING(counter) + ".json".
oRequest = RequestBuilder:pOST(httpUrl, oJson)
:AcceptJson()
:Request.
oResponse = ClientBuilder:Build():Client:Execute(oRequest).
oEntity = oResponse:Entity.
END.
END.