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 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 OC4 in SORT Mohan Kothakota DFSORT/ICETOOL 2 Tue Sep 12, 2017 6:30 pm
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts SORT Trailer Count - LRECL Output co... amorante DFSORT/ICETOOL 5 Tue Aug 29, 2017 8:57 pm
No new posts Changing sort Card Dynamically vickey_dw DFSORT/ICETOOL 5 Sat Aug 19, 2017 2:33 pm
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm

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