Update a record in live & history file during EOD/COB

Posted by

Just an example of elements to include in a routine that update a record during the COB (end of day process).

If this is done properly, you must update the last record version and put the previous one in history.

In the below example, we’re updating a record from DX.TRADE file:

One: open files

    FN.DX.TRADE = 'F.DX.TRADE'
    FV.DX.TRADE = ''
    CALL OPF(FN.DX.TRADE, FV.DX.TRADE)
    FN.DX.TRADE$HIS = 'F.DX.TRADE$HIS'
    FV.DX.TRADE$HIS = ''
    CALL OPF(FN.DX.TRADE$HIS, FV.DX.TRADE$HIS)
 
    * initialize variables 
    V$FUNCTION = 'YXCYXC'  ;* len(function) > 1
    CALL DX.TRADE          ;* Initialise DX.TRADE context variables

Two: declare your current record as a MAT, then you can manipulate the R.NEW as you wish

    DIM R.NEW.SAVE(DX.TRA.AUDIT.DATE.TIME)    
    MAT R.NEW='' 
    MAT R.NEW.SAVE='' 
    MATREAD R.NEW FROM FV.DX.TRADE, ID.NEW THEN
        MAT R.NEW.SAVE = MAT R.NEW
    END

Three: Update the new record and put previous one in history

    IF NOT(R.NEW(DX.TRA.CURR.NO)) THEN R.NEW(DX.TRA.CURR.NO) = 1
    ID$HIS = ID.NEW:';':R.NEW.SAVE(DX.TRA.CURR.NO)
    MATWRITE R.NEW.SAVE ON FV.DX.TRADE$HIS,ID$HIS
    R.NEW(DX.TRA.CURR.NO) += 1
    R.NEW(DX.TRA.INPUTTER) = TNO:'_':OPERATOR
    TIME.STAMP = TIMEDATE()
    X = OCONV(DATE(),'D-')
    X = X[9,2]:X[1,2]:X[4,2]:TIME.STAMP[1,2]:TIME.STAMP[4,2]
    R.NEW(DX.TRA.DATE.TIME) = X
    R.NEW(DX.TRA.AUTHORISER) = TNO:'_EOD.TRS'
    MATWRITE R.NEW ON FV.DX.TRADE,ID.NEW
    IF NOT(RUNNING.UNDER.BATCH) THEN CALL JOURNAL.UPDATE(ID.NEW)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.