ILE RPG call to ILE COBOL passing large array

pts.
Tags:
Arrays
COBOL
Parameters
RPG
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.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Rather interesting behavior!

Instead of guessing how you have the programs coded, can you provide:

1. The RPG prototype for the COBOL program (if you are using a prototype)
2. The RPG definition for the data structure/array being passed
3. The actual RPG CALL statement
4. How the RPG program is accessing the first element of the array after the COBOL program returns
5. The COBOL PROCEDURE DIVISION USING statement
6. The COBOL LINKAGE SECTION definition for the array being passed
7. How you are accessing the elements of the array within the COBOL program.

Bruce Vining
Bruce Vining Services

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • toddio
    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!
    0 pointsBadges:
    report
  • bvining
    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:
    R PLRCD                    
      DATA          10
    
    which I loaded with three records: 'Able', 'Baker', 'Cook' The RPG program CALLCBL:
    dClmRec         e ds                  occurs(999) extname(PLCLAIM)        
    dCount            s             10i 0                                     
    dWait             s              1                                        
    c                   call      'CALLEDCBL'                                 
    c                   parm                    ClmRec                        
    c                   parm                    TotLine           3 0         
    c     1             do        TotLine       Count                         
    c     Count         occur     ClmRec                                      
    c     Data          dsply                                                 
    c                   enddo                                                 
    c     'Press Enter' dsply                   Wait                          
    c                   move      *on           *inlr                         
    c                   return 
    
    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
    6,620 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following