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

Sum up a field & then pick specific record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
razesh84

New User


Joined: 05 Apr 2010
Posts: 41
Location: Kolkata,India

PostPosted: Wed Jul 13, 2011 3:34 pm
Reply with quote

Hi,

My input file looks like this [lrecl=10]
Code:

----+----1
**********
A1 1.0   
A2 0.0
A3 0.3   
A3 0.6   
B2 0.9   
B2 0.1   


where first 2 bytes are key.
My requirement is to add the fields from position 4-6 for every key & pick only those records whose summed value is exactly 1.0
Anything smaller or greater than 1.0 should be discarded.

So, my o/p file should look like
Code:

----+----1
**********
A1 1.0   
B2 1.0   


Can you give me a card that meets the requirement.

Thanks
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jul 13, 2011 4:12 pm
Reply with quote

Where are you stuck up? at summing the decimal records? or at after summing while dropping records which are not 1?
Back to top
View user's profile Send private message
razesh84

New User


Joined: 05 Apr 2010
Posts: 41
Location: Kolkata,India

PostPosted: Wed Jul 13, 2011 4:12 pm
Reply with quote

sorry for my mistake

o/p file sud contain A1 & B2 records

Code:

----+----1
**********
A1 1.0   
B2 0.9   
B2 0.1   


also i need a discard file which contains discarded records

Code:

----+----1
**********
A2 0.0
A3 0.3   
A3 0.6   
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Jul 13, 2011 7:28 pm
Reply with quote

Hi,
Try with this...
Code:

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
A1 1.0                                                               
A2 0.0                                                               
A3 0.3                                                               
A3 0.6                                                               
B2 0.9                                                               
B2 0.1                                                               
//SORTOUT  DD DSN=&&TEMP,DISP=(NEW,PASS)                             
//SYSIN    DD *                                                       
  SORT FIELDS=(1,2,CH,A)                                             
  OUTFIL REMOVECC,NODETAIL,                                           
  SECTIONS=(1,2,TRAILER3=(1,2,3:TOT=(3,4,SFF,EDIT=(ST.T),SIGNS=(,-))))
/*                                                                   
//STEP0200 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//FILE1    DD *                               
A1 1.0                                       
A2 0.0                                       
A3 0.3                                       
A3 0.6                                       
B2 0.9                                       
B2 0.1                                       
//FILE2    DD DSN=&&TEMP,DISP=(MOD,PASS)     
//SORTOUT  DD SYSOUT=*                       
//SYSIN DD *                                 
  SORT FIELDS=(1,2,CH,A)                     
  JOINKEYS F1=FILE1,FIELDS=(1,2,A),SORTED     
  JOINKEYS F2=FILE2,FIELDS=(1,2,A),SORTED,   
  OMIT=(4,3,CH,NE,C'1.0')                     
  JOIN UNPAIRED,F2                           
  REFORMAT FIELDS=(F1:1,10)                   
/*

Output will be..
Code:

A1 1.0
B2 0.9
B2 0.1
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed Jul 13, 2011 7:35 pm
Reply with quote

See if below works...
I assumed input and expected output is FB/80 and your numbers are UFF.
Code:
//STEP0001     EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                           
//SORTJNF1 DD *                                   
A1 0.1                                           
A1 0.2                                           
A1 0.3                                           
A1 0.4                                           
A2 1.0                                           
A3 0.1                                           
A3 0.1                                           
A3 0.1                                           
//SORTJNF2 DD *                                   
A1 0.1                                           
A1 0.2                                           
A1 0.3                                           
A1 0.4                                           
A2 1.0                                           
A3 0.1                                           
A3 0.1                                           
A3 0.1                                           
//SORTOUT  DD SYSOUT=*                           
//SYSIN    DD *                                   
  JOINKEYS FILES=F1,FIELDS=(01,02,A)             
  JOINKEYS FILES=F2,FIELDS=(01,02,A)             
  REFORMAT FIELDS=(F1:01,80,F2:81,3)             
  INCLUDE COND=(81,3,ZD,EQ,100)                   
  SORT FIELDS=COPY                               
  OUTREC BUILD=(1,80)                             
/*                                               
//JNF2CNTL DD *                                   
 INREC OVERLAY=(81:4,3,UFF,MUL,+10,TO=ZD,LENGTH=3)
 SUM FIELDS=(81,3,ZD)                             
//*                                               

OUTPUT
Code:
A1 0.1
A1 0.2
A1 0.3
A1 0.4
A2 1.0

Thanks,
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Wed Jul 13, 2011 7:50 pm
Reply with quote

Sorry I didn't realize you needed discarded records as well and by the time I tested the job, I was well past 10 minutes limit.
Code:

//STEP0001     EXEC PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                     
//SORTJNF1 DD *                                             
A1 0.1                                                     
A1 0.2                                                     
A1 0.3                                                     
A1 0.4                                                     
A2 1.0                                                     
A3 0.1                                                     
A3 0.1                                                     
A3 0.1                                                     
//SORTJNF2 DD *                                             
A1 0.1                                                     
A1 0.2                                                     
A1 0.3                                                     
A1 0.4                                                     
A2 1.0                                                     
A3 0.1                                                     
A3 0.1                                                     
A3 0.1                                                     
//SELECT   DD SYSOUT=*                                     
//REJECT   DD SYSOUT=*                                     
//SYSIN    DD *                                             
  JOINKEYS FILES=F1,FIELDS=(01,02,A)                       
  JOINKEYS FILES=F2,FIELDS=(01,02,A)                       
  REFORMAT FIELDS=(F1:01,80,F2:81,3)                       
  SORT FIELDS=COPY                                         
  OUTFIL FNAMES=SELECT,INCLUDE=(81,3,ZD,EQ,100),BUILD=(1,80)
  OUTFIL FNAMES=REJECT,SAVE,BUILD=(1,80)                   
/*                                                         
//JNF2CNTL DD *                                             
 INREC OVERLAY=(81:4,3,UFF,MUL,+10,TO=ZD,LENGTH=3)         
 SUM FIELDS=(81,3,ZD)                                       
//*                                                         

Thanks,
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top