I have a field with PIC $9(3)V99 COMP-3 in my file. But it is reported that
in some records the field is having non-numeric values.When I am trying to see the field for those records in CICS region it is abending with ASRA.
Now all I need to do is select the those records from my file.I cant use
the jcl utilities since my files are compressed.I have to code a COBOL program.
First When I used NUMERIC clause check on the field all records selected as Non-numeric.Then I came to know since it is signed packed decimal.Then I moved the field to PIC 9(3)V99 and checked this field.(not signed and not packed).This time all selected as valid Numeric.I am not sure what is happening actually.I believe something I am missing here.Please help.
Moreover I learned that when we move a non-numeric value to a numeric field in a program the job will abend with SOC7.But it is not happening here.
Joined: 03 Oct 2009 Posts: 1790 Location: Bloomington, IL
This thread has information provided by Dr. Sorichetti and, particularly, Sr. Woodger on the subject of S0C7 abends occurring (or not) when working with numeric variables and non-numeric data.
It's been nigh unto twenty years since I've written any COBOL, so I won't try to provide code; however, I recommend that you eschew NUMERIC and edit the raw data in a PIC X(3) field -- INSPECT and reference modification, IIRC, are the ways to go.
You can test unsigned for numeric. You can test signed for numeric. You can test display/zoned for numeric. You can test COMP-3/packed for numeric. You can test alphanumeric/X for numeric.
There is no need to MOVE anything about. If you do that, you do stand a chance of making something that was non-numeric into a numeric before your NUMERIC test.
IF nicely-named-comp-3-field NOT NUMERIC
nicely-named-comp-3-field-as-an-X wants to be either a redefinition of your field, or, if you can't get at it in a copybook, the group-item that it belongs to, "chopped up" for the DISPLAY using reference modification.
Then SET HEX ON when looking at the sysout from the run of the Cobol program, and paste the first 10 lines here, in the Code tags please.
Please also include your Compile options. Be creative. Copy/paste them into a file to edit with ISPF and TF (Text Flow) them so they don't take up so many lines.
Joined: 14 Jan 2008 Posts: 2504 Location: Atlanta, Georgia, USA
Remember, when you know a signed packed-decimal field does not contain a valid sign (not a "C" or "D"), but instead, it contains an "F" sign, when testing the field to be NUMERIC, it will fail, because the compiler is using an internal table to validate the sign is either "C" or "D". What you need to do is to redefine the field as 9(03)V99 COMP-3 and then the compiler will use the correct translate table. If the redefined field is found to have an "F" sign as well as good numerics, then you're OK.
So, to validate this data, issue a NUMERIC check against the signed packed-decimal field and (if needed) issue a NUMERIC check against the redefined unsigned packed-decimal field. If both tests fail, then your data is invalid packed-decimal.
Is it possible that the same data gets an ASRA in CICS (so, a S0C7), tests for not-NUMERIC in a batch Cobol program and then, when MOVEd to an unsigned DISPLAY numeric field tests for NUMERIC? Yes. It is down to compile options (setting of NUMPROC) and the installation option for NUMCLS and the way that the MOVE operates (unpack and "or immediate" with X'0F').
If you have a field which is signed numeric and which unsigned data is allowed to get into then with NUMPROC(PFD) you will be facing problems.
NUMPROC(NOPFD) allows for that (to my mind horrible) situation. When testing for NUMERIC with NUMPROC(NOPFD) the setting of NUMCLS tells whether to allow C, D or F, or A through F as valid in the sign for a NUMERIC test.
Having placed a value of positive two into W-SIGNED-PACKED
IF W-SIGNED-PACKED NUMERIC
DISPLAY "NUM 1"
MOVE 2 TO W-SIGNED-PACKED-R
IF W-SIGNED-PACKED NUMERIC
DISPLAY "NUM 2"
MOVE +2 TO W-SIGNED-PACKED
IF W-SIGNED-PACKED-R NUMERIC
DISPLAY "NUM 3"
MOVE SPACE TO W-SIGNED-PACKED-RR
MOVE W-SIGNED-PACKED TO W-UNSIGNED-DISPLAY
IF W-UNSIGNED-DISPLAY NUMERIC
DISPLAY "NUM 4"
MOVE W-SIGNED-PACKED TO W-UNSIGNED-PACKED
IF W-UNSIGNED-PACKED NUMERIC
DISPLAY "NUM 5"
With NUMPROC(NOPFD) and NUMCLS(PRIM) produces
With NUMPROC(PFD) produces
MOVEing W-SIGNED-PACKED when it contains space to another signed packed/DISPLAY with NUMPROC(NOPFD) abends, with NUMPROC(PFD) does not, although the destination afterwards is not numeric.
Without knowing your compile options for your CICS and batch programs, we can't say more. But, you're happy...