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
 

 

Adding up columns of the record

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Adding up columns of the record
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    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Apr 10, 2012 1:15 pm    Post subject: Reply to: Adding up columns of the record
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Apr 10, 2012 1:55 pm    Post subject: Reply to: Adding up columns of the record
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    Post subject: Reply to: Adding up columns of the record
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Apr 10, 2012 4:15 pm    Post subject: Reply to: Adding up columns of the record
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    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm


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