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
 

 

summing using sort card

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
rajeshwarch

New User


Joined: 24 Mar 2008
Posts: 29
Location: mumbai

PostPosted: Thu May 28, 2009 12:46 pm    Post subject: summing using sort card
Reply with quote

Hi everybody,

I need to calculate the sum of some specific field. the field position is 587 and length is 5. it is in packed decimal format. and the file is fixed block.

I tried with this below sort card

//step01 exec pgm=sort
//sortin dd dsn=xxx
//sortout dd dsn=yyyy
//sysin dd *
SORT FIELDS=COPY
SUM FIELDS=(587,5,PD)
//

But the output file is not giving any sum value.
please help me how to achieve it.
and i want to see the sum value in zd format.
Back to top
View user's profile Send private message

bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Thu May 28, 2009 12:48 pm    Post subject:
Reply with quote

For SORT FIELDS=COPY, SUM FIELDS will not work.Give some postion in the sort field and try it..
Back to top
View user's profile Send private message
rajeshwarch

New User


Joined: 24 Mar 2008
Posts: 29
Location: mumbai

PostPosted: Thu May 28, 2009 12:56 pm    Post subject:
Reply with quote

Thanks Bepen

I need to calculate sum for all records...!!

then what should be my sort card
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Thu May 28, 2009 1:42 pm    Post subject:
Reply with quote

I dont know the exact reason.But what i seen that if you give sort fields=copy the SUM FIELDS will not work.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2177
Location: @my desk

PostPosted: Thu May 28, 2009 2:08 pm    Post subject:
Reply with quote

rajeshwarch wrote:
Thanks Bepen

I need to calculate sum for all records...!!

then what should be my sort card
Search the forum, you will find many working examples for summation. If you are stuck up somewhere post the output from your job and the expected output. Somebody here might be able to help
Back to top
View user's profile Send private message
bipinpeter

Active User


Joined: 18 Jun 2007
Posts: 208
Location: Cochin/Kerala/India

PostPosted: Thu May 28, 2009 5:26 pm    Post subject:
Reply with quote

Hi rajeshwarch,

Code:
//step01 exec pgm=sort
//sortin dd dsn=xxx
//sortout dd dsn=yyyy
//sysin dd *
SORT FIELDS=(1,1,CH,A)
SUM FIELDS=(587,5,PD)
//
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu May 28, 2009 6:39 pm    Post subject:
Reply with quote

Bipin Peter,

you are assuming that the file is already sorted and has no dups in col 1.
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: Thu May 28, 2009 9:01 pm    Post subject:
Reply with quote

Rajesh,

If you just want to display the total of the PD field as a ZD field, you can use DFSORT control statements like this:

Code:

  OPTION COPY                         
  OUTFIL REMOVECC,NODETAIL,           
    TRAILER1=(TOT=(587,5,PD,TO=ZD))


If you want something else, be more specific about what you want.
Back to top
View user's profile Send private message
rajeshwarch

New User


Joined: 24 Mar 2008
Posts: 29
Location: mumbai

PostPosted: Fri May 29, 2009 7:00 pm    Post subject:
Reply with quote

Hi frank,

Thanks for ur reply. Its working fine. and I have a small doubt here. After converting PD to ZD, can we edit that ZD value using edit masks....!!
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: Fri May 29, 2009 9:11 pm    Post subject:
Reply with quote

You said
Quote:
i want to see the sum value in zd format

so I converted it to ZD. If you want an edited value, you can use an edit mask instead of TO=ZD. For example:

Code:

   TRAILER1=(TOT=(587,5,PD,M10))
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Summing on Mixed Case Literals Roy Ware SYNCSORT 3 Tue Jan 03, 2017 10:18 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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