Passing Parameters

In this section:

The following terminology is used in this section:


Top of page

x
Using CALLPGM with Embedded Spaces in Parameters

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
ENGINE 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 CALLPGM

Parameters are passed to CALLPGM as comma separated values. If a value is a string and contains an embedded space or comma then the string must be quoted. The SET STRIPQUOTE default is to strip the quotes for the underlying program so only the value is seen.

The underlying program then uses the CPM specification to read the individual parameters. The parameter order must match the parameter order that the underlying program expects, but there is also no reason why the underlying program cannot be written to understand parameter pair values (for example, firstname=John,lastname=Doe) so that the program is position independent. It is also permissible to form all values as a single quoted string, if the underlying program has code to parse the string into usable values.

For example assume myproc is a Dialogue Manager FOCEXEC procedure and the procedure contains and sets values for the variables &1, &2, and &3 and issues a CALLPGM command as follows:

CALLPGM &1,&2,&3
END

When the procedure executes, the server substitutes the values for the variables &1, &2, and &3, and the result call might look like:

CALLPGM myprog,Sales,20
END

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



Example: Passing Long Parameters

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 break up long parameters into more readable strings and internally pass the long parameter 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