View previous topic :: View next topic
|
Author |
Message |
lvbntapasvi
New User
Joined: 20 Jul 2006 Posts: 30
|
|
|
|
Hello everyone,
I have a requirement here where in I am supposed to add the columns in the same record and the resultant total should be inserted as a new column in the output file (including the columns in the input file).
The input with FB is shown below, please note that the fields are numeric with a single decimal point,
Code: |
+0000000000075397820 +0000000000074522236
+0000000000000049280 +0000000000000004480
|
And the output file should look like,
Code: |
+0000000000075397820 +0000000000074522236 +0000000000149920056
+0000000000000049280 +0000000000000004480 +0000000000000053760 |
I have tried with the below sort card and it is abending with S0C7,
Code: |
OPTION COPY
INREC OVERLAY=(64:1,10,PD,ADD,21,10,PD,
EDIT=(SIIIIIIIIIIIIIIIIIT.T))
|
Is there any other DFSORT format which can be used to achieve this?
Thanks in advance for your help. |
|
Back to top |
|
|
lvbntapasvi
New User
Joined: 20 Jul 2006 Posts: 30
|
|
|
|
The length of each input column is 18 digits+1 decimal point. |
|
Back to top |
|
|
lvbntapasvi
New User
Joined: 20 Jul 2006 Posts: 30
|
|
|
|
Sorry a small change, my input layout itself has the decimal point which looks like this,
Code: |
+000000000007539782.0 +000000000007452223.6
+000000000000004928.0 +000000000000000448.0 |
And the output file should look like,
Code: |
+000000000007539782.0 +000000000007452223.6 +000000000014992005.6
+000000000000004928.0 +000000000000000448.0 + +000000000000005376.0 |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Can we assume the "+ +" is a typo?
Is this related to your "strip" processing in the Cobol forum?
What would negative values look like?
Do you mean decimal point or decimal place? |
|
Back to top |
|
|
lvbntapasvi
New User
Joined: 20 Jul 2006 Posts: 30
|
|
|
|
1) Sorry Bill, yes, ++ was typo.
2) Yes, thats the same strip processing. I have added + to the positive values.
3) Negative values would have minus sign - prefixed
4) My input has the values with one decimal place, as shown above. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Yes, there is a DFSORT data format to do this.
You were attempting Packed Decimal (PD) processing of your data. You really have Zoned Decimal plus a sign and a decimal place.
Although capable of more than you need, you'll find the Free Format (FF) data types will do what you want. You have Signed Free Format, which is SFF.
If you do a search for SFF in the manual and find the table it is in you'll see good descriptions of all the data types. Read through them all, so you know what is there, then concentrate on the PDs, ZDs and FFs. |
|
Back to top |
|
|
lvbntapasvi
New User
Joined: 20 Jul 2006 Posts: 30
|
|
|
|
Thanks Bill, I have made use of SFF in my sort card and my columns are getting added now. Here's the sort card which I have made use of to add my 26 columns data,
Code: |
OPTION COPY
OUTREC BUILD=(1,600,
(23,20,SFF,ADD,45,20,SFF,ADD,67,20,SFF,ADD, and so on))
|
But, however I have observed that the total amount for few fields is getting truncated. For example, my input for first record is 26 columns having values,
Code: |
+000000000007452223.6
+000000000008155566.0
+000000000007530180.2
+000000000007413404.0
+000000000007386999.9
+000000000007351305.1
+000000000007159863.2
+000000000006837583.5
+000000000006804602.3
+000000000007191901.8
+000000000008514042.6
+000000000008018320.9
+000000000007847856.3
+000000000007918532.5
+000000000007963653.3
+000000000007719708.1
+000000000006230721.2
+000000000008173929.6
+000000000008193597.5
+000000000007630063.5
+000000000007785466.2
+000000000007260624.9
+000000000007541486.1
+000000000008234919.7
+000000000008589356.1
+000000000007555620.0 |
which sums up to 198461528.1. However, my output file using the above sort card shows the value 198461518 only without any decimal. Is there any way through which I can re-format my output file which will show up the result including decimals.
Input file LRECL=600, RECFM=FB,
Output file LRECL=632,RECFM=FB,
Thanks again. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
all Your posts have been edited to add the code tags, in order to make the DATA more readable
( the code tags force a FIXED pitch font which preserves the alignment ) |
|
Back to top |
|
|
lvbntapasvi
New User
Joined: 20 Jul 2006 Posts: 30
|
|
|
|
Bill, I have fixed the above and I am now getting the desired output. Actually in the sort card I was supposed to extract 21 digits, while I was doing it for only 20, as above. I have rectified it and it is working now with proper SUM values. Thanks for your support. |
|
Back to top |
|
|
|