View previous topic :: View next topic
|
Author |
Message |
Binaya
New User
Joined: 03 Jul 2007 Posts: 77 Location: Hyderabad
|
|
|
|
Hello
Need help on the below.
Want to sort the input file on key filed-1 to give output file as below.
field-1 = 9(3)
filed-2 = x(3)
filed-3 = x(3)
Input file:
======
field-1 field-2 filed-3
==== ==== =====
100 abc xyz
300 bcd xyp
200 dbf xyn
100 adb xtp
150 dfg fsd
Required Output file:
=============
field-1 field-2 filed-3
==== ==== =====
100 abc xyz
100 adb xtp
300 bcd xyp
200 dbf xyn
150 dfg fsd
Regards
Binaya |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
What do you need help with. What are the rules of the required sort.
What have you tried so far and what is it that is giving you problems.
You say that you want to sort on field 1 but your shown output is not consistent with your request. |
|
Back to top |
|
|
Binaya
New User
Joined: 03 Jul 2007 Posts: 77 Location: Hyderabad
|
|
|
|
expat wrote: |
What do you need help with. What are the rules of the required sort.
What have you tried so far and what is it that is giving you problems.
You say that you want to sort on field 1 but your shown output is not consistent with your request. |
I need records with same key to be in sequence without disturbing other records. Of course other records will shift the row position.
In my request 1'st and 4'th record have the same key.
So these 2 records should be in sequence in the output.
This can be done by tables & search in COBOL but don't have any clues if this can be by SORT.
Thanks
Binaya |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Show a more comprehensive set of test data (both more records and more kinds of duplication/triplication). It may help if you get rid of the alphabet soup and use something easier to relate to.
Clearly explain the rules for the grouping of the output. As your example shows, it is not in any sort key sequence.
Use the Code tag to preserve alignment and improve readability. |
|
Back to top |
|
|
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Binaya,
assuming 80 byte input file.
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
100 ABC XYZ
300 BCD XYP
200 DBF XYN
100 ADB XTP
150 DFG FSD
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
//T1 DD DSN=&&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//CTL1CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD)
SORT FIELDS=(1,3,ZD,A)
OUTREC OVERLAY=(91:SEQNUM,8,ZD,RESTART=(1,3))
OUTFIL IFTHEN=(WHEN=GROUP,BEGIN=(91,08,ZD,EQ,1),PUSH=(91:81,8))
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(91,08,ZD,A)
OUTREC BUILD=(1,80)
/* |
Thanks, |
|
Back to top |
|
|
|