IBM Books

Administration and Programming Guide for OS/400

Direct Call Language Environment Example

In this example, the macro calls a program and passes several parameters. The source for the program follows the macro, and is written in RPG and CL. The program that is called accepts two integer parameters. It copies the first parameter (the input parameter) to the second parameter (the output parameter).

Macro:

%define ilepgm = "/QSYS.LIB/NETDATADEV.LIB/TDCCLI01.PGM"    
 %define out1  = "0"
                                                                                                                                
 %FUNCTION(DTW_DIRECTCALL) dcFunction(IN INT inp1, 
                                      OUT INT outp2)        
 {  %EXEC { $(ilepgm) %} %}
                                   
 %HTML(REPORT) {
 @dcFunction("123", out1)
 The value of out1 is: "$(out1)"
 %}

ILE RPG program:

 DINP1             S             10I00     
 DOUTP2            S             10I00     
 C*                                        
 C     *ENTRY        PLIST                           
 C                   PARM                    INP1    
 C                   PARM                    OUTP2   
 C*                                                  
 C                   Z-ADD     INP1          OUTP2   
 C*                                                                  
 C                   SETON                                 LR

CL program:

 PGM PARM(&INP1; &OUTP2;) 
                                                  
 DCL VAR(&INP1;)  TYPE(*CHAR) LEN(4)                                                   
 DCL VAR(&OUTP2;) TYPE(*CHAR) LEN(4)              
                                                  
 CHGVAR VAR(&OUTP2;) VALUE(&INP1;)                                                                              
 ENDPGM


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]