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

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

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Sat Sep 27, 2008 3:17 pm    Post subject: Sum up the fields in Sort
Reply with quote

CAn anyone given 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:

ABCDEFGHIJK  T   4
ABCDEFGHIJK  L   8
KSDKLADALKS  T   6
LSKDSLDKSLS  T   4
LSKDSLDKSLS  L   7


in short , the Field 3 should be added based on Field1 and Field2
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

Frank Yaeger

DFSORT Moderator


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

PostPosted: Sat Sep 27, 2008 9:10 pm    Post subject:
Reply with quote

Here's a DFSORT job that will do what you asked for. Although your example shows only 1 byte numeric values and totals in position 18, I assumed that your numeric values were actually in positions 15-18 and coded for that. I also added records with 2 byte numeric values for a better test. You can adjust the job if appropriate.

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
11111111111  T  19
11111111111  T  13
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION ZDPRINT
  SORT FIELDS=(1,11,CH,A,14,1,CH,D)
  SUM FIELDS=(15,4,ZD)
  OUTREC OVERLAY=(15:15,4,ZD,EDIT=(IIIT))
/*


SORTOUT would have:

Code:

ABCDEFGHIJK  T   4   
ABCDEFGHIJK  L   8   
KSDKLADALKS  T   6   
LSKDSLDKSLS  T   4   
LSKDSLDKSLS  L   7   
11111111111  T  32   
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Tue Sep 30, 2008 4:23 pm    Post subject:
Reply with quote

Hi

I cannot use ICEMAN here ... Can you send me the JCL with ICETOOL or SORT ?
Field1 is at column1 length 11
Field2 is at column 20 length 1 (value L or T)
Field3 is at column 22 length (upto 8 digits)
Back to top
View user's profile Send private message
Escapa

Senior Member


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

PostPosted: Tue Sep 30, 2008 5:37 pm    Post subject:
Reply with quote

Solution given by Frank should work for SORT also..
What error you are getting? post it here
Back to top
View user's profile Send private message
dip62001

New User


Joined: 04 Jul 2005
Posts: 12
Location: Pune

PostPosted: Tue Sep 30, 2008 5:45 pm    Post subject:
Reply with quote

I am getting a SOC7 error
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: Tue Sep 30, 2008 9:04 pm    Post subject:
Reply with quote

Quote:
I cannot use ICEMAN here ... Can you send me the JCL with ICETOOL or SORT ?


This statement makes no sense. PGM=ICEMAN and PGM=SORT both invoke DFSORT.

Quote:
I am getting a SOC7 error


That would be caused by an invalid ZD value in positions 15-18 (the SUM field). Since you didn't say, I had to guess at what positions your ZD field was in. You only showed one digit in your example and I assumed that digit was at position 18.

Given the new information you've supplied about the actual positions of your fields, you would need the following DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD  DSN=...  output file
//SYSIN    DD    *
  OPTION ZDPRINT
  SORT FIELDS=(1,11,CH,A,20,1,CH,D)
  SUM FIELDS=(22,8,ZD)
  OUTREC OVERLAY=(22:22,8,ZD,EDIT=(IIIIIIIT))
/*
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