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

Sum up the fields in Sort


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


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

PostPosted: Sat Sep 27, 2008 9:10 pm
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
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
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
Reply with quote

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