Search code examples
ibm-midrange

*BYVAL and *BYREF in CLLE


I am trying to call a RPGLE procedure from a CLLE. Since the RPGLE procedure is existing, I cannot change it to extproc(*CL) type. I am currently in V7R1. I have used the below code. If i pass by *BYVAL the parameters are not getting passed. If i pass by *BYREF it is working. I have defined the parameters as CONST in RPGLE service. Please let me know if i have to do any additional changes to pass by value.

PGM                                                      

DCLPRCOPT  USRPRF(*OWNER) DFTACTGRP(*NO) ACTGRP(*NEW) +  
             BNDDIR(SAMSRV)                              

DCL        VAR(&CLNBR) TYPE(*CHAR) LEN(9)                
DCL        VAR(&USER) TYPE(*CHAR) LEN(10)                
DCL        VAR(&IS_VLD) TYPE(*LGL)                       

CHGVAR     VAR(&CLNBR) VALUE('01112201T')                
CHGVAR     VAR(&USER)  VALUE('UUUUU ')                   

CALLPRC    PRC('IsValidClient') PARM((&CLNBR *BYREF) +
             (&USER *BYREF)) RTNVAL(&IS_VLD)             
ENDPGM    

Solution

  • If the parms are coded as CONST in the RPGLE procedure, then you simply can not pass by value.

    The parameter on the RPGLE side would need VALUE keyword to be a pass by value parm. CONST means passed by read-only reference. When neither CONST nor VALUE is specified in RPGLE, then the parm is passed by reference.

    You really should add the EXTPROC(*CL). RPGLE and CL don't return 1-byte values quite the same way; Nor pass by value 1-byte variables the same way. Prior to v6r1, you could code a temporary 2-byte variable to hold the returned value and then just copy the first byte to &IS_VLD.