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

How to capture data exception abend?


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

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Thu Nov 01, 2012 6:25 pm
Reply with quote

In my program, i have below statment:
Code:
COMPUTE WK-TMP-NUM        =     FUNCTION NUMVAL(WK-NUM)
END-COMPUTE                                                 


and if illegal character exists in WK-NUM, program abended with data exception.

But what if I want to caputure this abend?

I mean, when error occurs when execute 'FUNCTION NUMVAL', I want to save some error message, like ' data exception occurred, please check the input data' into DB2 table, how can I do it?
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Nov 01, 2012 6:43 pm
Reply with quote

Hi dejunzhu,

You mean illegal characters are nothing but non-numeric data?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Nov 01, 2012 6:59 pm
Reply with quote

what about doing a bit of research and manual reading Yourself

a simple google with cobol abend handling
( not too complicated I guess )

returned quite a few useful links

here is a cut and paste of the first page
Quote:
[PDF]
ibm Exploit Condition Handling in LE
www-01.ibm.com/support/docview.wss?uid=swg27016953&aid...File Format: PDF/Adobe Acrobat - Quick View
In this case, want to use RESUME using LE features rather than ABEND. – Want to write the code to handle errors in COBOL, not assembler. • Could also use ...
Abend handling
publib.boulder.ibm.com/infocenter/.../com.../t_hndlng_abend.htmlAbend handling. About this task. A program-level abend exit facility is provided in CICS® so that you can write exits of your own that can be given control during ...
Using Language Environment Abend-handling
publib.boulder.ibm.com/infocenter/cicsts/v2r3/.../dfhp3pr.htmIf TRAP(OFF) is specified, no error handling takes place; the abend proceeds. ... condition handler (other than in COBOL), you can use most CICS commands, ...
[PDF]
Got COBOL? Bet you didn't know you could do THIS in COBOL
proceedings.share.org/client_files/SHARE.../S8237TR124124.pdfFile Format: PDF/Adobe Acrobat - Quick View
Retrieving information about an ABEND with COBOL. – XML GENERATE ... Add condition handling to your application with no programming changes to the ...


odd that with such many results You felt the need to ask rather than purus the issue Yourself

the first link has also a code example
www-01.ibm.com/support/docview.wss?uid=swg27016953&aid=1
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 01, 2012 7:07 pm
Reply with quote

What you think you want to do isn't necessarily the best thing.

Can you show a representative sample of your data you are sending to NUMVAL? NUMVAL, as you've noticed, blows up with bad data, but you can check for bad data before calling, then you don't need to get into the "LE Abend Handler" and all that goes with that.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Nov 01, 2012 9:04 pm
Reply with quote

Hello,

Quote:
and if illegal character exists in WK-NUM,
Correct the code that generates this value. . .

It should never be invalid when being used.

If there is no control over the creating code, make a decision on what should happen when the value is invalid (change to zero, terminate the process with an error, etc).
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Fri Nov 02, 2012 2:28 pm
Reply with quote

I tried to verify every byte of the input of 'FUNCTION NUMVAL(WK-NUM)', but since there might be sign character, which might be '+' or '-' contained in the front or in the end of the field, when I verify the field with 'IF WK-NUM IS NUMERIC', and if '+' or '-' exists in the field, WK-NUM will never be recognized as NUMERIC.

so, I want to perform FUNCTION NUMVAL directly without any pre-verification.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Nov 02, 2012 2:40 pm
Reply with quote

Quote:
... without any pre-verification.


by doing anything without any [pre]verification
You will deserve all misfortunes in which You might incur icon_cool.gif

( and not only in the IT world )
if You had to go for a deep sea immersion would You check if the air cylinders are at full pressure ???
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Nov 02, 2012 6:54 pm
Reply with quote

Hello,

Quote:
so, I want to perform FUNCTION NUMVAL directly without any pre-verification.
Utter nonsense . . . icon_evil.gif

You MUST use the system as it is designed and working, NOT as you would prefer it woked.

How in the world could "numval" be coded to handle everyone's perception of what is "valid"?

NUMVAL is excellent for data that is guaranteed (i.e. generated by code that Always works). For data from an unknown or questionable source, it must be completely validated before any use as a number.

Keep in mind that there are a few billion lines of code that address the very issue of validating numeric fields. Compared to all of the code ever written, NUMVAL is a rather new feature and is Not for every occasion.
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 02, 2012 7:03 pm
Reply with quote

On top of that, the validation you seem to need from the little you have described is enormously simple.

To my mind it would be plain nuts, and much slower in terms of processing, and much more difficult to plan, and ever more difficult to maintain as you do it more often, to use this to trap abends from NUMVAL.

If you do not have leading space, use FUNCTION REVERSE to put it into a new field of the same size, then INSPECT to replace the by-now leading spaces. Use INSPECT to change one -/+ to zero, and ONE "." to zero. Test this field for being numeric. If so, use NUMVAL, else log it as an error.

In fact, your data, as you describe it, is so simple, you've no need of NUMVAL, but that is another story.
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 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 ISAM and abend S03B JCL & VSAM 10
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top