EXPERT RESPONSE
The CL module has a PGM statement that lists the variable names passed into and out of the module. All values passed in will also be passed out.
The RPGLE source must contain a procedure prototype naming the CL *MODULE object in the EXTPROC keyword. Note: The procedure name is in fact the *MODULE object name. No return value must be specified. The prototype parameters following the procedure name statement must be of the same type and size as the parameters in the CLLE module.
When defining parameters for RPGLE<-->CLLE procedure calls, try to avoid 1-byte lengths, for reasons which used to be valid but probably are not any more. I make a habit of defining return codes as seven characters, because I can then pass a meaningful value or a message ID. Also, avoid 1 and 2 byte integer and unsigned fields, 1-byte graphic and UCS-2, and 4-byte floating-point fields. You may have no problems with them, but if you do have problems it may be connected with field types.
Use NO keywords on the prototype parameter statements in the RPG. The parameters will be passed by address.
Example:
In CLLE (source member SAMPLE_2) :
PGM PARM(&RTCD &COMMAND)
DCL VAR(&RTCD) TYPE(*CHAR) LEN(7)
DCL VAR(&COMMAND) TYPE(*CHAR) LEN(50)
Use CRTCLMOD to create the *MODULE object. No special options need to be used.
In RPGLE :
D Sample_2 PR ExtProc('SAMPLE_2')
D pRtcd 7
D pCmd 50
In your C-specs use CALLP to call the CLLE module:
C CallP Sample_2(wkRTCD : Command)
If the CLLE module changes the values in the fields &RTCD or &COMMAND, those changed values will be reflected in the fields WKRTCD and Command in the RPGLE program.
NOTE: To compile the RPGLE object, you must either create it as a *MODULE object and then create a bound program from the two *MODULE objects, or else you can create the RPGLE as a *PGM object directly using CRTBNDRPG -- but only if you add the CLLE *MODULE object name to a binding directory and specify the following options on the CRTBNDRPG command:
DFTACTGRP(*NO) ACTGRP(*CALLER) BNDDIR(your_binding_directory_name)
|