There are two ways to pass information to a REXX program that is invoked by the REXX (DTW_REXX) language environment, directly and indirectly.
%FUNCTION(DTW_REXX) rexx1() { %EXEC{ /QSYS.LIB/NETDATA.LIB/QREXXSRC.FILE/CALL1.MBR $(INPARM1) %} %}
The Net.Data variable INPARM1 is dereferenced and passed to the external REXX program. The REXX program can reference the variable by using REXX PARSE ARG instruction. The parameters that are passed to the program using this method are considered input type parameters (the parameters passed to the program can be used and manipulated by the program, but changes to the parameters are not reflected back to Net.Data).
Pass parameters indirectly, by way of the REXX program variable pool. When a REXX program is started, a space which contains information about all variables is created and maintained by the REXX interpreter. This space is called the variable pool.
When a REXX language environment (DTW_REXX) function is called, any function parameters that are input (IN) or input/output (INOUT) are stored in the variable pool by the REXX language environment prior to executing the REXX program. When the REXX program is invoked, it can access these variables directly. Upon the successful completion of the REXX program, the DTW_REXX language environment determines whether there are any output (OUT) or INOUT function parameters. If so, the language environment retrieves the value corresponding to the function parameter from the variable pool and updates the function parameter value with the new value. When Net.Data receives control, it updates all OUT or INOUT parameters with the new values obtained from the REXX language environment. For example:
%DEFINE a = "3" %DEFINE b = "0" %FUNCTION(DTW_REXX) double_func(IN inp1, OUT outp1){ outp1 = 2*inp1 %} %HTML(REPORT) { Value of b is $(b), @double_func(a, b) Value of b is $(b) %}
In the above example, the call @double_func passes two parameters, a and b. The REXX function double_func doubles the first parameter and stores the result in the second parameter. When Net.Data invokes the macro, b has a value of 6.
You can pass Net.Data tables to a REXX program. A REXX program accesses the values of a Net.Data macro table parameter as REXX stem variables. To a REXX program, the column headings and field values are contained in variables identified with the table name and column number. For example, in the table myTable, the column headings are myTable_N.j, and the field values are myTable_N.i.j, where i is the row number and j is the column number. The number of rows in the table is myTable_ROWS and the number of columns in the table is myTable_COLS.