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:

  1. 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.

    ⋮
    
     Template:
        Data set name . 'FMN.RFM0569.PDSE'                                          
        Member  . . . . TMPLB1  
  2. 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.

      Process   Options   Help
     ──────────────────────────────────────────────────────────────────────────────
     File Manager                Record Type Selection                  Line 1 of 9
    
     Processing Option:    Template for segmented data
     Cmd SIE Field Name                                       Prompt   Offset Length
             ****  Top of data  ****
         S   HEADER-01                                                      0     20
         S   HEADER-02                                                      0     20
         S   HEADER-03                                                      0     20
         S   DETAIL-0101                                                    0     30
         S   DETAIL-0102                                                    0     30
         S   DETAIL-0103                                                    0     30
         S   DETAIL-0201                                                    0     30
         S   DETAIL-0202                                                    0     30
         S   DETAIL-0203                                                    0     30
             ****  End of data  ****
    
    
    
    
     Command ===>                                                       Scroll CSR 
      F1=Help      F2=Split     F3=Exit      F4=CRetriev  F5=RFind     F6=RunTemp
      F7=Up        F8=Down      F9=Swap     F12=Cancel
  3. Select (if currently unselected) the Template for segmented data option.
  4. 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).
      Process   Options   Help
     ──────────────────────────────────────────────────────────────────────────────
     File Manager                Record Type Selection                  Line 1 of 9
    
     Processing Option: /  Template for segmented data
     Cmd SIE Field Name                                       Prompt   Offset Length
             ****  Top of data  ****
         S   HEADER-01                                                      0     20
         S   HEADER-02                                                      0     20
         S   HEADER-03                                                      0     20
     E   S   DETAIL-0101                                                    0     30
         S   DETAIL-0102                                                    0     30
         S   DETAIL-0103                                                    0     30
         S   DETAIL-0201                                                    0     30
         S   DETAIL-0202                                                    0     30
         S   DETAIL-0203                                                    0     30
             ****  End of data  ****
    ⋮
  5. Press Enter.

    File Manager displays the Field Selection/Edit panel showing the selected layout.

      Process   Options   Help
     ──────────────────────────────────────────────────────────────────────────────
     File Manager                 Field Selection/Edit                  Line 1 of 6
    
     ---Criteria - Enter 0 - Related ID expression, 1 or 2 - expression by field---
     0 Rid:                                                                       +
     1 Id :                                                                       +
     2 Sel: 0                                                                     +
     Offset      0           Enter "/" to OR with related ID
     Cmd Seq SHE Ref  Field Name                          Picture  Type Start Length
                      ****  Top of data  ****
                   1  1 DETAIL-0101                                 AN      1     30
                   2   2 SUBTYPE-FIELD                              AN      1      9
                   3    3 SUBTYPECONST                    X(7)      AN      1      7
                   4    3 TYPEREC                         X(2)      AN      8      2
                   5   2 DETAILTEXT01                               AN     10     21
                   6    3 DETAIL01-01                     X(21)     AN     10     21
                      ****  End of data  ****
    
    
    
     Command ===>                                                       Scroll CSR 
      F1=Help      F2=Split     F3=Exit      F4=Expand    F5=RFind     F6=RunTemp
      F7=Up        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel
    Note:
    1. The 0 Rid line at the top of the panel is blank (unless you have previously specified a related ID expression).
    2. The ability to OR the identification criteria with related ID by selecting the processing option.
  6. 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.
      Process   Options   Help
     ──────────────────────────────────────────────────────────────────────────────
     File Manager           RID Selection for DETAIL-0101               Line 1 of 8
    
     E against layouts to specify related id criteria
     Cmd SIE Field Name                                       Prompt   Offset Length
             ****  Top of data  ****
         SI  HEADER-01                                                      0     20
         SI  HEADER-02                                                      0     20
         S   HEADER-03                                                      0     20
         SI  DETAIL-0102                                                    0     30
         S   DETAIL-0103                                                    0     30
         S   DETAIL-0201                                                    0     30
         S   DETAIL-0202                                                    0     30
         S   DETAIL-0203                                                    0     30
             ****  End of data  ****
    
    
    
    
    
     Command ===>                                                       Scroll CSR 
      F1=Help      F2=Split     F3=Exit      F4=CRetriev  F5=RFind     F6=RunTemp
      F7=Up        F8=Down      F9=Swap     F12=Cancel
  7. Type the E prefix command in the Cmd field against the layout in which the related ID criteria are held.
    ⋮
    
     Cmd SIE Field Name                                       Prompt   Offset Length
             ****  Top of data  ****
     E   S   HEADER-01                                                      0     20
         S   HEADER-02                                                      0     20
         S   HEADER-03                                                      0     20
         S   DETAIL-0102                                                    0     30
         S   DETAIL-0103                                                    0     30
         S   DETAIL-0201                                                    0     30
         S   DETAIL-0202                                                    0     30
         S   DETAIL-0203
    ⋮
  8. Press Enter.

    File Manager displays the Related ID expression panel showing the selected layout.

      Process   Options   Help
     ──────────────────────────────────────────────────────────────────────────────
     File Manager    Related Id expression for DETAIL-0101              Line 1 of 7
    
     -------- Criteria - Enter 0 to specify related ID expression by field --------
     0 Rid:                                                                       +
     Offset      0           Enter "/" to OR with related ID
     Cmd Seq SHE Ref  Field Name                          Picture  Type Start Length
                      ****  Top of data  ****
                   1  1 HEADER-01                                   AN      1     20
                   2   2 ALLGROUP                                   AN      1     20
                   3    3 TYPE-FIELD                                AN      1      8
                   4     4 TYPECONST                      X(6)      AN      1      6
                   5     4 TYPEREC                        X(2)      AN      7      2
                   6    3 HEADERTEXT                                AN      9     12
                   7     4 HEAD01-TEXT                    X(12)     AN      9     12
                      ****  End of data  ****
    
    
     Command ===>                                                       Scroll CSR 
      F1=Help      F2=Split     F3=Exit      F4=Expand    F5=RFind     F6=RunTemp
      F7=Up        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel
    Note: The ability to OR the related criteria with other related ID by selecting the processing option.
  9. 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.

      Process   Options   Help
     ──────────────────────────────────────────────────────────────────────────────
     File Manager    Related Id expression for DETAIL-0101              Line 1 of 7
    
     -------- Criteria - Enter 0 to specify related ID expression by field --------
     0 Rid: #5='01'                                                               +
     Offset      0           Enter "/" to OR with related ID
     Cmd Seq SHE Ref  Field Name                          Picture  Type Start Length
                      ****  Top of data  ****
                   1  1 HEADER-01                                   AN      1     20
                   2   2 ALLGROUP                                   AN      1     20
                   3    3 TYPE-FIELD                                AN      1      8
                   4     4 TYPECONST                      X(6)      AN      1      6
                   5     4 TYPEREC                        X(2)      AN      7      2
                   6    3 HEADERTEXT                                AN      9     12
                   7     4 HEAD01-TEXT                    X(12)     AN      9     12
                      ****  End of data  ****
    
    
     Command ===>                                                       Scroll CSR 
      F1=Help      F2=Split     F3=Exit      F4=Expand    F5=RFind     F6=RunTemp
      F7=Up        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel
  10. Press the Exit function key (F3) to return to the RID Selection panel.
  11. Press the Exit function key (F3) again to return to the Field Selection/Edit panel.
      Process   Options   Help
     ──────────────────────────────────────────────────────────────────────────────
     File Manager                 Field Selection/Edit                  Line 1 of 6
    
     ---Criteria - Enter 0 - Related ID expression, 1 or 2 - expression by field---
     0 Rid: SEG(HEADER-01):#5: TYPEREC    ='01'                                   +
     1 Id :                                                                       +
     2 Sel: 0                                                                     +
     Offset      0           Enter "/" to OR with related ID
    
                      ****  Top of data  ****
                   1  1 DETAIL-0101                                 AN      1     30
                   2   2 SUBTYPE-FIELD                              AN      1      9
                   3    3 SUBTYPECONST                    X(7)      AN      1      7
                   4    3 TYPEREC                         X(2)      AN      8      2
                   5   2 DETAILTEXT01                               AN     10     21
                   6    3 DETAIL01-01                     X(21)     AN     10     21
                      ****  End of data  ****
    
    
    
     Command ===>                                                       Scroll CSR 
      F1=Help      F2=Split     F3=Exit      F4=Expand    F5=RFind     F6=RunTemp
      F7=Up        F8=Down      F9=Swap     F10=Left     F11=Right    F12=Cancel

    You will now see the related ID expression on the 0 Rid line at the top of the Field Selection/Edit panel.

  12. On the 1 Id and 2 Sel lines, specify record identification and or selection criteria by field as required.
      Process   Options   Help
     ──────────────────────────────────────────────────────────────────────────────
     File Manager                 Field Selection/Edit                  Line 1 of 6
    
     ---Criteria - Enter 0 - Related ID expression, 1 or 2 - expression by field---
     0 Rid: SEG(HEADER-01):#5: TYPEREC    ='01'                                   +
     1 Id : #4='01'                                                               +
     2 Sel: 0                                                                     +
     Offset      0           Enter "/" to OR with related ID
    
    ⋮
  13. 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:

    ⋮
            Col 1       Insert Length 8160            Record AT TOP     Format CHAR
            ----+----10---+----2----+----3----+----4----+----5----+----6----+----7--
     ****** ****  Top of data  ****
     000001 1234AsegBsegBsegCsegCsegCsegDsegDsegDsegDseg
     000002 0202BsegBsegDsegDseg
     000003 1232AsegBsegBsegCsegCsegCsegDsegDseg
     ****** ****  End of data  ****
    ⋮

    The data above can be mapped with the following template:

    File Manager                Record Type Selection                  Line 1 of 2
    
     Processing Option:    Template for segmented data
     Cmd SIE Field Name                                       Prompt   Offset Length
             ****  Top of data  ****
      e  SI  SEG-HDR                                                        0      4
      e  SI  SEG-A                                                          0      4
      e  SI  SEG-B                                                          0      4
      e  SI  SEG-C                                                          0      4
      e  SI  SEG-D                                                          0      4
             ****  End of data  ****
    ⋮

    Examine the criteria for each segment.

    Header segment segno() = 1 ensures its always the first segment on the record.

    File Manager                 Field Selection/Edit                  Line 1 of 5
    
     ---Criteria - Enter 0 - Related ID expression, 1 or 2 - expression by field---
     0 Rid:                                                                       +
     1 Id : segno()=1                                                             +
     2 Sel:                                                                       +
     Offset      0           Enter "/" to OR with related ID
     Cmd Seq SHE Ref  Field Name                          Picture  Type Start Length
                      ****  Top of data  ****
                   1  1 SEG-HDR                                     AN      1      4
                   2   2 SEG-NUM-A                        9         ZD      1      1
                   3   2 SEG-NUM-B                        9         ZD      2      1
                   4   2 SEG-NUM-C                        9         ZD      3      1
                   5   2 SEG-NUM-D                        9         ZD      4      1
                      ****  End of data  ****
    ⋮
    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.

    File Manager                 Field Selection/Edit                  Line 1 of 3
    
     ---Criteria - Enter 0 - Related ID expression, 1 or 2 - expression by field---
     0 Rid: SEG(SEG-HDR):segcnt('seg-a') < #2: SEG-NUM-A                          +
     1 Id :                                                                       +
     2 Sel:                                                                       +
     Offset      0           Enter "/" to OR with related ID
     Cmd Seq SHE Ref  Field Name                          Picture  Type Start Length
                      ****  Top of data  ****
                   1  1 SEG-A                                       AN      1      4
                   2   2 SEG-TYPE                         X(1)      AN      1      1
                   3   2 SEG-DATA                         X(3)      AN      2      3
                      ****  End of data  ****
    ⋮
    File Manager           RID Selection for SEG-A                     Line 1 of 4
    
     E against layouts to specify related id criteria
     Cmd SIE Field Name                                       Prompt   Offset Length
             ****  Top of data  ****
     e   SI  SEG-HDR                                                        0      4
         SI  SEG-B                                                          0      4
         SI  SEG-C                                                          0      4
         SI  SEG-D                                                          0      4
             ****  End of data  ****
    ⋮

    Press Enter.

    File Manager    Related Id expression for SEG-A                    Line 1 of 5
    
     -------- Criteria - Enter 0 to specify related ID expression by field --------
     0 Rid: segcnt('seg-a') < #2                                                  +
     Offset      0           Enter "/" to OR with related ID
     Cmd Seq SHE Ref  Field Name                          Picture  Type Start Length
                      ****  Top of data  ****
                   1  1 SEG-HDR                                     AN      1      4
                   2   2 SEG-NUM-A                        9         ZD      1      1
                   3   2 SEG-NUM-B                        9         ZD      2      1
                   4   2 SEG-NUM-C                        9         ZD      3      1
                   5   2 SEG-NUM-D                        9         ZD      4      1
                      ****  End of data  ****
    ⋮
    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:

    File Manager    Related Id expression for SEG-B                    Line 1 of 5
    
     -------- Criteria - Enter 0 to specify related ID expression by field --------
     0 Rid: segcnt('seg-b') < #3                                                  +
     Offset      0           Enter "/" to OR with related ID
     Cmd Seq SHE Ref  Field Name                          Picture  Type Start Length
                      ****  Top of data  ****
                   1  1 SEG-HDR                                     AN      1      4
                   2   2 SEG-NUM-A                        9         ZD      1      1
                   3   2 SEG-NUM-B                        9         ZD      2      1
                   4   2 SEG-NUM-C                        9         ZD      3      1
                   5   2 SEG-NUM-D                        9         ZD      4      1
                      ****  End of data  ****
    ⋮
    File Manager    Related Id expression for SEG-C                    Line 1 of 5
    
     -------- Criteria - Enter 0 to specify related ID expression by field --------
     0 Rid: segcnt('seg-c') < #4                                                  +
     Offset      0           Enter "/" to OR with related ID
     Cmd Seq SHE Ref  Field Name                          Picture  Type Start Length
                      ****  Top of data  ****
                   1  1 SEG-HDR                                     AN      1      4
                   2   2 SEG-NUM-A                        9         ZD      1      1
                   3   2 SEG-NUM-B                        9         ZD      2      1
                   4   2 SEG-NUM-C                        9         ZD      3      1
                   5   2 SEG-NUM-D                        9         ZD      4      1
                      ****  End of data  ****
    ⋮
    File Manager    Related Id expression for SEG-D                    Line 1 of 5
    
     -------- Criteria - Enter 0 to specify related ID expression by field --------
     0 Rid: segcnt('seg-d') < #5                                                  +
     Offset      0           Enter "/" to OR with related ID
     Cmd Seq SHE Ref  Field Name                          Picture  Type Start Length
                      ****  Top of data  ****
                   1  1 SEG-HDR                                     AN      1      4
                   2   2 SEG-NUM-A                        9         ZD      1      1
                   3   2 SEG-NUM-B                        9         ZD      2      1
                   4   2 SEG-NUM-C                        9         ZD      3      1
                   5   2 SEG-NUM-D                        9         ZD      4      1
                      ****  End of data  ****
    ⋮

    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.

    ⋮
     View             FMN.RFM0757.SEGTEST(SEG2)                         Top of 3
                                                      Record AT TOP     Format TABL
            SEG-NUM-A SEG-NUM-B SEG-NUM-C SEG-NUM-D
                   #2        #3        #4        #5
               ZD 1:1    ZD 2:1    ZD 3:1    ZD 4:1
                   <>        <>        <>        <>
     ****** ****  Top of data  ****
     000001         1         2         3         4
     - - -  - - -1- - - SEG-A - - - - - - - - - - - - - 1 Line(s) suppressed
     - - -  - - -1- - - SEG-B - - - - - - - - - - - - - 2 Line(s) suppressed
     - - -  - - -1- - - SEG-C - - - - - - - - - - - - - 3 Line(s) suppressed
     - - -  - - -1- - - SEG-D - - - - - - - - - - - - - 4 Line(s) suppressed
     000002         0         2         0         2
     - - -  - - -2- - - SEG-B - - - - - - - - - - - - - 2 Line(s) suppressed
     - - -  - - -2- - - SEG-D - - - - - - - - - - - - - 2 Line(s) suppressed
     000003         1         2         3         2
     - - -  - - -3- - - SEG-A - - - - - - - - - - - - - 1 Line(s) suppressed
     - - -  - - -3- - - SEG-B - - - - - - - - - - - - - 2 Line(s) suppressed
     - - -  - - -3- - - SEG-C - - - - - - - - - - - - - 3 Line(s) suppressed
     - - -  - - -3- - - SEG-D - - - - - - - - - - - - - 2 Line(s) suppressed
    ⋮