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
 

 

SUM ZONED DECIMAL S9(13)V99 USING INREC

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
kris_madras
Warnings : 1

New User


Joined: 04 Jul 2005
Posts: 26

PostPosted: Tue Apr 28, 2009 10:53 pm    Post subject: SUM ZONED DECIMAL S9(13)V99 USING INREC
Reply with quote

Apologies.... I did search first but couldn't find. Appreciate your help by replying to this question.

My COBOL code produces the output file with data (field-1) S9(13)V99. The data will have negative/positive values.

I used the following SYNCSORT statement to sum this field using INREC statement.
Code:

INREC FIELDS=(001:050,15,ZD,020:020,002)
SORT FIELDS=(020,002,CH,A)
SUM FIELDS=(001,015,ZD)

Here is the sample data

Code:
0000100
0000200
0000400   (Assume this is negative feild)

The INREC statement is interpreting this data as

Code:
100
200
400-

and in during sum, it is not considering '-' sign at the end. So I am receiving result as 700 instead of -200.

I used EDIT format in OUTREC to display negative sign in leading position.


Please help me.

Thanks,
Kris
Back to top
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Tue Apr 28, 2009 11:08 pm    Post subject:
Reply with quote

Quote:
Here is the sample data
Code:
0000100
0000200
0000400   (Assume this is negative feild)

Could you hex display one of these negative records and post it here?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 29, 2009 12:57 am    Post subject:
Reply with quote

Hello,

You need to get everything "on the same page". . .

You show 7-position input numbers, but declare them as 15. Not only 15, but zoned-decimal.

Zoned-decimal cannot contain an actual minus "-" sign. Zone-decimal data has the sign in the high-order nibble of the low-order byte.

Quote:
So I am receiving result as 700 instead of -200.
How would the values posted arrive at 200 (positive or negative)?
Back to top
View user's profile Send private message
kris_madras
Warnings : 1

New User


Joined: 04 Jul 2005
Posts: 26

PostPosted: Wed Apr 29, 2009 8:01 am    Post subject:
Reply with quote

Code:
Here is the control statement I used in SORT.

INREC FIELDS=(001:040,002,              CODE                   
                        010:051,015,ZD,         AMOUNT                   
                        030:C'000000001')        COUNTER                       
SORT FIELDS=(001,002,CH,A)
SUM  FIELDS=(010,015,ZD,030,009,ZD)                                   
                                                                     
OUTREC FIELDS=(001:C'D',              THIS IS A DETAILED RECORD       
               002:001,002,           
               010:030,009,                   
               019:010,15,ZD,EDIT(TTTTTTTTTTTT.TT),SIGNS=(+,-),LENGTH=15)


And the amout data is (Please ignore the data I posted earlier)

Code:
00000005892206N
00000000001630{
00000000001630{
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 29, 2009 8:12 am    Post subject:
Reply with quote

Hello,

Those numbers show a negative value of 58922065 and 2 positive values of 16300.

There appears to be one too few Ts in the edit mask.

What is the output data or diagnostic info when this is run?
Back to top
View user's profile Send private message
kris_madras
Warnings : 1

New User


Joined: 04 Jul 2005
Posts: 26

PostPosted: Wed Apr 29, 2009 9:12 am    Post subject:
Reply with quote

The equivalent values in the file are:

58922065-
163
163

The output is 58,922,391 instead of -58,921,739
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Apr 29, 2009 9:30 am    Post subject:
Reply with quote

Hello,

Quote:
The equivalent values in the file are:

58922065-
163
163
I believe not - you have ignored the low order zeros in the 2 "163" values. . .
Back to top
View user's profile Send private message
kris_madras
Warnings : 1

New User


Joined: 04 Jul 2005
Posts: 26

PostPosted: Wed Apr 29, 2009 9:50 am    Post subject:
Reply with quote

The INREC is reading this input data as

Code:
58922065-
   16300
   16300


Please suggest me the code to get the correct output in this scenario.
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Convert Decimal to hexadecimal Steve Ironmonger DFSORT/ICETOOL 5 Fri May 27, 2016 4:19 pm
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... polymathtarun JCL & VSAM 3 Sun May 15, 2016 9:57 pm


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