Q
Problem solve Get help with specific problems with your technologies, process and projects.

Testing for numeric data

05 WS-BANDC-CHECK    PIC 9(02).
    88 VALID-BC                         
    VALUE  00 THROUGH 99.  

I'm checking this field in a CICS program for valid numeric values 00-99. When I test on the CICS screen, '&&' inputed gives me the correct error message. However '!!' and other characters causes the ASRA system abend.

How do I code this so I can stop getting the ASRA system abend?
It isn't clear from your description of the problem you've encountered what COBOL statements you are using to test for numeric data in the WS-BANDC-CHECK field. The COBOL compiler assumes that values for a data item are valid for the item's PICTURE and USAGE clause and assigns the value you supply without checking for validity. If a data item has a value that is incompatible with its data description, references to that item in the PROCEDURE DIVISION will be undefined and your results will be unpredictable.

For values passed to your program as input data, as in this case, that may be incompatible with the data descriptions for the field to which they are moved. You can ask COBOL to check the validity of the field contents for numeric values by performing a numeric case test. You should ensure that the contents of a data item conforms to its PICTURE and USAGE clauses before using the data item in any further processing steps.

To perform a numeric case test in this case issue:

          IF WS-BANDC-CHECK IS NUMERIC THEN  next sentence

The "next sentence" will only be executed if the condition is true, i.e., the contents of WS-BANDC-CHECK are, in fact, valid numeric characters.

Editor's note: Do you agree with this expert's response? If you have more to share, post it in one of our .VO7aaqqaAFk.0@/search390>discussion forums.


 

Dig Deeper on IBM system z and mainframe systems

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

SearchServerVirtualization

SearchCloudComputing

Close