Processing paths
The existence (PATH) or absence (NOPATH) of a selected segment for each specified object keyword is determined prior to the execution of any sub-commands. Each object keyword of each sub-command specifies, explicitly or implicitly, whether PATH or NOPATH processing is desired. The following describes the execution steps for both PATH and NOPATH conditions.
When a PATH condition exists, the following three phases of processing occur:
- During the first phase the COUNT, PRINT, and CHANGE sub-commands, if specified, are considered for processing. Processing starts with the object keyword closest to the top of the hierarchical sequence and proceeds down the hierarchy to the lowest object keyword specified. Object keywords that have specified PATH or ALWAYS for the COUNT, PRINT, or CHANGE sub-command are executed.
- During the second phase the DELETE sub-command, if specified, is considered for processing. Processing starts with the object keyword closest to the top of the hierarchical sequence and proceeds down the hierarchy to the first object keyword that has specified PATH or ALWAYS for the DELETE sub-command. The DELETE sub-command is then executed.
During the third and final phase the INSERT sub-command, if specified, is considered for processing. Processing starts with the object keyword closest to the top of the hierarchy and proceeds down the hierarchy to the first object keyword that has specified PATH or ALWAYS for the INSERT sub-command. This segment is inserted. Segments for subsequent levels for which PATH or ALWAYS have been specified are also inserted.
This form for the insert may be applicable when the segment being inserted does not have a unique sequence field. If the segment has a unique sequence field, the preferred method would be to SELECT the segment to be inserted and, if it is not present, insert it using the NOPATH option. When using the PATH option to insert a segment with a unique sequence field, it is possible that the insert will result in an II status code. An II status code is treated as an error with respect to the MAXERRORS option of the SET command. If using the default MAXERRORS count of 1 and the default PROCESS option of NOSKIP, the program will be terminated when the first II status code is received.
When a NOPATH condition exists, the following three phases of processing occur:
- During the first phase the COUNT, PRINT, and CHANGE sub-commands, if specified, are considered for processing. Processing starts with the object keyword closest to the top of the hierarchical sequence and proceeds down the hierarchy to the last object keyword with a selected segment. Object keywords that have specified NOPATH or ALWAYS for the COUNT, PRINT, or CHANGE sub-command are executed.
- During the second phase the DELETE sub-command, if specified, is considered for processing. Processing starts with the object keyword closest to the top of the hierarchical sequence and proceeds down the hierarchy to the last object keyword with a selected segment. When an object keyword that has specified NOPATH or ALWAYS for the DELETE sub-command is found, the DELETE sub-command is then executed.
- During the third and final phase the INSERT sub-command, if specified, is considered for processing. If a DELETE was performed and the insert NOPATH or ALWAYS is specified at the delete level, the insert is performed at that level and continues down the lower levels where the insert NOPATH or ALWAYS was specified. If a DELETE was not performed, processing starts with the first object keyword that does not have a selected segment and proceeds down the hierarchy to the last object keyword that specified NOPATH or ALWAYS for the INSERT sub-command.
When performing either PATH or NOPATH processing, each sub-command is performed only once per selected segment. The following example illustrates this point.
segments.
SELECT SEGMENT=CUSTOMER
SEGMENT=CUSTORDR MAX=ALL
PRINT SEGMENT=CUSTOMER
SEGMENT=CUSTORDR;
In this example the customer CU0001 has three customer order segments (CUOR01, CUOR02, and CUOR03). A PATH condition exists three times:
once for CU0001 and CUOR01,
once for CU0001 and CUOR02,
once for CU0001 and CUOR03.
When the first PATH condition (CU0001 and CUOR01) is encountered, the customer (CU0001) and the customer order (CUOR01) segments are printed. When the second and third PATH conditions are encountered, only the customer order (CUOR02 and CUOR03) segments are printed.
At the completion of the PATH or NOPATH process, Step 1 of the SELECT primary command resumes. Refer to here for a description of the execution of SELECT. The current position is determined as follows:
- If a DELETE or an INSERT command was not executed, the current position in the hierarchy is at the bottom level of the select for a PATH condition. Processing is at the current position at the level above the NOPATH level for a NOPATH condition.
- If a DELETE sub-command was executed, the current position in the hierarchy is immediately following and at the same hierarchical level as the deleted segment.
- If an INSERT sub-command was executed, the current position in the hierarchy is immediately following the current segment on the next higher hierarchical level above the inserted segment.
If the INSERT sub-command fails during the insert process, no attempts are made to insert any dependent segments
The following values enable you to determine the processing to be performed based on the results of the SELECT primary command.
ALWAYS | Process for either PATH or NOPATH condition. |
NOPATH | Process only if the specified path does not exist. |
PATH | Process only if the specified path exists. |
A different value can be specified for each SEGMENT object keyword. The values are mutually exclusive and are invalid with the CHILD object keyword.
ALWAYS
Processing occurs when either a PATH or NOPATH condition exists. For example:
SEGMENT=B
SEGMENT=C
PRINT SEGMENT=A OPTION=ALWAYS
SEGMENT=B
SEGMENT=C
If segment A is found, it is processed regardless of the outcome of segments B and C.
NOPATH
A NOPATH condition exists when a selected segment is not found for each object keyword. For example:
SEGMENT=B
SEGMENT=C
PRINT SEGMENT=A OPTION=NOPATH
SEGMENT=B OPTION=NOPATH
SEGMENT=C
If segments A and B are found and C is not, a NOPATH condition exists. Segments A and B are processed.
PATH
A PATH condition exists when a selected segment is found for each object keyword. For example:
SEGMENT=B
SEGMENT=C
PRINT SEGMENT=A OPTION=PATH
SEGMENT=B OPTION=PATH
SEGMENT=C
If segments A, B, and C are found, a PATH condition exists. Segments A, B, and C (default OPTION=PATH) are processed.