Okay, I'm not sure what I'm missing here. After 30 years an iSeries programmer, I'm finally trying to fully utilize the benefits of ILE (thanks Scott Klement!) but I can't explain what's happening. I've stripped my code down to the essential:
MAIN (RPGLE):
D CLProc PR ExtProc('SUBPROC')
D SomeValue 15A Value
D CharParm S 15A
C Eval CharParm = 'Message'
C CallP CLProc( CharParm )
C Eval *InLR = *On
SUBPROC (CLLE):
0001.00 PGM PARM(&CHAR15)
0002.00 DCL VAR(&CHAR15) TYPE(*CHAR) LEN(15)
0003.00 CHGVAR VAR(&CHAR15) VALUE('Change Msg')
0004.00 RETURN
I've created both as *MODULEs, then created the *PGM MAIN. I want to pass a parameter value from the RPG to the CL, allow the CL to change the value, but not affect the original variable. The above code blows up on the CL (line 3) with MCH3601 error because &CHAR15 is *NULL. If I change the RPG prototype from "Value" to "Const," it works without error, but CharParm has changed value (to "Change Msg") when it returns to the RPG. I can?t figure out what?s wrong. The only way I can see to make it work is by creating a trash variable in the MAIN program, evaluate it to CharParm, and pass the new variable to the CL procedure. Any assistance will be greatly appreciated!
MAIN (RPGLE):
D CLProc PR ExtProc('SUBPROC')
D SomeValue 15A Value
D CharParm S 15A
C Eval CharParm = 'Message'
C CallP CLProc( CharParm )
C Eval *InLR = *On
SUBPROC (CLLE):
0001.00 PGM PARM(&CHAR15)
0002.00 DCL VAR(&CHAR15) TYPE(*CHAR) LEN(15)
0003.00 CHGVAR VAR(&CHAR15) VALUE('Change Msg')
0004.00 RETURN
I've created both as *MODULEs, then created the *PGM MAIN. I want to pass a parameter value from the RPG to the CL, allow the CL to change the value, but not affect the original variable. The above code blows up on the CL (line 3) with MCH3601 error because &CHAR15 is *NULL. If I change the RPG prototype from "Value" to "Const," it works without error, but CharParm has changed value (to "Change Msg") when it returns to the RPG. I can?t figure out what?s wrong. The only way I can see to make it work is by creating a trash variable in the MAIN program, evaluate it to CharParm, and pass the new variable to the CL procedure. Any assistance will be greatly appreciated!
Comment