Editing related ID criteria
When you are working with segmented records with related ID criteria (that is, the ID criteria for a segment layout resides in another segment earlier in the physical record), you can edit the related ID criteria in the template as follows:
- In the Data set name field in the Template section
of the Template Workbench panel, type the name of the data set in
which your existing template for segmented data is stored.
Templates can be stored in PDS or PDSE data sets but not in a CA-Panvalet library, or a library accessed using the Library Management System Exit.
If you know it, type the Member name of the template into the relevant field or specify blanks or a pattern for the member name to have a member selection list displayed. You can then select the required member from the list.
- On the Command line, type the
E
command and press Enter.File Manager displays the Record Type Selection panel which lists each of the level-01 layouts in the template.
- Select (if currently unselected) the Template for segmented data option.
- Type the E prefix command in the Cmd field against the layout for which you want to specify related ID criteria (but which is held in another segment).
- Press Enter.
File Manager displays the Field Selection/Edit panel showing the selected layout.
Note:- The 0 Rid line at the top of the panel is blank (unless you have previously specified a related ID expression).
- The ability to OR the identification criteria with related ID by selecting the processing option.
- To enter or edit a related ID expression, type
0
(zero) on the command line and press Enter.For the selected layout, File Manager displays the RID Selection panel listing the other level-01 layouts in the template. - Type the E prefix command in the Cmd field against the layout in which the related ID criteria are held.
- Press Enter.
File Manager displays the Related ID expression panel showing the selected layout.
Note: The ability to OR the related criteria with other related ID by selecting the processing option. - On the 0 Rid line at the top of the Related ID expression
panel, specify (or edit) the related ID expression. Alternatively,
type
0
(zero) on the command line and press Enter to specify the related ID expression by field.Typically, the related ID expression specifies the field, and the value it contains, in the layout holding the related ID.
- Press the Exit function key (F3) to return to the RID Selection panel.
- Press the Exit function key (F3) again to return to the Field
Selection/Edit panel.
You will now see the related ID expression on the 0 Rid line at the top of the Field Selection/Edit panel.
- On the 1 Id and 2 Sel lines, specify record identification and or selection criteria by field as required.
- Using SEGNO() and SEGCNT() functions to identify your segments
The SEGNO and SEGCNT functions provide a mechanism for checking the current segment number being processed and the number of previous occurrences of a particular segment.
- SEGNO()
- Returns the current segment number.
- SEGCNT('01 field-name')
- Returns the number of previous occurrences of the segment with 01 field name specified.
The SEGNO and SEGCNT functions can only be specified in a free-format expression.
Example of their usage:
Consider the following sample data, where the first segment can be used to determine the number of following A, B, C, or D segments:
The data above can be mapped with the following template:
Examine the criteria for each segment.
Header segment
segno() = 1
ensures its always the first segment on the record.Note: The segment header contains the number of each of the following segments that occur.Segment A: note the related expression where we compare the previous occurrences to the value in the header.
Press Enter.
Note: We use SEGCNT and compare it to the value in the header to ensure that the number of SEG-A identified is determined by the header value.SEG-B, SEG-C, and SEG-D are all defined with a similar expression as follows:
Viewing the data with a segmented template produces the following where we can see the header segment has been used to determine the number of following segments.