I am trying to partition a fairly large RECFM=VB dataset (220K+ records) by 
various characteristics of the records using a unique identifier byte and a 
SEQNUM.  The goal is to be able to subsequently extract in a second pass some 
"count" number of records by "type" to create an extracted sample file with a 
counted number of each type of record.  The original input is sequenced by a 
record key in bytes 1-136.

To start with I am partitioning the records by type, assigning a type 
identifier and a SEQNUM, but the problem is that the SEQNUM does not restart at 
1 for each unique identifier and does not consistently increment by 1 for each 
record of each type.

This is the SYSIN control input:

  SORT FIELDS=(5,147,CH,A)
  INREC IFTHEN=(WHEN=INIT,
                BUILD=(1,4,5:C' ',
                       6:SEQNUM,10,ZD,START=1,RESTART=(5,1),
                       16:5)),
        IFTHEN=(WHEN=(16,2,CH,EQ,X'0000'),               HEADER RECORD (1 PER 
FILE)
                BUILD=(1,4,5:C'A',6)),
        IFTHEN=(WHEN=(16,2,CH,EQ,X'FFFF'),               TRAILER RECORD (1 PER 
FILE)
                BUILD=(1,4,5:C'Z',6)),
        IFTHEN=(WHEN=(16,2,CH,EQ,C'D1',AND,          FIRST TYPE
                      (1370,1,CH,EQ,C'Y',OR,
                       1371,1,CH,EQ,C'Y')),
                BUILD=(1,4,5:C'C',6)),
        IFTHEN=(WHEN=(16,2,CH,EQ,C'D1',AND,         SECOND TYPE (none of this 
type occur in the example input file)
                      1604,2,CH,EQ,C'CD'),
                BUILD=(1,4,5:C'D',6)),
        IFTHEN=(WHEN=(16,2,CH,EQ,C'D1',AND,         THIRD TYPE
                      (1145,1,CH,EQ,C'2',OR,
                       1145,1,CH,EQ,C'4')),
                BUILD=(1,4,5:C'E',6)),
        IFTHEN=(WHEN=NONE,                                          NOT ONE OF 
THE OTHER TYPES
                BUILD=(1,4,5:C'B',6))

This control input results in output identifiers "A", "B" and "Z" each getting 
a SEQNUM starting at 1, but identifiers "C" and "E" (there are no "D" types in 
the example input file) each seem to start at numbers equal to their record 
number in the original dataset minus 1 (e.g., input record # 51 is the first 
type "C" record and gets SEQNUM 50).

Subsequent records of each type do not get "prior SEQNUM of unique type + 1" 
value, but again a SEQNUM equal to their record number in the original dataset 
minus 1 (e.g., third record of type "C" gets SEQNUM 52 but fourth record of 
type "C" gets SEQNUM 125).

What I want to see in the output is that all unique identifiers get a SEQNUM 
starting at 1 and incrementing by 1 for each record of that type.  Below are 
example outputs showing the SEQNUM values resulting from the above SORT control 
instructions.

Any help you can provide in generating the result I am aiming to produce is 
appreciated.

Peter

Example output results showing only identifier, SEQNUM and first 2 bytes of 
record:

A0000000001..                   (This is the header record)
B0000000001D1
B0000000002D1
. . .
B0000225201D1
C0000000050D1                 (First "C" record Is not SEQNUM 1)
C0000000051D1
C0000000052D1
C0000000125D1                 (Fourth "C" record is not thired-record-SEQNUM + 
1)
C0000000126D1
. . .
C0000224188D1
E0000016714D1                 (Same issue as for "C" records)
E0000016715D1
E0000016716D1
E0000016717D1
E0000016736D1                 (Same issue as for "C" records)
E0000016737D1
. . .
E0000223279D1                 (Same issue as for "C" records)
E0000223280D1
E0000224051D1                 (Same issue as for "C" records)
E0000224052D1
Z0000000001..                    (This is the trailer record)

--


This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to