View previous topic :: View next topic
|
Author |
Message |
anand1204
New User
Joined: 16 Jan 2015 Posts: 12 Location: USA
|
|
|
|
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 |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
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 |
|
|
anand1204
New User
Joined: 16 Jan 2015 Posts: 12 Location: USA
|
|
|
|
Thanks Rahul.
It would be great if you can send me an example or I can look up online. |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
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 |
|
|
anand1204
New User
Joined: 16 Jan 2015 Posts: 12 Location: USA
|
|
|
|
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 |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You can't RESIZE variable-length records. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
|