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
 

 

Sum up the fields in sort for a specific condition

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

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Mon Sep 29, 2008 1:04 pm    Post subject: Sum up the fields in sort for a specific condition
Reply with quote

Can anyone give me the JCL for the below query please:

My input is:
Code:

ABCDEFGHIJK T 3
LSKDSLDKSLS L 4
KSDKLADALKS T 4
ABCDEFGHIJK L 3
KSDKLADALKS T 2
LSKDSLDKSLS T 1
LSKDSLDKSLS T 3
LSKDSLDKSLS L 3
ABCDEFGHIJK T 1
ABCDEFGHIJK L 3
ABCDEFGHIJK L 2


THE OUTPUT SHOULD LOOK LIKE:
Code:

LSKDSLDKSLS L 4
KSDKLADALKS T 4
KSDKLADALKS T 2
LSKDSLDKSLS T 1
LSKDSLDKSLS T 3
LSKDSLDKSLS L 3
ABCDEFGHIJK T 4
ABCDEFGHIJK L 8


In short, the Field 3 should be added based on Field1 and Field2 only if Field1 has ‘ABCDEFGHIJK’. Field 2 can have the value T or L. The output in Field3 should contain the sum based on Field1 with T, and Field1 with L (if there is any)
Back to top
View user's profile Send private message

nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Mon Sep 29, 2008 2:45 pm    Post subject:
Reply with quote

I don't want to add Field3 for all the criteria. The Field3 should be added only if Field1 is 'ABCDEFGHIJK' and the FIELD1 Field1 with T or Field1 with L. I have to hardcode the FIELD1. This is bz it can have any values. Hope we can not Hardcode in SORT FIELDS. so im unable to use SORT FIELDS. Can u sagest some other way to solve this.
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: Mon Sep 29, 2008 9:36 pm    Post subject:
Reply with quote

Here's a DFSORT job that will do what I think you asked for. I assumed your input file has RECFM=FB and LRECL=80. I couldn't figure out what output order you wanted the records in so I just sorted them by the first two fields.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
ABCDEFGHIJK  T   3
LSKDSLDKSLS  L   4
KSDKLADALKS  T   4
ABCDEFGHIJK  L   3
KSDKLADALKS  T   2
LSKDSLDKSLS  T   1
LSKDSLDKSLS  T   3
LSKDSLDKSLS  L   3
ABCDEFGHIJK  T   1
ABCDEFGHIJK  L   3
ABCDEFGHIJK  L   2
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
   INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
     IFTHEN=(WHEN=(1,11,CH,EQ,C'ABCDEFGHIJK'),OVERLAY=(81:8C'0'))
   SORT FIELDS=(1,11,CH,A,14,1,CH,A,81,8,ZD,A)
   OPTION ZDPRINT
   SUM FIELDS=(18,1,ZD)
   OUTREC BUILD=(1,80)
/*


SORTOUT would have:

Code:

ABCDEFGHIJK  L   8     
ABCDEFGHIJK  T   4     
KSDKLADALKS  T   4     
KSDKLADALKS  T   2     
LSKDSLDKSLS  L   4     
LSKDSLDKSLS  L   3     
LSKDSLDKSLS  T   1     
LSKDSLDKSLS  T   3     
Back to top
View user's profile Send private message
nelson.pandian

Active User


Joined: 09 Apr 2008
Posts: 133
Location: Phoenix, AZ

PostPosted: Tue Sep 30, 2008 9:31 am    Post subject:
Reply with quote

Thanks Frank... I got the output...
Thank u very much icon_smile.gif
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 SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts Db2 load job abending in SORT mistah kurtz DB2 4 Mon Jun 05, 2017 3:58 pm


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