IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to check the Non-numeric data in PIC $9(3)V99 COMP-3


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Arunkumar Chandrasekaran

New User


Joined: 01 Jun 2010
Posts: 63
Location: India

PostPosted: Fri Nov 09, 2012 2:59 am
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Nov 09, 2012 3:19 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Nov 09, 2012 4:14 am
Reply with quote

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
View user's profile Send private message
Arunkumar Chandrasekaran

New User


Joined: 01 Jun 2010
Posts: 63
Location: India

PostPosted: Fri Nov 09, 2012 4:41 am
Reply with quote

I have a field with PIC S9(3)V99 COMP-3. Is it fine now??
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Nov 09, 2012 4:55 am
Reply with quote

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
View user's profile Send private message
Arunkumar Chandrasekaran

New User


Joined: 01 Jun 2010
Posts: 63
Location: India

PostPosted: Thu Nov 22, 2012 1:16 am
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Nov 22, 2012 3:37 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Nov 22, 2012 6:28 am
Reply with quote

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

Code:
NUM 1
NUM 4
NUM 5


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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Store the data for fixed length COBOL Programming 1
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top