Aneesh
New User
Joined: 30 Sep 2006 Posts: 60
|
|
|
|
Hi,
I have a file that has location number and customer number.
File FB 80 bytes
Location 9(4)
Filler X(20)
Customerid 9(14)
Filler X (42)
I have a requirement to generate a 6 digit sequence number starting from 1 at the end of the file with the condition - everytime a location changes, sequnce number should be incremented. Within the same
location, after every 150 customers, the sequence number should be incremented.
Sample Input
Location Customer-id
0331 00000000000001
0331 00000000000002
... (150 customer records for same location)
0331 00000000000149
0331 00000000000150
0331 00000000000151
0332 00000000000001
0332 00000000001234
0333 00000000001234
Sample Output
Location Customer-id Sequence number
0331 00000000000001 000001
0331 00000000000002 000001
... 000001
0331 00000000000149 000001
0331 00000000000150 000001
0331 00000000000151 000002
0332 00000000000001 000003
0332 00000000001234 000003
0333 00000000001234 000004
Any pointers for this to be done with sort would be helpful.
Aneesh. |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
The following DFSORT Control cards will give you the desired results
Code: |
//SYSIN DD *
SORT FIELDS=(1,4,CH,A)
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,6,ZD,RESTART=(1,4),
SEQNUM,8,ZD)),
IFTHEN=(WHEN=(81,6,ZD,EQ,1,OR,81,6,ZD,GT,150),
OVERLAY=(81:6X),HIT=NEXT),
IFTHEN=(WHEN=(81,6,CH,EQ,C' '),OVERLAY=(87:SEQNUM,8,ZD)),
IFTHEN=(WHEN=NONE,OVERLAY=(95:SEQNUM,8,ZD,
87:87,8,ZD,SUB,95,8,ZD,M11,LENGTH=8))
OUTFIL BUILD=(1,4,25,14,89,6)
//*
|
The output lay of the file is
Code: |
Location 9(4)
Customerid 9(14)
Seqnume 9(6)
|
Hope this helps...
Cheers |
|