Hi All,
I have a report file as a input where the amount field has been defined as numeric edited field in the format given below.
I want to read that amount for every record from the input file and do summation.
The picture clause defined for amount field is --------------9.99
I have redefined this field using the below format.
01 Ws-original-amt pic --------------9.99.
01 Ws-field REDEFINES Ws-original-amt.
05 ws-first-value pic S9(15).
05 filler pic x.
05 ws-last-value pic 99.
I am able to read the positive amount using redefine clause but having issues with reading the negative amount. The negative sign is considered as space and I am not able to identify the negative amount.
For example if I have the amount as -15.00 in the input report file then I can see the same amount in display before doing summation using the redefined field (ws-first-value) but the instead of reducing the total it gets increased by 15.
Please let me know if anybody have solution for this.
Regards,
Shrishant
Numeric edited field issue
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: Numeric edited field issue
What I don't understand is why you don't just use since 6.2.24.1.1 of the COBOL Language Reference manual on the MOVE statement explicitly states
Code: Select all
MOVE WS-ORIGINAL-AMT TO <numeric-variable>
Due to the size of WS-ORIGINAL-AMT you might have to use ARITH(EXTEND) compiler option, but that's no big deal.When the sending item is numeric-edited, the compiler de-edits the sending data to establish the unedited value of the numeric-edited item (this value can be signed). The unedited numeric value is used in the move to the receiving numeric or numeric-edited data item.
Re: Numeric edited field issue
Thanks for your reply.
I have tried using the numeric variable but when the value of sending data is negative then the negative sign is not considered and the final total after calculation gets added by 15 instead of reducing by 15.
See the display below.
WS-TEST-AGAIN : -1E
SH-B4-CAL-TOT-LN-BAL :0000000012562253E
SH-AT-CAL-TOT-LN-BAL :0000000012562403E
The picture clause of WS-TEST-AGAIN is PIC S9(15) and i have ket the display before compute statement and after compute statement.
The final total is increased by 15.
I have tried to move the numeric edited value into 9(15) as well and that didnt give me the correct total as well. The issue is same as above.
Please let me know if you have any option to resolve this.
Thanks in advance.
Regards,
Shri
I have tried using the numeric variable but when the value of sending data is negative then the negative sign is not considered and the final total after calculation gets added by 15 instead of reducing by 15.
See the display below.
WS-TEST-AGAIN : -1E
SH-B4-CAL-TOT-LN-BAL :0000000012562253E
SH-AT-CAL-TOT-LN-BAL :0000000012562403E
The picture clause of WS-TEST-AGAIN is PIC S9(15) and i have ket the display before compute statement and after compute statement.
The final total is increased by 15.
I have tried to move the numeric edited value into 9(15) as well and that didnt give me the correct total as well. The issue is same as above.
Please let me know if you have any option to resolve this.
Thanks in advance.
Regards,
Shri
-
- Global moderator
- Posts: 3805
- Joined: Tue Jan 25, 2011 12:02 am
- Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
- Referer: Google
Re: Numeric edited field issue
"-1E" is not a valid numeric-edited value.
"-15" would be valid.
"1E" in a PIC S99 is +15, but is not a valid numeric-edited value.
Maybe you can show your definitions and code if you want assistance in making sense of it.
"-15" would be valid.
"1E" in a PIC S99 is +15, but is not a valid numeric-edited value.
Maybe you can show your definitions and code if you want assistance in making sense of it.
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: Numeric edited field issue
Code: Select all
05 WS-ORIGINAL-AMT PIC --------------9.99.
05 WS-NUMERIC-AMT PIC S9(15)V99.
05 WS-NUMVAL-AMT PIC S9(15)V99.
PROCEDURE DIVISION .
0000-START.
MOVE -12345.67 TO WS-ORIGINAL-AMT.
MOVE WS-ORIGINAL-AMT TO WS-NUMERIC-AMT.
COMPUTE WS-NUMVAL-AMT = FUNCTION NUMVAL (WS-ORIGINAL-AMT).
DISPLAY 'WS-ORIGINAL-AMT <' WS-ORIGINAL-AMT '>'.
DISPLAY 'WS-NUMERIC-AMT <' WS-NUMERIC-AMT '>'.
DISPLAY 'WS-NUMVAL-AMT <' WS-NUMVAL-AMT '>'.
Code: Select all
WS-ORIGINAL-AMT < -12345.67>
WS-NUMERIC-AMT <0000000000123456P>
WS-NUMVAL-AMT <0000000000123456P>
Re: Numeric edited field issue
Hey Robert, Thanks a lot buddy.
I did the modification in my code as per your explanation and its working great.
I tried using the PIC S9(15)v99 earlier but I got abend with S0C7.
That must been my misunderstanding and that abend must have been caused due to some other issue in code.
Thanks again for your help. This issue is successfully resovled.
Regards,
Shri
I did the modification in my code as per your explanation and its working great.
I tried using the PIC S9(15)v99 earlier but I got abend with S0C7.
That must been my misunderstanding and that abend must have been caused due to some other issue in code.
Thanks again for your help. This issue is successfully resovled.
Regards,
Shri
-
- Similar Topics
- Replies
- Views
- Last post
-
- 1
- 1810
-
by sergeyken
View the latest post
Fri Mar 26, 2021 11:59 pm
-
-
Retain non numeric character in IFTHEN - BUILD
by Shambu » Wed Dec 01, 2021 5:00 pm » in Syncsort/Synctool - 1
- 1981
-
by sergeyken
View the latest post
Sat Dec 04, 2021 2:28 pm
-
-
- 3
- 5123
-
by jrcox
View the latest post
Wed Jul 29, 2020 7:52 pm
-
- 1
- 1349
-
by jcdm
View the latest post
Mon Oct 24, 2022 6:10 pm
-
- 2
- 2283
-
by Terry Heinze
View the latest post
Tue Feb 15, 2022 9:13 pm