Passing Parameters

In this section:

The following terminology is used in this section:


Top of page

x
Using CALLPGM

How to:

When passing CPG parameters that contain embedded spaces or commas, the parameters must be enclosed in quotation marks. The following profile setting controls the stripping of quotation marks from parameters.



x
Syntax: How to Control the Stripping of Quotes From Parameters
SQL SPG SET STRIPQUOTE {ON|OFF}

where:

ON

Causes the quotation marks to be stripped from the parameters. ON is the default value.

OFF

Prevents the stripping of the quotation marks from the parameters.


Top of page

x
Using EDARPC

EDARPC passes positional or keyword API parameters. Positional parameters work with Dialogue Manager procedures or compiled programs. Keyword API parameters only work with Dialogue Manager procedures.

Note: Positional and keyword API parameters are mixed if performed as described.

This section contains examples of positional and keyword API parameters passed by EDARPC.



Example: Passing Positional API Parameters

EDARPC passes one or more positional API parameters to a Dialogue Manager procedure or compiled program, which uses each in a variety of ways. Positional API parameters receive the values from the order in the EDARPC calling sequence.

Positional API parameters are passed as a string enclosed in double quotation marks, with the positional values separated by commas as shown in the following example

EDARPC(scb,"myproc",6,"myprog,Sales,20",15)

where:

scb

Is the session control block.

myproc

Is the name of a Dialogue Manager procedure or compiled program.

6

Is the length of the string myproc.

myprog,Sales,20

Is a string (an API parameter) containing the three positional parameters.

15

Is the length of the above string.

For the purpose of this example, assume myproc is a Dialogue Manager procedure and the procedure uses the API parameter as DM variables &1, &2, and &3 to, in turn, issue a CALLPGM command as follows:

CALLPGM &1,&2,&3 
END

When the Dialogue Manager procedure executes, the server substitutes the values for the variables &1, &2, and &3, and the result is:

CALLPGM myprog,Sales,20
END

The values Sales and 20 are passed to the underlying compiled program myprog.



Example: Passing Keyword API Parameters

EDARPC also passes one or more keyword API parameters to a Dialogue Manager procedure. The value of a keyword API parameter is determined by the name given before the equal sign (=) on the EDARPC function call.

Keyword DM parameters are specified as name=value pairs in the API parameter and are passed as a string enclosed in double quotation marks, with name=value pairs separated by commas. Keyword DM parameters are only used in Dialogue Manager procedures.

EDARPC(scb,"myrp",4,"prog=myprog,parm1=Sales,parm2=20",32)

where:

scb

Is the session control block.

myrp

Is the name of a Dialogue Manager procedure.

4

Is the length of the string myrp.

prog=myprog,parm1=Sales,parm2=20

Is a string (an API parameter) containing three keyword DM parameter value pairs.

32

Is the length of the above string.

For the purpose of this example, assume that myrp is a Dialogue Manager procedure and the procedure puts the keyword DM parameters in the DM variables &prog, &parm1, and &parm2, and then uses each in a CALLPGM command:

CALLPGM &prog,&parm1,&parm2 
END

When values are substituted at run time, the result is the same command as in the previous example:

CALLPGM myprog,Sales,20
END

The advantage of keyword parameters is that the order of the parameters is positionally independent. An API program does not need this level of knowledge and Dialogue Manager is used to establish default values. Default values do not need to be established as part of the API program.

For more information on API positional and keyword parameters, see the API Reference manual.



Example: Combining Positional and Keyword API Parameters

EDARPC passes one or more positional API parameters mixed with one or more keyword parameters to a Dialogue Manager procedure. The server substitutes the values for the amper variables based on the relative position of the positional keywords to each other.

EDARPC(scb,"myproc",6,"prog=myprog,000001,000002,kparm1=keyparm,000003",47)

where:

scb

Is the session control block.

myproc

Is the name of a Dialogue Manager procedure.

6

Is the length of the string myproc.

prog=myprog...,000003

Is a string (an API parameter) containing three positional and two keyword Dialogue Manager parameters.

47

Is the length of the above string.

For the purpose of this example, assume that myproc is a Dialogue Manager procedure and the procedure uses the API positional parameters &1, &2, and &3, and the keyword parameters &prog and &kparm1 to, in turn, issue a CALLPGM command as follows:

CALLPGM &prog,&1,&2,&kparm1,&3;
END

When the Dialogue Manager procedure executes, the server substitutes the values for the variables &1, &2, &3, &prog, and &kparm1, and the result is:

CALLPGM myprog,000001,000002,keyparm,000003;

The values 000001, 000002, keyparm, and 000003 are passed to the program myprog.

Passing mixed positional and keyword parameters requires care in assembling the API parameter string so that the positional values match up appropriately with the underlying RPC.



Example: Passing Long Parameters

EDARPC passes a parameter up to 32,000 bytes in length. If a CALLPGM program is being executed directly, the parameter is passed directly to the CALLPGM program.

If a CALLPGM program is being executed from a procedure residing on the server, the -LINES function is used to pass long parameters to the CALLPGM program. The following is an example of a server procedure passing the maximum parameter of 32,000 bytes:

"EX -LINES 401 CPG32000 LINE000000000000000000000000000000000000000000001      "
"LINEOFINFORMATION1111111111111111111111111111111111111111111111111111111111111"
"LINEOFINFORMATION2222222222222222222222222222222222222222222222222222222222222"
"LINEOFINFORMATION4004004004004004004004004004004004004004004004004004004004004"
.
.
.
"LASTLINETOTAL32000BYTESTHEENDXX"

Note:


iWay Software