View previous topic :: View next topic
|
Author |
Message |
sourav_dasgupta
New User
Joined: 26 Dec 2007 Posts: 18 Location: Chennai, India
|
|
|
|
Hi all,
I am facing an issue and in need of your help to solve it.
Code: |
05 WS-AMOUNT-CHAR PIC X(20).
05 WS-AMOUNT-DEC REDEFINES WS-AMOUNT-CHAR
PIC -9(16).99.
05 WS-AMOUNT-SIGNED PIC S9(16)V99.
MOVE WS-AMOUNT-DEC TO WS-AMOUNT-SIGNED
|
The issue I am facing is some times with production data WS-AMOUNT-CHAR is holding soe junk value like '**********'. In that case the MOVE statement fails with S0C7 abend.
My intention is to execute the MOVE if the WS-AMOUNT-DEC field is holding valid value. other wise I will move Zeroes to WS-AMOUNT-SIGNED.
I tried with is numeric on both WS-AMOUNT-DEC and WS-AMOUNT-CHAR but both returns false even if it holds some valid value like 0.00.
Please help
TIA
Sourav |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You should be able to say
Code: |
IF WS-AMOUNT-DEC NUMERIC
MOVE WS-AMOUNT-DEC TO WS-AMOUNT-SIGNED
ELSE
MOVE ZERO TO WS-AMOUNT-SIGNED
END-IF.
|
If this isn't working, add a display of WS-AMOUNT-DEC and post the output from a few lines. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
WS-AMOUNT-DEC is actually an x-type field. (edit mask).
would suggest a
Code: |
COMPUTE WS-AMOUNT-SIGNED
= FUNCTION NUMVAL(WS-AMOUNT-DEC)
END-COMPUTE
|
(You may need to change the syntax for the NUMVAL depending on your compiler) |
|
Back to top |
|
|
sourav_dasgupta
New User
Joined: 26 Dec 2007 Posts: 18 Location: Chennai, India
|
|
|
|
Robert,
If I do
Code: |
IF WS-AMOUNT-DEC NUMERIC
MOVE WS-AMOUNT-DEC TO WS-AMOUNT-SIGNED
ELSE
MOVE ZERO TO WS-AMOUNT-SIGNED
END-IF.
|
then the problem I am facing is, it is returning false even if WS-AMOUNT-DEC is containing 123.00
so in WS-AMOUNT-SIGNED zeroes are being moved.
I have added display as you said and checked in Xped.
While googling for this i found this
IBM-PK26004
But there is no solution or work around given.
The same is happening for me for a -9(16).99 field which is a signed edited numeric.
Thanks
Sourav |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
When I look at PK26004, I see:
Quote: |
This problem has been resolved with WebSphere Developer for
zSeries V6.0.1 Interim Fix 004 which will be available from
the Rational Product Updater or WDz product web download page:
|
which sounds like a fix to me -- resolved means fixed. Perhaps you should contact your site support group and have them apply this fix?
And why wouldn't WS-AMOUNT-DEC contain 0000000000000123.00? If it contains a batch of spaces and 123.00, then the field is not numeric and will fail the test no matter whether or not the PK26004 fix is applied.
You might want to use FUNCTION NUMVAL if you can have spaces in your value. |
|
Back to top |
|
|
sourav_dasgupta
New User
Joined: 26 Dec 2007 Posts: 18 Location: Chennai, India
|
|
|
|
Dick,
If I use NUMVAL then if an junk value comes WS-AMOUNT-DEC then I think it will abend.
As WS-AMOUNT-DEC is a redefine of WS-AMOUNT-CHAR and WS-AMOUNT-CHAR can hold alphanumeric also, it is quite possible.
Have not tested though. I may be wrong too.
In normal scenario I am expecting one amount value in this field but in some one off scenarion i an getting junk values like '***********' also, which is alphanumeric.
Thanks
Sourav |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Run a loop across WS-AMOUNT-CHAR checking each character (via reference modification) to be space, +, -, a digit, or a decimal point. If you have anything else, put out an error message and don't use WS-AMOUNT-DEC. Otherwise, you can use FUNCTION NUMVAL to convert the value to a valid numeric and use it. |
|
Back to top |
|
|
sourav_dasgupta
New User
Joined: 26 Dec 2007 Posts: 18 Location: Chennai, India
|
|
|
|
Robert,
Even if WS-AMOUNT-DEC contains 0000000000000123.23 (without any space, leading/trailing), then also the numeric check fails and returns false in my case. Maybe I need the site support team to apply the fix.
Thanks
Sourav |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
From the COBOL Language Reference manual (link at the top of the page):
Quote: |
NUMERIC
identifier-1 consists entirely of the characters 0 through 9, with or without an operational sign. |
so having the period in the value makes it not numeric by definition. You can either redefine as two fields before and after the decimal point and check each separately, or use reference modification to check each byte one at a time. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
You can redef WS-AMOUNT-CHAR as WAC-SIGN, WAC-DIGITS,
WAC-DEC-PT and WAC-CENTS.
Then: (untested code)
Code: |
IF WAC-SIGN NOT = (' ' AND '-') (not sure about this compound)
OR
WAC-DIGITS NOT NUMERIC
OR
WAC-DEC-PT NOT = '.'
OR
WAC-CENTS NOT NUMERIC
MOVE ' 0000000000000000.00' TO WS-AMOUNT-SIGNED
(or whatever)
ELSE
MOVE WS-AMOUNT-DEC TO WS-AMOUNT-SIGNED
END-IF |
|
|
Back to top |
|
|
|