{auditing/include/_aud-utils.i}
DEFINE VARIABLE cStatus AS CHARACTER NO-UNDO. DEFINE VARIABLE errorMsg AS CHARACTER NO-UNDO. DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO. DEFINE VARIABLE hDSChanges AS HANDLE NO-UNDO. DEFINE VARIABLE hQuery AS HANDLE NO-UNDO. DEFINE VARIABLE ix AS INTEGER NO-UNDO. /* Turn tracking-changes off for now */ RUN set-tracking-changes (FALSE). /* Create a ProDataSet with the changes before sending it to the other procedure */ CREATE DATASET hDSChanges. hDSChanges:CREATE-LIKE(hAuditDset). hDSChanges:GET-CHANGES(hAuditDset). /* Get the changes */ ASSIGN errorMsg = "". /* Call the generic procedure passing our local ProDataSet */ RUN update-auditing-policies IN hAuditUtils (INPUT cDbInfo, INPUT-OUTPUT DATASET-HANDLE hDSChanges BY-REFERENCE). ASSIGN errorMsg = RETURN-VALUE. /* Turn tracking changes back on */ RUN set-tracking-changes (TRUE). /* Check the ERROR status that might have been returned. */ IF errorMsg = "":U AND hDSChanges:ERROR THEN DO: /* There was an error somewhere in the updates. Find it. */ DO ix = 1 TO hDSChanges:NUM-BUFFERS. CREATE QUERY hQuery. hBuffer = hDSChanges:GET-BUFFER-HANDLE(ix):BEFORE-BUFFER. hQuery:ADD-BUFFER(hBuffer). hQuery:QUERY-PREPARE("FOR EACH " + hBuffer:NAME). hQuery:QUERY-OPEN(). hQuery:GET-FIRST(). DO WHILE NOT hQuery:QUERY-OFF-END: IF hBuffer:ERROR THEN cStatus = cStatus + hBuffer:ERROR-STRING + CHR(10) NO-ERROR. hQuery:GET-NEXT(). END. hQuery:QUERY-CLOSE(). DELETE OBJECT hQuery. END. END. /* delete the ProDataSet with changes */ DELETE OBJECT hDSChanges. IF errorMsg <> "":U THEN RETURN errorMsg. IF cstatus = "" THEN /* If no errors so far, accept all the changes */ hAuditDset:ACCEPT-CHANGES(). ELSE RETURN cStatus. |