View previous topic :: View next topic
|
Author |
Message |
rockish
Active User
Joined: 05 Jun 2009 Posts: 185 Location: Planet Earth
|
|
|
|
I have an input file which has many columns. I want to copy the records from my input file into an output file with a extra column (say col 2).
Col 2 should have the value 1 if the content of one particular column (say col 1) in that record is not equal to col1 of the previous record.
Col 2 should have the value one greater than col 2 of the previous record, if col 1 of this record matches with that of the previous record.
For instance, assume the following example,
Input Records :
A
B
C
C
B
D
E
E
E
B
E
A
D
Desired Output Records :
A1
B1
C1
C2
B1
D1
E1
E2
E3
B1
E1
A1
D1
As the above example shows, the col 2 value need not continue and have to restart when the col 1 repeats after a break. Its only when the previous and the current value of col 1 matches, col 2 has to increase.
Please note - I do not want a SORT to be done on the input records.. I only want a COPY..
I actually had couple of more activities to be done on the same input file like replacing certain strings with a different strings and conditional formatting based on the current record's value. But I already found ways to do that by using CHANGE/NOMATCH and IFTHEN resply. Despite trying to read DFSORT manual twice, I couldn't find which command can help me to match with the previous record. |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
rockish,
Use the following DFSORT JCL
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A
B
C
C
B
D
E
E
E
B
E
A
D
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(2:SEQNUM,1,ZD,RESTART=(1,1))
/* |
|
|
Back to top |
|
|
rockish
Active User
Joined: 05 Jun 2009 Posts: 185 Location: Planet Earth
|
|
|
|
Thanks a lot for your response Skolusu. It worked !!!!
Now I have a doubt. I also have one more thing to do. I need to omit all the records which repeats more than 5 times continuously. That is the no records with the sequence number greater than 5 should be in the output file.
I was in the assumption that OMIT COND will act on the INREC output. But just realised that OMIT acts on the input record. Hence if I give OMIT on the position of the sequence number, I am getting error message !!!!
ICE027A 2 END OF FIELD BEYOND MAXIMUM RECORD LENGTH
Can you please help me in finding out how to omit the record numbers beyond a particular sequence number ??? |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Use the following JCL. This appends the 2 byte seqnum in pos 10 and we drop the records where the sequence number is greater than 5. Look at the E record which is repeated 6 times
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A KEEP
B KEEP
C KEEP
C KEEP
B KEEP
D KEEP
E KEEP
E KEEP
E KEEP
E KEEP
E KEEP
E DROP
B KEEP
E KEEP
A KEEP
D KEEP
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(10:SEQNUM,2,ZD,RESTART=(1,1))
OUTFIL OMIT=(10,2,ZD,GT,5)
/*
|
|
|
Back to top |
|
|
rockish
Active User
Joined: 05 Jun 2009 Posts: 185 Location: Planet Earth
|
|
|
|
Thanks Kolusu
That solved my problem... |
|
Back to top |
|
|
|