Our RPG program calls the COBOL program with a large linkage made up of an external file record format occurring 999 times. The COBOL program loads 121 of the occurrences with data. The RPG program, however, appears to start processing with the following occurrence 122 even though the COUNT index in the RPG program is set to 1. Since there is no data in the 122nd array element, the RPG program gets a MCH1202 data decimal error.
Software/Hardware used:
ASKED:
November 14, 2007 4:10 PM
UPDATED:
November 15, 2007 9:47 PM
1. No prototype exists.
2. RPG data structure Definition:
D CLMREC E DS OCCURS(999) EXTNAME(PLCLAIM)
3. RPG call statement:
CALL ‘PLGETCLAIM’
PARM CLMREC
PARM SVVECO
PARM SVIREF
PARM TRANSCD 10
PARM XSTART 3 0
PARM TOTLINE 3 0
PARM CPFORM
PARM CPNUMC
PARM CPNUML
PARM CPPREF
PARM SVICHK
PARM PYMTHD
4. Highlights of RPG looping code:
C COUNT OCCUR CLMREC
C COUNT IFGT TOTLINE
C LEAVE
C ENDIF
It is erroring out on this Z-ADD statement:
C Z-ADD IREF IREFZ
5 & 6. COBOL Linkage & Using:
LINKAGE SECTION.
01 PLCLAIM-RETURN.
03 PLCLAIM-RETURN-TABLE OCCURS 999 TIMES INDEXED BY PLC.
COPY DDS-ALL-FORMATS OF PLCLAIM
REPLACING CLAIM-INFOL-REC BY CLAIN-NFO-REC-LNK
PLR000 BY PLR000-LNK.
01 LA-COMPANY PIC X(05).
01 LA-REF PIC 9(09) COMP-3.
01 LA-TRANS PIC X(10).
01 LA-START PIC 9(03) COMP-3.
01 LA-END PIC 9(03) COMP-3.
01 LA-FORM PIC 9(03) COMP-3.
01 LA-NUMC PIC 9(06) COMP-3.
01 LA-NUML PIC 9(05) COMP-3.
01 LA-CHKNBR PIC X(18).
01 LA-ICHK PIC 9(09) COMP-3.
01 LA-METHOD PIC X(02).
PROCEDURE DIVISION USING PLCLAIM-RETURN
LA-COMPANY
LA-REF
LA-TRANS
LA-START
LA-END
LA-FORM
LA-NUMC
LA-NUML
LA-CHKNBR
LA-ICHK
LA-METHOD.
7. COBOL access:
MOVE SVIREF TO IREF OF PLR000
CLMIREF OF PLP000…
MOVE CORR PLR000 TO PLR000-LNK(PLC)
Bruce,
If the above is insufficient, I’d be happy to send pdf files of the two program compile listings. Just let me know your email address. Mine is tdanforth@magmutual.com.
Thanks!
There must be something else going on in your program… The following does work as expected so you may want to compare it to what you have:
The file PLCLAIM:
which I loaded with three records: ‘Able’, ‘Baker’, ‘Cook’
The RPG program CALLCBL:
The COBOL program CALLEDCBL:
IDENTIFICATION DIVISION. PROGRAM-ID. CALLEDCBL. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT PLClaim ASSIGN TO DATABASE-PLClaim. DATA DIVISION. FILE SECTION. FD PLClaim. 01 PLCLaim-Records. COPY DDS-ALL-FORMATS OF PLClaim. WORKING-STORAGE SECTION. 01 PLClaim-File PIC X(1). 88 EOF VALUE "Y". LINKAGE SECTION. 01 PLClaim-Return. 03 PLCLaim-Return-Table OCCURS 999 TIMES INDEXED BY Plc. COPY DDS-ALL-FORMATS OF PLClaim REPLACING PLRCD BY PLRcd-Lnk. 01 LA-End PIC 9(03) COMP-3. PROCEDURE DIVISION USING PLClaim-Return LA-End. MAIN-LINE. OPEN INPUT PLClaim. MOVE 0 TO LA-End. READ PLClaim AT END SET EOF TO TRUE. PERFORM WITH TEST BEFORE UNTIL EOF MOVE CORRESPONDING PLRcd TO PLRcd-Lnk(Plc) ADD 1 TO LA-End SET Plc UP BY 1 READ PLClaim AT END SET EOF TO TRUE END-READ END-PERFORM. CLOSE PLClaim. STOP RUN.When I then CALLED CALLCBL I got:
DSPLY Able
DSPLY Baker
DSPLY Cook
DSPLY Press Enter