/* trload.p */
DEFINE VARIABLE event AS CHARACTER NO-UNDO FORMAT "x(6)". DEFINE VARIABLE field-name AS CHARACTER NO-UNDO FORMAT "x(32)". DEFINE VARIABLE iCRC AS INTEGER NO-UNDO. DEFINE VARIABLE ix AS INTEGER NO-UNDO. DEFINE VARIABLE proc-name AS CHARACTER NO-UNDO FORMAT "x(32)". DEFINE VARIABLE table-name AS CHARACTER NO-UNDO FORMAT "x(32)". INPUT FROM "_file-tr.dat". /* Table trigger data */ _fl-loop: REPEAT: SET table-name event proc-name. ASSIGN RCODE-INFO:FILE-NAME = proc-name iCRC = RCODE-INFO:CRC-VALUE. FIND _file WHERE _file._file-name = table-name. FIND _file-trig WHERE _file-trig._file-recid = RECID(_file) AND _file-trig._event = event NO-ERROR. IF AVAILABLE _file-trig THEN DO: IF _file-trig._proc-name = proc-name AND _file-trig._trig-crc = iCRC THEN NEXT _fl-loop. ELSE DO: /* ABL doesn't let you modify a trigger record, so delete and recreate. */ DELETE _file-trig. CREATE _file-trig. ASSIGN _file-trig._file-recid = RECID(_file) _file-trig._event = event _file-trig._override = TRUE _file-trig._proc-name = proc-name _file-trig._trig-crc = iCRC ix = ix + 1. END. END. END. INPUT CLOSE. MESSAGE ix "_file-trig records updated.". INPUT CLOSE. MESSAGE ix "_file-trig records updated.". INPUT FROM "_field-t.dat". /* Field trigger data */ _fld-loop: REPEAT: SET table-name field-name event proc-name. RCODE-INFO:FILE-NAME = proc-name. iCRC = RCODE-INFO:CRC-VALUE. FIND _file WHERE _file._file-name = table-name. FIND _field WHERE _field._file-recid = RECID(_file) AND _field._field-name = field-name. FIND _field-trig WHERE _field-trig._file-recid = RECID(_file) AND _field-trig._field-recid = RECID(_field) AND _event = event NO-ERROR. IF AVAILABLE _field-trig AND _field-trig._proc-name = proc-name AND _field-trig._trig-crc = iCRC THEN NEXT _fld-loop. ELSE DO: DELETE _field-trig. CREATE _field-trig. ASSIGN _field-trig._file-recid = RECID(_file) _field-trig._field-recid = RECID(_field) _field-trig._event = event _field-trig._override = TRUE _field-trig._proc-name = proc-name _field-trig._trig-crc = iCRC ix = ix + 1. END. END. INPUT CLOSE. MESSAGE ix "_field-trig records updated.". |