/* write-json-pds3.p */
{pi-json-parameterVarDefs.i} /* parameter variable definitions */ {pi-write-json-pds1.i} /* dsOrderLog definition - no nesting */ DEFINE VARIABLE hdsOrderLog AS HANDLE NO-UNDO. DEFINE VARIABLE lRetOK AS LOGICAL NO-UNDO. hdsOrderLog = DATASET dsOrderLog:HANDLE. DATA-SOURCE dsCustomer:FILL-WHERE-STRING = "WHERE Customer.CustNum = 2 ". DATASET dsOrderLog:FILL(). /* set tracking-changes so that before-table records are created */ TEMP-TABLE ttCustomer:TRACKING-CHANGES = TRUE. TEMP-TABLE ttCustomer:TRACKING-CHANGES = TRUE. /* modify ttCustomer 2 */ FIND ttCustomer WHERE ttCustomer.CustNum = 2. ASSIGN ttCustomer.EmailAddress = "www.progress.com". /* set error string on ttCustomer 2 */ BUFFER ttCustomer:ERROR = TRUE. BUFFER ttCustomer:ERROR-STRING = "ttCustomer 2 error". /* delete an order */ FIND ttOrder WHERE ttOrder.OrderNum = 94. DELETE ttOrder. TEMP-TABLE ttCustomer:TRACKING-CHANGES = FALSE. TEMP-TABLE ttCustomer:TRACKING-CHANGES = FALSE. /* write-json with before-image data to file */ ASSIGN cTargetType = "file" cFile = "dsOrderLogWithBefore.json" lFormatted = TRUE cEncoding = ? lOmitInitialValues = FALSE lOmitOuterObject = FALSE lWriteBeforeImage = TRUE. lRetOK = hdsOrderLog:WRITE-JSON(cTargetType, cFile, lFormatted, cEncoding, lOmitInitialValues, lOmitOuterObject, lWriteBeforeImage). |
{"dsOrderLog": {
"prods:hasChanges": true, "ttCustomer": [ { "prods:id": "ttCustomer14592", "prods:rowState": "modified", "prods:hasErrors": true, "CustNum": 2, ... "EmailAddress": "www.progress.com" } ], "ttOrder": [ { "Ordernum": 125, ... }, ... { "Ordernum": 6070, ... ], "ttInvoice": [ { "Invoicenum": 94, ... }, { "Invoicenum": 124, ... } ], "prods:before": { "ttCustomer": [ { "prods:id": "ttCustomer14592", "prods:rowState": "modified", "CustNum": 2, ... "EmailAddress": "" } ], "ttOrder": [ { "prods:id": "ttOrder12545", "prods:rowState": "deleted", "CustNum": 2, "OrderNum": 94, ... } ] }, "prods:errors": { "ttCustomer": [ { "prods:id": "ttCustomer14592", "prods:error": "ttCustomer 2 error" } ] } }} |