The DO SET statement allows for the extraction of information from reports, assigning that information to internal variables, and the manipulation of those variables (such as concatenation and sub-string extraction). Additionally, strings can extracted from XML documents and environment variables such as JOBNAME and EXTWTR.
DO SET Placement
The following are rules for placement of the DO SET parameter:
Using Variables with the WHEN Statement
You can use variables with the WHEN LINE and WHEN VAR variants of the WHEN statement. For an example of using variables with WHEN VAR and WHEN LINE, see Example 2 in Examples. For more information on the WHEN statement, see WHEN: Decollating Parameter.
Using Variables with DO Statements
Certain DO statements can contain variables, including the system variables JOBNAME, EXTWTR, USERID, FILE, DSNLLQ, or a substring of the variable, using the following format:
DO parameter [=] {
reg_syntax | %%
var1[(
startpos,length)]}
where
The following are the DO parameters that support variables, and their formats:
For an example of using variables with DO statements, see Example 3 in Examples.
DO SET and Decollation Subtasks
In decollation subtasks, for each page that is processed, the following steps are performed:
The values assigned by DO SET for the current page may be used in DO statements that appear later in the same page. These values can also be used in the WHEN statements that begin on the next page.
Note: If a variable is used before it is assigned, it has a NULL value.
Extracting a Value from a Decollated Report
When using this option for setting a value for DO SET, do the following:
Note: To switch back to the regular varvalue field, replace the * in the varvalue field with any character other than a blank or * (asterisk), and press Enter. The LINE and COL fields are hidden, and the length of the varvalue field is restored to its normal default.
LINE[n] COL [k–m]
where
For an example using of extracting a value using this method, see Example 1 in Examples.
Extracting a Value from the XML List of Node Tag Names
When using this option for setting a value for DO SET, use the following format for the XML path (Xpath):
<{/[/] {* | node}/.../{* | source_node}}>
where
tag[index]
where
{@attribute_name | text()[[index]]}
where
Searches for source tag names are performed using the following rules:
XML Considerations
Because decollation sub-tasks process documents page-by-page, XML documents that are referenced can contain one or more pages. The number of pages is determined by setting an appropriate value for the LINECT CDAM control parameter. For more information on the LINCECT parameter, see CDAM Control Parameters.
You can split an XML report (EDCDIC only) into pages by setting the PRINT/CDAM XMLSEP parameter to tagname. For more information on the XMLSEP parameter, see CDAM Control Parameters.
Because XML documents do not have fixed line and column positions, you cannot reference data from an XML document with any statement that contains the LINE and COL parameters. Strings from the XML document must first be assigned to variables using DO SET statements, after which they may be used in other WHEN and DO statements.
For an example of extracting strings from an XML document, see Example 4 in Examples.
Parent Topic |