View previous topic :: View next topic
|
Author |
Message |
Arunkumar Chandrasekaran
New User
Joined: 01 Jun 2010 Posts: 63 Location: India
|
|
|
|
Hi,
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.
Arun |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 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. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Arunkumar Chandrasekaran wrote: |
I have a field with PIC $9(3)V99 COMP-3 |
Bullshit!
until you come up with a syntactically correct PIC clause
there is little we can do. |
|
Back to top |
|
|
Arunkumar Chandrasekaran
New User
Joined: 01 Jun 2010 Posts: 63 Location: India
|
|
|
|
I have a field with PIC S9(3)V99 COMP-3. Is it fine now?? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
At least it would compile now.
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.
Code: |
IF nicely-named-comp-3-field NOT NUMERIC
DISPLAY nicely-named-comp-3-field-as-an-X
END-IF
|
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. |
|
Back to top |
|
|
Arunkumar Chandrasekaran
New User
Joined: 01 Jun 2010 Posts: 63 Location: India
|
|
|
|
Hi thanks for your reply.actually it is unsigned comp-3 and the issue is because of spaces moved for that field.Now its fine now.Sorry for the confusion and thanks for the help. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 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. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Good point Bill.
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.
Code: |
01 W-UNSIGNED-PACKED COMP-3 PIC 9(3).
01 W-SIGNED-PACKED COMP-3 PIC S9(3).
01 W-SIGNED-PACKED-R
REDEFINES W-SIGNED-PACKED COMP-3 PIC 9(3).
01 W-SIGNED-PACKED-RR
REDEFINES W-SIGNED-PACKED PIC XX.
01 W-UNSIGNED-DISPLAY PIC 999.
|
Having placed a value of positive two into W-SIGNED-PACKED
Code: |
IF W-SIGNED-PACKED NUMERIC
DISPLAY "NUM 1"
END-IF
MOVE 2 TO W-SIGNED-PACKED-R
IF W-SIGNED-PACKED NUMERIC
DISPLAY "NUM 2"
END-IF
MOVE +2 TO W-SIGNED-PACKED
IF W-SIGNED-PACKED-R NUMERIC
DISPLAY "NUM 3"
END-IF
MOVE SPACE TO W-SIGNED-PACKED-RR
MOVE W-SIGNED-PACKED TO W-UNSIGNED-DISPLAY
IF W-UNSIGNED-DISPLAY NUMERIC
DISPLAY "NUM 4"
END-IF
MOVE W-SIGNED-PACKED TO W-UNSIGNED-PACKED
IF W-UNSIGNED-PACKED NUMERIC
DISPLAY "NUM 5"
END-IF
|
With NUMPROC(NOPFD) and NUMCLS(PRIM) produces
Code: |
NUM 1
NUM 2
NUM 4
NUM 5
|
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... |
|
Back to top |
|
|
|