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

SORT, eliminate and SUM fields


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

New User


Joined: 12 Nov 2007
Posts: 38
Location: Texas, USA

PostPosted: Wed Nov 14, 2007 3:34 am
Reply with quote

Hi,

Please suggest me a solution using JCL SORT. I have following data in a sequential file.

Code:

ITEM       QTY     PRICE        DATE
----       ---     -----        ----
ITEM_A     15      045.00    2007-09-05
ITEM_B     10      040.00    2007-09-11
ITEM_A     15      045.00    2007-09-14
ITEM_C     50      100.00    2007-09-17
ITEM_A     25      075.00    2007-09-19
ITEM_B     20      080.00    2007-09-22
ITEM_A     05      015.00    2007-09-25


Query
1. Quantity and price should be summed up for same item number and One item number should be displayed only once.
2. Eliminate the date field.

So following is the expected output

Code:

ITEM A    60    180.00
ITEM B    30    120.00
ITEM C    50    100.00


Thanks & Regards,
Satish
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 Nov 14, 2007 4:13 am
Reply with quote

You can use a DFSORT job like the following to do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
ITEM_A     15      045.00    2007-09-05
ITEM_B     10      040.00    2007-09-11
ITEM_A     15      045.00    2007-09-14
ITEM_C     50      100.00    2007-09-17
ITEM_A     25      075.00    2007-09-19
ITEM_B     20      080.00    2007-09-22
ITEM_A     05      015.00    2007-09-25
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  SORT FIELDS=(1,6,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(1,6,
      TRAILER3=(1,6,11:TOT=(12,2,ZD,EDIT=(TT)),
        17:TOT=(20,6,UFF,EDIT=(TTT.TT))))
/*
Back to top
View user's profile Send private message
Satish5

New User


Joined: 12 Nov 2007
Posts: 38
Location: Texas, USA

PostPosted: Thu Nov 15, 2007 4:35 am
Reply with quote

Thanks Frank for the quick reply.

Please help me understand what '1,6' means in "TRAILER3=(1,6,11:TOT=(12,2,ZD,EDIT=(TT)), 17:TOT=(20,6,UFF,EDIT=(TTT.TT)))) "

As per my understanding , 11 position of trailor will have total of field values at position 12 and length 2.

Please suggest how can I print a fields as such. For e.g. How can I print ITEM in trailor.

Thanks & Regards,
Satish
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: Thu Nov 15, 2007 5:23 am
Reply with quote

Quote:
Please help me understand what '1,6' means in "TRAILER3=(1,6


TRAILER3=(1,6 - each item value in positions 1-6 will appear in the output record in positions 1-6. So 'ITEM_A' will appear in the first record, 'ITEM_B' will appear in the second record and 'ITEM_C' will appear in the third record, which is what you asked for.

Quote:
As per my understanding , 11 position of trailor will have total of field values at position 12 and length 2.


For each item (e.g. 'ITEM_A', 'ITEM_B' and 'ITEM_C'), the total of the numeric values in 12-13 for that item will appear in output positions 11-12.

Quote:
Please suggest how can I print a fields as such. For e.g. How can I print ITEM in trailor.


I don't understand what you're asking. Each item (e.g. 'ITEM_A') will appear in an output record because we specified 1,6 in TRAILER3.
Back to top
View user's profile Send private message
Satish5

New User


Joined: 12 Nov 2007
Posts: 38
Location: Texas, USA

PostPosted: Thu Nov 22, 2007 2:20 am
Reply with quote

Thanks Frank icon_biggrin.gif . It helped me solve the problem.

Regards,
Satish
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