Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Dropping records based on zero sum - special case

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Dropping records based on zero sum - special case
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: 1703
Location: Australia

PostPosted: Wed Mar 14, 2012 11:17 am    Post subject:
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: 1756
Location: UK

PostPosted: Wed Mar 14, 2012 1:45 pm    Post subject:
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    Post subject: Reply to: Dropping records based on zero sum - special case
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    Post subject: Reply to: Dropping records based on zero sum - special case
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us