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

sort job to calculate amounts


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nmr

New User


Joined: 27 Sep 2007
Posts: 14
Location: hyderabad

PostPosted: Tue Dec 18, 2007 4:36 pm
Reply with quote

My requirement is I need to read one file and in that file
for the variable say lockbox-number I need to sort all the lockbox-numbers and I need to calculate the
same lockbox-number record amounts and write total to output file

for example in the input file lockbox-number are like this
----------------------------------------------------------

Code:

lockbox-number           amount

6064                        10
6064                        20
6064                        30
6065                        60
6065                        70
6065                        80
6064                        40
6064                        50


output file

Code:

lockbox-number     total

6064                 150
6065                 210


how can we write sort job to perform above output
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Tue Dec 18, 2007 6:26 pm
Reply with quote

Use the SUM FIELDS option of SORT...

Try searching the forum b4 posting
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Tue Dec 18, 2007 8:16 pm
Reply with quote

Hi,

Try this sort card

Code:
SUM FIELDS=(5,2,ZD)


Let me know if you need any more help
Back to top
View user's profile Send private message
nmr

New User


Joined: 27 Sep 2007
Posts: 14
Location: hyderabad

PostPosted: Tue Dec 18, 2007 8:37 pm
Reply with quote

Thanks khamarutheen

its working for me
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Dec 18, 2007 10:02 pm
Reply with quote

nmr wrote:
Thanks khamarutheen

its working for me


nmr,

Are you sure you got the right results? Your summing on 2 bytes will results in a overflow and you will NOT get the right results. Use the following DFSORT JCL which will you the desired results.

Code:

//STEP0100 EXEC PGM=ICEMAN       
//SYSOUT   DD SYSOUT=*         
//SORTIN   DD *               
6064 10                       
6064 20                       
6064 30                       
6065 60                       
6065 70                       
6065 80                       
6064 40                       
6064 50                       
//SORTOUT  DD SYSOUT=*         
//SYSIN    DD *     
  OPTION EQUALS         
  SORT FIELDS=(1,4,CH,A)       
  OUTFIL REMOVECC,NODETAIL,   
    SECTIONS=(1,4,               
       TRAILER3=(1,5,TOT=(6,2,ZD)))
//* 


Hope this helps...
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Wed Dec 19, 2007 9:12 am
Reply with quote

Quote:

Thanks khamarutheen

its working for me


nmr,

Above code doesnot give proper results.

Kolusu's solution is working fine.

Regards,
KSK
Back to top
View user's profile Send private message
nmr

New User


Joined: 27 Sep 2007
Posts: 14
Location: hyderabad

PostPosted: Wed Dec 19, 2007 10:31 am
Reply with quote

ksk or kolusu

if you do not mind can u tell me the meaning of below code what it does,
because i am not aware of sort

OPTION EQUALS
SORT FIELDS=(1,4,CH,A)
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,4,
TRAILER3=(1,5,TOT=(6,2,ZD)))
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: Wed Dec 19, 2007 10:21 pm
Reply with quote

Quote:
i am not aware of sort


I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
sreenivasreddyg

New User


Joined: 23 Apr 2005
Posts: 39
Location: delhi

PostPosted: Sat Dec 22, 2007 1:43 am
Reply with quote

What happens if that field is comp-3. SORT will add the amoutns in this case also?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Dec 22, 2007 2:00 am
Reply with quote

Hello,

Quote:
What happens if that field is comp-3. SORT will add the amoutns in this case also?
Sort will add the amounts if you define the positions as packed-decimal (for COMP-3 fields) rather than zoned-decimal.
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 Dec 22, 2007 2:38 am
Reply with quote

Quote:
What happens if that field is comp-3. SORT will add the amoutns in this case also?


DFSORT has many numeric formats (ZD, PD, BI, FI, FS, UFF, SFF) - you just have to specify the correct format for the input data you're processing. COMP-3 is equivalent to PD format.

For information on COBOL vs DFSORT formats, see:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA20/C.3?DT=20060615185603

You can use DFSORT's output formats and edit masks to change the input data to different forms. For more information see:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG20/2.4.7?DT=20060615173822

and

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CG20/2.4.8?DT=20060615173822
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 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
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
Search our Forums:

Back to Top