|
View previous topic :: View next topic
|
| Author |
Message |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Hi Team,
I am in process of creating SORT CARD with Omit condition based on the Number of Inputs/Input. Typically 'OR' should be added at the end when there is more than one input .
| Code: |
//STEP100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD*
09999
08888
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(81:5X,SEQNUM,8,ZD)),
IFTHEN=(WHEN=(86,8,ZD,GT,1),OVERLAY=(81:C’,OR,’))
OUTFIL REMOVECC,
HEADER1=(2X,C’SORT FIELDS=COPY’,/,
2X,C’OMIT COND=(‘,80:X),
BUILD=(13X,C’21,05,CH,EQ,C’’’,1,5,C’’’’,80:X),
SECTIONS=(86,8,HEADER3=(33X,81,4)),
TRAILER1=(33X,’)’)
|
I still see the alignment is not proper due to my statments in my header /Build and Trailer statements in my output . Output i got
is
| Code: |
SORT FIELDS=COPY
OMIT COND=(
21,05,CH,EQ,C’09999’
,OR,
21,05,CH,EQ,C’08888’
)
|
I am in process of rearrange my statements on built in cards . Any help is very much appreciated . I saw few samples from our forum but it has dummy records added at the beginning and the end to have logical begin and end of sort card . |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
Why don’t you use JOINKEYS instead of having too many ORs which is sort of redundant ?
In your SORT CARD you don’t need OMIT COND in HEADER1, just BUILD it for first record only and if you don’t want spaces the SQZ it or don’t add it during the BUILD. |
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
| Thanks Rohit , will rephrase my statements on Build and will try to acheive my need on this logic. |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
| Code: |
//*============================================
//* SELECT DATA ON VALIDITY LIST
//*============================================
//SORTJOIN EXEC PGM=SORT
//*
//SYSOUT DD SYSOUT=*
//*
//VALIDATE DD *
09999
08888
//*
//MASTER DD *
01111 garbage data
08888 good data
07777 garbage data
05555 garbage data
08888 good data
09999 good data
03333 garbage data
00000 garbage data
02222 garbage data
01111 garbage data
09999 good data
03333 garbage data
04444 garbage data
//*
//SORTOUT DD SYSOUT=*
//*
//SYSIN DD *
JOINKEYS F1=MASTER,
FIELDS=(1,5,A)
JOINKEYS F2=VALIDATE,
FIELDS=(1,5,A)
*
REFORMAT FIELDS=(F1:1,80)
*
SORT FIELDS=COPY
*
END
//* |
| Code: |
********************************* TOP OF DATA *****
08888 good data
08888 good data
09999 good data
09999 good data
******************************** BOTTOM OF DATA *** |
|
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
Thanks Rohit for the example , here the problem is formatting . I am still working on it . |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
balaji81_k, Why are you still struggling creating the dynamic SORT card? I am mean you can always learn this way and you can continue to do that but right away solution is to use JOINKEYs as illustrated to solve the problem in hand.
The JOINKEYs solution is already dynamic in nature . |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2286 Location: USA
|
|
|
|
| Rohit Umarjikar wrote: |
balaji81_k, Why are you still struggling creating the dynamic SORT card? I am mean you can always learn this way and you can continue to do that but right away solution is to use JOINKEYs as illustrated to solve the problem in hand.
The JOINKEYs solution is already dynamic in nature . |
Speaking into the air... |
|
| Back to top |
|
 |
balaji81_k
Active User
Joined: 29 Jun 2005 Posts: 155
|
|
|
|
| Rohit Umarjikar wrote: |
balaji81_k, Why are you still struggling creating the dynamic SORT card? I am mean you can always learn this way and you can continue to do that but right away solution is to use JOINKEYs as illustrated to solve the problem in hand.
The JOINKEYs solution is already dynamic in nature . |
Hi Rohit,
Thanks for your valuable time and provide me an example, i come up with simple sort build which has Header and Trailer records with 'Begin' and 'End' and required records is in the body of Omit Condition.
| Code: |
SORT FIELDS=COPY
OUTREC FIELDS=(13X,C'01,05,CH,EQ,C''',1,5,C'''',C',OR,',80:X)
OUTFIL REMOVECC,
HEADER1=(2X,C'SORT FIELDS=COPY',/,
2X,C'OMIT COND=(01,05,CH,EQ,C''',
C'BEGIN',C'''',C',OR,',80:X)
TRAILER1=(13X,C'01,05,CH,EQ,C'END ',C'''',C')',80:X)
|
This sort card is fine and created required records in body along with Header and Trailer as per Build like
below
| Code: |
SORT IN DD*
01111
02222
SORT FIELDS=COPY
OMIT COND=(01,05,CH,EQ,C'BEGIN',OR,
01,05,CH,EQ,C'01111',OR,
01,05,CH,EQ,C'02222',OR,
01,05,CH,EQ,C'END ')
|
This sort build sample is ok for now and it solves my issue .
Thanks
Balaji K |
|
| Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3109 Location: NYC,USA
|
|
|
|
| Very Well. Thanks for posting back the solution. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|