|
|
| Author |
Message |
vvmanyam
New User
Joined: 16 Apr 2008 Posts: 37 Location: Bangalore
|
|
|
|
Hi Friends,
I have a sample input file which looks like this
| Code: |
AABB 213456 0001 1001
AABB 213456 0001 2002
AABB 213456 0001 3003
AABB 213456 0001 4004
AABB 213456 0001 5005
AABB 213456 0001 6006
AABB 123458 0002 0101
AABB 123458 0002 0202
AABB 123458 0002 0303
AABB 123458 0002 0404
AABB 123458 0002 0505
AABB 123458 0003 0051
AABB 123458 0003 0052
AABB 123458 0003 0053
AABB 123458 0003 0054
AABB 123458 0003 0055
AABB 412489 0004 0401
AABB 412489 0004 0402
AABB 412489 0004 0403
AABB 412489 0004 0404
|
There are no empty lines between the records just for understanding i copied like that.
Each record is made of key which is of 3 parts.
First part is same for all the records.
Socond part may be same for more than one set of records.
Third part will be different for every set of records.
Fourth part is just data which may be any thing.
Requirement is if the first 10 bytes of is same for 2 sets of data.
Retain the data of only one set in to the output file and all other sets will be written to second file.
Output1:
| Code: |
AABB 213456 0001 1001
AABB 213456 0001 2002
AABB 213456 0001 3003
AABB 213456 0001 4004
AABB 213456 0001 5005
AABB 213456 0001 6006
AABB 123458 0002 0101
AABB 123458 0002 0202
AABB 123458 0002 0303
AABB 123458 0002 0404
AABB 123458 0002 0505
AABB 412489 0004 0401
AABB 412489 0004 0402
AABB 412489 0004 0403
AABB 412489 0004 0404
|
Ouput2:
| Code: |
AABB 123458 0003 0051
AABB 123458 0003 0052
AABB 123458 0003 0053
AABB 123458 0003 0054
AABB 123458 0003 0055
|
The key '123458' is same for second and third set so, this set should come to ouput2
I tried to put the question as simple as I can
Hope I am clear
Regards,
Balu |
|
| Back to top |
|
 |
References
|
|
 |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 802 Location: Chennai, India
|
|
|
|
Balu,
Can you provide some more inputs?????
| Quote: |
| Socond part may be same for more than one set of records. |
If the second part is the same for 2 groups, will both the groups have the same number of records????
Thanks,
Arun |
|
| Back to top |
|
 |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 802 Location: Chennai, India
|
|
|
|
Balu,
You might want to give this a try. I have assumed FB files of LRECL=80. This works even if the second group has different number of records.
JCL
| Code: |
//STEP01 EXEC PGM=SORT
//*
//SYSOUT DD SYSOUT=*
//*
//SORTIN DD DSN=your.input.file,DISP=SHR
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(13,4))),
IFTHEN=(WHEN=INIT,OVERLAY=(89:SEQNUM,8,ZD,RESTART=(1,11)))
SORT FIELDS=COPY
OUTREC OVERLAY=(81:89,8,ZD,SUB,81,8,ZD,M11,LENGTH=8)
OUTFIL FNAMES=OUT1,INCLUDE=(81,8,ZD,EQ,0),BUILD=(1,80)
OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)
//* |
SORTIN input
| Code: |
AABB 213456 0001 1001
AABB 213456 0001 2002
AABB 213456 0001 3003
AABB 213456 0001 4004
AABB 213456 0001 5005
AABB 213456 0001 6006
AABB 123458 0002 0101
AABB 123458 0002 0202
AABB 123458 0002 0303
AABB 123458 0002 0404
AABB 123458 0002 0505
AABB 123458 0003 0051
AABB 123458 0003 0052
AABB 123458 0003 0053
AABB 123458 0003 0054
AABB 123458 0003 0055
AABB 412489 0004 0401
AABB 412489 0004 0402
AABB 412489 0004 0403
AABB 412489 0004 0404 |
OUT1
| Code: |
AABB 213456 0001 1001
AABB 213456 0001 2002
AABB 213456 0001 3003
AABB 213456 0001 4004
AABB 213456 0001 5005
AABB 213456 0001 6006
AABB 123458 0002 0101
AABB 123458 0002 0202
AABB 123458 0002 0303
AABB 123458 0002 0404
AABB 123458 0002 0505
AABB 412489 0004 0401
AABB 412489 0004 0402
AABB 412489 0004 0403
AABB 412489 0004 0404 |
OUT2
| Code: |
AABB 123458 0003 0051
AABB 123458 0003 0052
AABB 123458 0003 0053
AABB 123458 0003 0054
AABB 123458 0003 0055 |
Thanks,
Arun |
|
| Back to top |
|
 |
vvmanyam
New User
Joined: 16 Apr 2008 Posts: 37 Location: Bangalore
|
|
|
|
Hi,
arcvns,
| Quote: |
| will both the groups have the same number of records???? |
Not necceserily
Arun,
Thanks a lot, Understood the solution.
Thanks,
Balu |
|
| Back to top |
|
 |
|
|
|