View previous topic :: View next topic
|
Author |
Message |
sujithsamuel
New User
Joined: 22 Dec 2006 Posts: 11 Location: Chennai
|
|
|
|
Hi
I have a particular requirement in which there is a need to discard records based on whether the resultant sum of a particular field is zero.
Please find the input file below
BHASKAR 29| 10
BHASKAR 29| 00
BOSE 29| 00
BOSE 29| 00
NATU 27| 00
NARESH 27| 12
The key is from the start of the record till the pipe character '|'.
The requirement is to sum the records based on the key and then discard the records which give zero sum.
The output in this case should be
BHASKAR 29| 10
BHASKAR 29| 00
NARESH 27| 12
Note that in above case the second record did not get discarded because for the same key non zero value exists.
Please help on the same |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
ok I made a couple of assumptions, LRECL is 80 RECFM is FB
The length of the key is max of 20 bytes
The length of the field after the pipe is 4 bytes
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
BHASKAR 29| 10
BHASKAR 29| 00
BOSE 29| 00
NATU 27| 00
NARESH 27| 12
/*
//OUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
PARSE=(%00=(ENDAT=C'|',FIXLEN=20),
%01=(FIXLEN=4)),
OVERLAY=(81:%00,%01))
SORT FIELDS=(81,20,BI,A,101,4,UFF,D)
OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(81,20),PUSH=(105:101,4))
OUTFIL FNAMES=OUT,INCLUDE(105,4,UFF,NE,+0),BUILD=(1,80)
/* |
Gerry |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
You have posted in another forum in the SYNCSORT section. Why are you posting in the DFSORT section here? Your other topic has been locked. |
|
Back to top |
|
|
sujithsamuel
New User
Joined: 22 Dec 2006 Posts: 11 Location: Chennai
|
|
|
|
Sorry Nic
But my installation supports SYNCSORT and not DFSORT.
I should have originally posted in SYNCSORT.
Could you please let me know the SYNCSORT solution.
Thanks |
|
Back to top |
|
|
bodatrinadh
Active User
Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
|
|
|
|
Hello sujithsamuel,
Try this below code.
Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTIN DD *
BHASKAR 29| 10
BHASKAR 29| 00
BOSE 29| 00
BOSE 29| 00
NATU 27| 00
NARESH 27| 12
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,
PARSE=(%00=(ENDBEFR=C'|',FIXLEN=20),%01=(FIXLEN=4)),
OVERLAY=(81:%00,%01,105:SEQNUM,8,ZD,RESTART=(81,20),
113:SEQNUM,8,ZD,RESTART=(81,24)))
SORT FIELDS=COPY
OUTFIL BUILD=(1,24),
INCLUDE=((102,2,CH,EQ,C'00',AND,113,8,CH,NE,105,8,CH),OR,
(102,2,CH,NE,C'00',AND,113,8,CH,EQ,105,8,CH))
|
Output :-
Code: |
BHASKAR 29| 10
BHASKAR 29| 00
NARESH 27| 12
|
Thanks
-3nadh |
|
Back to top |
|
|
|
|