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

Adding up columns of the record


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

New User


Joined: 20 Jul 2006
Posts: 30

PostPosted: Tue Apr 10, 2012 12:22 pm
Reply with quote

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
View user's profile Send private message
lvbntapasvi

New User


Joined: 20 Jul 2006
Posts: 30

PostPosted: Tue Apr 10, 2012 1:01 pm
Reply with quote

The length of each input column is 18 digits+1 decimal point.
Back to top
View user's profile Send private message
lvbntapasvi

New User


Joined: 20 Jul 2006
Posts: 30

PostPosted: Tue Apr 10, 2012 1:11 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Tue Apr 10, 2012 1:15 pm
Reply with quote

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
View user's profile Send private message
lvbntapasvi

New User


Joined: 20 Jul 2006
Posts: 30

PostPosted: Tue Apr 10, 2012 1:18 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Tue Apr 10, 2012 1:55 pm
Reply with quote

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
View user's profile Send private message
lvbntapasvi

New User


Joined: 20 Jul 2006
Posts: 30

PostPosted: Tue Apr 10, 2012 4:08 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Apr 10, 2012 4:15 pm
Reply with quote

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
View user's profile Send private message
lvbntapasvi

New User


Joined: 20 Jul 2006
Posts: 30

PostPosted: Tue Apr 10, 2012 4:53 pm
Reply with quote

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
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Adding QMF and SPUFI to the ISPF menu DB2 20
Search our Forums:

Back to Top