Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
error handling in Cobol db2 program - subprograms

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: error handling in Cobol db2 program - subprograms
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

Site Director


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

PostPosted: Mon May 25, 2009 10:42 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon May 25, 2009 11:05 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Mon May 25, 2009 12:17 pm    Post subject:
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    Post subject:
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    Post subject:
Reply with quote

hey got it. thanks
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon May 25, 2009 10:26 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Accessing CICS tran with map from JCL... navdeepaggarwal CICS 5 Tue Oct 03, 2017 6:15 pm
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us