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

SUM ZONED DECIMAL S9(13)V99 USING INREC


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kris_madras
Warnings : 1

New User


Joined: 04 Jul 2005
Posts: 31

PostPosted: Tue Apr 28, 2009 10:53 pm
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: 2146
Location: At my coffee table

PostPosted: Tue Apr 28, 2009 11:08 pm
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

Moderator Emeritus


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

PostPosted: Wed Apr 29, 2009 12:57 am
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: 31

PostPosted: Wed Apr 29, 2009 8:01 am
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

Moderator Emeritus


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

PostPosted: Wed Apr 29, 2009 8:12 am
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: 31

PostPosted: Wed Apr 29, 2009 9:12 am
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

Moderator Emeritus


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

PostPosted: Wed Apr 29, 2009 9:30 am
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: 31

PostPosted: Wed Apr 29, 2009 9:50 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Select a DB2 value in a specific deci... DB2 4
No new posts String has hex character need to conv... COBOL Programming 3
No new posts How to display the leading zeros of a... DB2 7
Search our Forums:

Back to Top