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

Sum up the fields in sort for a specific condition


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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 Developer


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

PostPosted: Mon Sep 29, 2008 9:36 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top