View previous topic :: View next topic
|
Author |
Message |
kris_madras Warnings : 1 New User
Joined: 04 Jul 2005 Posts: 31
|
|
|
|
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
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 |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
kris_madras Warnings : 1 New User
Joined: 04 Jul 2005 Posts: 31
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
kris_madras Warnings : 1 New User
Joined: 04 Jul 2005 Posts: 31
|
|
|
|
The equivalent values in the file are:
58922065-
163
163
The output is 58,922,391 instead of -58,921,739 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
kris_madras Warnings : 1 New User
Joined: 04 Jul 2005 Posts: 31
|
|
|
|
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 |
|
|
|