Below is the code:
FILE POSFILE
POSFILE-REC 01 39 A
IN-POS-ID 01 11 N
IN-POS-AMT 30 05 N
FILE NEGFILE
NEGFILE-REC 01 39 A
IN-NEG-ID 01 11 N
IN-NEG-AMT 30 05 N
FILE OUTFILE1
OUT1-REC 1 80 A
IN-OUT-ID 01 11 N
IN-OUT-AMT 30 05 N
WS-POS-ACCT-ID W 11 N
WS-POS-ACC-AMT W 05 N
WS-NEG-ACCT-ID W 11 N
WS-NEG-ACC-AMT W 05 N
**************************************************************
JOB INPUT POSFILE
WS-POS-ACCT-ID = IN-POS-ID
MOVE IN-POS-ID TO WS-POS-ACCT-ID
DISPLAY WS-POS-ACCT-ID
WS-POS-ACC-AMT = IN-POS-AMT
GET NEGFILE
DO WHILE NOT EOF NEGFILE
WS-NEG-ACCT-ID = IN-NEG-ID
WS-NEG-ACC-AMT = IN-NEG-AMT
DISPLAY WS-POS-ACC-AMT ' WS-POS-ACC-AMT'
DISPLAY 'IN WHILE LOOP'
DISPLAY WS-NEG-ACC-AMT 'WS-NEG-ACC-AMT'
IF WS-NEG-ACCT-ID EQ WS-POS-ACCT-ID
DISPLAY 'IN IF LOOP'
IN-OUT-ID = WS-POS-ACCT-ID
WS-POS-ACC-AMT = WS-POS-ACC-AMT - WS-NEG-ACC-AMT
ELSE
DISPLAY 'IN ELSE LOOP'
IN-OUT-ID = WS-POS-ACCT-ID
IN-OUT-AMT = WS-POS-ACC-AMT
DISPLAY IN-OUT-AMT 'IN-OUT-AMT'
END-IF
GET NEGFILE
END-DO
PUT OUTFILE1
GOTO JOB
STOP
My program is able to check the first record of the first file ... but when it tried to process the second one it ended wth RC=16.