Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sum based on a particular field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Jithucse

New User


Joined: 18 Apr 2008
Posts: 11
Location: Coimbatore

PostPosted: Thu Dec 03, 2009 5:53 pm    Post subject: Sum based on a particular field
Reply with quote

Hi,

I've have a requirement like this...My input file contains records as shown below..

ABD10Y
ABD20Y
DEF10N
DEF30N
DEF30N
GEH40Y

And my output records are...

ABD30
DEF0
GEH40

That is if the sixth byte is 'Y', then i will be adding the amount fields(4,5) of that key.

Can anyone suggest any method in sort?

Regards,
Jithucse
Back to top
View user's profile Send private message

Escapa

Senior Member


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

PostPosted: Thu Dec 03, 2009 7:21 pm    Post subject:
Reply with quote

Hi Jithucse,
Do you want sum to be left alligned?
Back to top
View user's profile Send private message
Jithucse

New User


Joined: 18 Apr 2008
Posts: 11
Location: Coimbatore

PostPosted: Thu Dec 03, 2009 7:22 pm    Post subject: Reply to: Sum based on a particular field
Reply with quote

Not required..I'm fine with

ABD30
DEF 0
FEH40
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Thu Dec 03, 2009 7:29 pm    Post subject:
Reply with quote

Hi below sortstep will give you desired result

Code:

//S1    EXEC  PGM=SORT                                                 
//SORTIN DD *                                                           
ABD10Y                                                                 
ABD20Y                                                                 
DEF10N                                                                 
DEF30N                                                                 
DEF30N                                                                 
GEH40Y                                                                 
//SORTOUT DD SYSOUT=*                                                   
//SYSOUT    DD  SYSOUT=*                                               
//SYSPRINT DD SYSOUT=*                                                 
//SYSIN    DD  *                                                       
  SORT FIELDS=(1,3,CH,A)                                               
  SUM FIELDS=(4,2,ZD)                                                   
  INREC IFTHEN=(WHEN=(6,1,CH,EQ,C'N'),OVERLAY=(4:C'00'))               
  OUTFIL BUILD=(1,3,4,2,ZD,EDIT=(IT))                                   
/*                                                                     
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Thu Dec 03, 2009 7:46 pm    Post subject:
Reply with quote

But I suggest you to use this so that sum fields will not overflow...
Code:

//S1    EXEC  PGM=SORT                                   
//SORTIN DD *                                             
ABD10Y                                                   
ABD20Y                                                   
DEF10N                                                   
DEF30N                                                   
DEF30N                                                   
GEH99Y                                                   
GEH99Y                                                   
GEH99Y                                                   
GEH99Y                                                   
//SORTOUT DD SYSOUT=*                                     
//SYSOUT    DD  SYSOUT=*                                 
//SYSPRINT DD SYSOUT=*                                   
//SYSIN    DD  *                                         
  SORT FIELDS=(1,3,CH,A)                                 
  SUM FIELDS=(4,8,ZD)                                     
  INREC IFTHEN=(WHEN=(6,1,CH,EQ,C'N'),BUILD=(1,3,8C'0')),
        IFTHEN=(WHEN=NONE,BUILD=(1,3,6C'0',4,2))         
  OUTFIL BUILD=(1,3,4,8,ZD,EDIT=(IIIIIIIT))             
/*                                                       

Output will be
Code:

ABD      30   
DEF       0   
GEH     396   
Back to top
View user's profile Send private message
Jithucse

New User


Joined: 18 Apr 2008
Posts: 11
Location: Coimbatore

PostPosted: Thu Dec 03, 2009 8:09 pm    Post subject: Reply to: Sum based on a particular field
Reply with quote

Thanks Sambhaji,

It worked...Thanks a lot...

Regards,
Jithucse
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Dec 03, 2009 10:18 pm    Post subject: Reply to: Sum based on a particular field
Reply with quote

Jithucse,

Since your input is already sorted on the key, you can use COPY instead of sort and here is another way to get the desired results without worrying about the overflow and padding the records before summing

Code:

//SYSIN    DD *                                           
  SORT FIELDS=COPY                                       
  INREC IFTHEN=(WHEN=(6,1,CH,EQ,C'N'),OVERLAY=(4:C'00')) 
  OUTFIL REMOVECC,NODETAIL,                               
  SECTIONS=(1,3,TRAILER3=(1,3,TOT=(4,2,ZD,M10,LENGTH=8)))
//*
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Dec 03, 2009 11:16 pm    Post subject:
Reply with quote

Sambhaji,

I'm curious. Why do you have

//SYSPRINT DD SYSOUT=*

in your DFSORT jobs? DFSORT does NOT use this ddname.
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Thu Dec 03, 2009 11:51 pm    Post subject:
Reply with quote

Yeah... You are right Frank.

I copied STEP from existing JCL(calling some other program) and changed it for this example.
Missed to delete SYSPRINT
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to select record x+7 or x+2 based... JoAnn Kulcyk SYNCSORT 6 Tue Jan 16, 2018 10:49 pm
No new posts Split files upto certain limit based ... bubbu75 DFSORT/ICETOOL 5 Tue Nov 14, 2017 11:11 pm
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us