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
 

 

SORT, eliminate and SUM fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: SORT, eliminate and SUM fields
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 Moderator


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

PostPosted: Wed Nov 14, 2007 4:13 am    Post subject:
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    Post subject: SORT, eliminate and SUM fields
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 Moderator


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

PostPosted: Thu Nov 15, 2007 5:23 am    Post subject:
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    Post subject: Reply to: SORT, eliminate and SUM fields
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    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 Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm


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