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

error handling in Cobol db2 program - subprograms


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

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon May 25, 2009 10:27 am
Reply with quote

hi
my requirement is as follows -
to read a file, read input record.
if there is an error, for example the date is not valid. then no further processing, it will call a second program and there a report will be generated with the reason as 'invalid date'.

i am planning to send reason code to second program there it will be decoded to the text and written to the report.

there are two ways of doing this - one is file - with all types of reason code and reason text. another way is by using a table, with reason code and reason text.

but here I am not able to figure out how it can be done. and which one will be more easier to write.

please suggest.

thanks
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: Mon May 25, 2009 10:42 am
Reply with quote

Hello,

Is the plan to have a common error reporting module?

As you mention, you will have a table or array with all of the supported reasons and the error text that go with them. If the common error reporting module receives the error reason as input from some calling program, the error text can be retrieved using the error reason code.

If the table is hard-coded in the common module, there will be very frequent changes to the module as new errors are added. If the values are stored in an external file (ps, pds/mbr, vsam file, or database table), the error reporting information can be maintained without requiring program modifications.

Some coding choices are to look up the reason and get the message from within the code/array or to use the reason to return message value from an external source. You might also consider loading the array into the common code's ws for use.

If it were my requirement, i'd look for a way to maintain the table externally pretty much eliminating code changes to the callers and the common error module.
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon May 25, 2009 10:54 am
Reply with quote

You are right plan is to have a common error reporting module.

my question is see for example - in the first record in input file i found the date is invalid.

how do i know the reason code.... is 01.

shall i write in working storage with all possible error mesages and reason code in first pgm. then in linkage section i wil pass 01 to second pgm.

in second pgm to decode this reason code i will check in external table and write the corresponding text msg in report.

how wil be the design you suggest.
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: Mon May 25, 2009 11:05 am
Reply with quote

Hello,

I suggest that you begin with the list of error codes and the reason text. This (however it is maintained) will be used by the common called module to report the error. In the beginning, this will grow quite quickly.

When code is running and something fails validation, pass the field name, the problem data value (make sure these are pic x when passing them to the error routine), and the failure reason code (and possibly more info depending on how elegant this common error reporting module is to be).
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon May 25, 2009 11:50 am
Reply with quote

hey Dick

sorry i am not getting.

could you please elaborate a little what you mean or give an example how i will write in code. or give one example pseudocode to implement this.
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: Mon May 25, 2009 12:17 pm
Reply with quote

Hello,

First, create the initial list of problem situations. This will be the reason there is a problem. Next, assign an error code to each item in the list (i.e. A01, A02, A03, etc) whatever convention you create.

Let's say the first entry in this list is to deal with an invalid input date. Let's also say that the error code for an invalid date is A01.

In an application module, when an invalid date is detected, i'd call the common error module and pass the A01, the problem field name, and the problem value (as pic x data) to the common error module.

The common error module would do whatever error reporting has been designed and append the error text from the table you've defined.
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon May 25, 2009 12:36 pm
Reply with quote

you mean i will have a file or working-storage declaration with all possible errorcodes and text in first pgm. and there will be a table with same structure which will be external and will be fetched in 2nd pgm.

is it correct.
Back to top
View user's profile Send private message
sm_2009

New User


Joined: 10 May 2009
Posts: 72
Location: bangalore

PostPosted: Mon May 25, 2009 2:30 pm
Reply with quote

hey got it. thanks
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: Mon May 25, 2009 10:26 pm
Reply with quote

Hello,

Quote:

you mean i will have a file or working-storage declaration with all possible errorcodes and text in first pgm.
No, the table would not be in the first program - that would require the table be in every program which is what you are trying to avoid.

Quote:
and there will be a table with same structure which will be external and will be fetched in 2nd pgm.
The info could be in the called module as a constant array (not my preference), it could be an array that is loaded when needed (also, not my preference), of the value could be retrieved directly from a vsam file or database table. My preference would be a database table that would be maintained eliminating lots of code changes and compiles and promotions. . .
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts Error to read log with rexx CLIST & REXX 11
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Error when install DB2 DB2 2
Search our Forums:

Back to Top