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

help with SORT/ICETOOL


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

New User


Joined: 16 Jan 2015
Posts: 12
Location: USA

PostPosted: Tue Nov 10, 2015 7:10 am
Reply with quote

Hi,

I need help with the below scenario.

I have a VB file with different array elements (say 10 subscript) of fixed size

e.g:

Code:
DEPT - X(3)
FILLER - X(10)
AMt -   S9(3)V99.


Code:
Dept(1)   Amt(1)   Dept(2)   Amt(2).....   Dept(10)   Amt(10)
----------------------------------------------------------------------      
100          200.00   433         980.09   566   700.22
200          -22.00   455       -189.99           220   99.00
220          -2344.02   300        700.22           900   200.00
300          2356.01   220        99.00           922   -22.00


Now, I want to sum the amount of all the Dept using Sort JCL

in the above e.g - Dept 220 - sum Amt (-2146.02)

Please help me with this regard,

Thanks.

Code'd
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Nov 10, 2015 7:39 am
Reply with quote

I believe some things are easier done than said.

You can use RESIZE in Icetool or Outfil '/' operator to break the records such that you get records containing 1 row for each Dept and Amt. Then, it would be easier to SUM the amount fields for each/specific Dept.

.
Back to top
View user's profile Send private message
anand1204

New User


Joined: 16 Jan 2015
Posts: 12
Location: USA

PostPosted: Tue Nov 10, 2015 7:43 am
Reply with quote

Thanks Rahul.

It would be great if you can send me an example or I can look up online.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Nov 10, 2015 8:02 am
Reply with quote

Okay. As you said that the amount field is S9(3), you can't have amount in thousands. Also, you need to specify the location of the sign field and Do you have 0s in front if the amount field is less than 3 digits and You can't have decimal in the data if it is an assumed decimal field (V99) i.e.

is it
Code:
200   -22.00   455   -189.99   220   99.00

Or
Code:
200   -22.00   455   -189.99   220   +99.00

Or
Code:
200   -022.00   455   -189.99   220   +099.00

Or
Code:
200   -02200   455   -18999   220   +09900


Use code tags to preserve spacing (in case of filler) and provide the accurate data.

.
Back to top
View user's profile Send private message
anand1204

New User


Joined: 16 Jan 2015
Posts: 12
Location: USA

PostPosted: Tue Nov 10, 2015 8:14 am
Reply with quote

Hi Raghu..

Sorry for the confusion. here is my example data


DEPT(1) AMT(1) DEPT(2) AMT(2) DEPT(10) AMT(10)
---------------------------------------------------
100 20000 433 98009 566 70022
200 -02200 455 -18999 220 09900
220 -34402 300 70022 900 20000
300 35601 220 09900 922 -02200
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Nov 10, 2015 9:21 am
Reply with quote

So, If your input is:
Code:
//IN1      DD *
100  20000 433  98009 566  70022
200 -02200 455 -18999 220  09900
220 -34402 300  70022 900  20000
300  35601 220  09900 922 -02200

You can use:
Code:
//TOOLIN DD *
 RESIZE FROM(IN1) TO(TEMP) TOLEN(11)
 COPY FROM(TEMP) TO(OUT) USING(CTL1)
/*
//CTL1CNTL DD *
 OMIT COND=(1,3,CH,EQ,C'   ')
 SORT FIELDS=(1,3,CH,A)
 OUTFIL REMOVECC,NODETAIL,
     SECTIONS=(1,3,
      TRAILER3=(1,4,TOT=(5,6,FS,EDIT=(STTTTT),SIGNS=(,-))))

Your output will look:
Code:
100  20000
200 -02200
220 -14602
300  05623
433  98009
455 -18999
566  70022
900  20000
922 -02200


.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Nov 10, 2015 12:21 pm
Reply with quote

You can't RESIZE variable-length records.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Nov 10, 2015 12:47 pm
Reply with quote

You need two passes of the data to do it entirely with SORT Control Cards.

If this needs to be with SORT Control Cards (the use of the word JCL is irrelevant, and has nothing with SORT) because you have an existing SORT, consider writing an EXIT, which can be in COBOL.

If you are doing it in SORT just because someone says so (often, stupidly, less paperwork) then is the OCCURS the last thing in the record, or does it always contain 10 elements? You're heading towards Rahul's other suggestion, to use the slash operator (/) to output multiple records from on record, and then a second simple step to do the totalling.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Nov 10, 2015 3:10 pm
Reply with quote

Moved to the correct part of the forum.
Please do not post images - a simple cut'n'paste is adequate, quicker and takes fewer resources.
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 Shift left VB record without x00 endi... DFSORT/ICETOOL 11
Search our Forums:

Back to Top