IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Dropping records based on zero sum - special case


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sujithsamuel

New User


Joined: 22 Dec 2006
Posts: 11
Location: Chennai

PostPosted: Wed Mar 14, 2012 9:43 am
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Mar 14, 2012 11:17 am
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Mar 14, 2012 1:45 pm
Reply with quote

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
View user's profile Send private message
sujithsamuel

New User


Joined: 22 Dec 2006
Posts: 11
Location: Chennai

PostPosted: Wed Mar 14, 2012 5:14 pm
Reply with quote

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
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Wed Mar 14, 2012 10:42 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top