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

Error Handling in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kishpra

New User


Joined: 24 May 2010
Posts: 92
Location: Pune

PostPosted: Wed Mar 02, 2011 6:19 pm
Reply with quote

I want to incorporate the below conditions in my REXX program -

1) I am preparing the skeleton jcl using some files as below -

"ISPEXEC LIBDEF ISPSLIB DATASET ID('ITA.REXX.TEMP.F')"
"ISPEXEC LIBDEF ISPFILE DATASET ID('TEST.TEMPNEW')"

"ALLOC DA('TEST.TEMPGHI') F(INPUT) SHR REUSE"
"EXECIO * DISKR INPUT (STEM LINES. FINIS)"

I want to check whether file 'TEST.TEMPGHI' is present or not .Also if present ,want to check whether it is blank before procedding further.


2) Also when reading in the below loop -

DO I = 1 TO LINES.0
PARSE VAR LINES.I VAR1 VAR2

I want to check whether VAR2 is blank or not


In both above cases,what is the appropriate error handling method.


Thanks!
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Mar 02, 2011 6:50 pm
Reply with quote

This is REALLY basic stuff ... anyway ...

kishpra wrote:

I want to check whether file 'TEST.TEMPGHI' is present or not .


LISTDSI ought to work.

kishpra wrote:

Also if present ,want to check whether it is blank before procedding further.


I'm not sure what you mean by "blank", but if you read the dataset as you showed:

"EXECIO * DISKR INPUT (STEM LINES. FINIS)"

then you can interrogate the value of LINES.0 for the number of records read.

kishpra wrote:

I want to check whether VAR2 is blank or not


A LENGTH check should work.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Mar 02, 2011 7:11 pm
Reply with quote

SYSDSN will also work for checking on the existance of a file.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 92
Location: Pune

PostPosted: Thu Mar 03, 2011 6:05 pm
Reply with quote

Thanks for the reply.


If i am submitting a REXX program using JCL ,if by using LISTDSI I get the return code as 16 i.e. file is not available.It should give some JCL error with some return code.

How to process that ?


Thanks!
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Mar 03, 2011 6:15 pm
Reply with quote

JCL ERROR and a non zero return code are two completely different animals.

Which do you require ?

Terminology is oh so important in the IT world. Please take the time to learn it.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 92
Location: Pune

PostPosted: Thu Mar 03, 2011 6:16 pm
Reply with quote

If my LISTDSI retun code is non-zero in the REXX program,i want the JCL to fail with some return code.



Thanks!
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Mar 03, 2011 6:21 pm
Reply with quote

Please read my previous comment again, and again, and again until you understand it thoroughly. Let's face it, if YOU don't know what you are on about, how are we supposed to icon_rolleyes.gif
If the JCL fails, then a JCL ERROR will occur, if a non zero return code is issued then the JCL will be deemed to have be successful.

May I suggest that you read the REXX / TSO manuals for the EXIT statement.
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 92
Location: Pune

PostPosted: Thu Mar 03, 2011 6:24 pm
Reply with quote

Apologies!


Failing of JCL with return code means the JCL error.So that means If

LISTDSI issues return code as 16,JCL should fail with some JCL error.




Thnaks!
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Mar 03, 2011 6:29 pm
Reply with quote

If you put a DD for dataset ITA.REXX.TEMP.F in your JCL then you will get a JCL error and the step will never get executed.

You would not need the listdsi in your rexx program.

Just an alternative.

Ignore me if you will.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Mar 03, 2011 7:07 pm
Reply with quote

I said:
Quote:
If you put a DD for dataset ITA.REXX.TEMP.F in your JCL then you will get a JCL error and the step will never get executed.



I meant dataset: 'TEST.TEMPGHI'
If this dataset does not exist, the JCL get a JCL error (that is what you want correct?).

I think JCL errors are never a good idea however.

On a side note: Everyone here is helping with your syntax without regard to the soundness of your design.

I think you would benifit from giving the 'big picture' of what you are trying to accomplish.

There are many years of experience here that would help you in that regard.

Ignore me if you will.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Mar 03, 2011 7:24 pm
Reply with quote

Dave,

I believe that the OP wants to issue a non zero RC if the dataset specified does not exist. Based on the RC issued by this step the OP can determine what actions to take in the remainder of the job.

Unfortunately to me, this is just another case of the OP NOT understanding the correct terminology.

From my view, the OP understands that a non zero RC is a JCL ERROR or failure, which we both know is not the case.

I did try to educate the OP ................ but until the OP understands and uses the correct terminology then both the OP and responders are probably wasting their time icon_cry.gif
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 92
Location: Pune

PostPosted: Mon Mar 07, 2011 10:20 am
Reply with quote

Thanks for the reply.


I have many a things to check for 'TEST.TEMPGHI' dataset as below -

1) Existence of the file.As the file is coming from different system as an input to REXX program and so not specified in the jcl.

Expected Result - if the above file is not present,JCL should fail with JCL error

2) I have to check if that file is blank or not.

Expected Result - JCL should fail with JCL error and write something in the spool

3) Need to check whether the account number is valid or not.If invalid JCL should fail with JCL error.


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 Mar 07, 2011 10:47 am
Reply with quote

Hello,

How did you get so hung up on "jcl error". . . icon_confused.gif

It makes no sense to try to force a jcl error when some incorrect condition is encouneterd. . .

1 - when the file does not exist, write a message to the spool and terminate with some return code or force an abend.
2 - when the file does is empty, write a message to the spool and terminate with some return code or force an abend (possibly the same as for 1).
3 - when the file contains an invalid account number, write a message to the spool and terminate with some return code or force an abend (probably not the same as 1 or 2).
Back to top
View user's profile Send private message
kishpra

New User


Joined: 24 May 2010
Posts: 92
Location: Pune

PostPosted: Mon Mar 07, 2011 11:08 am
Reply with quote

Thanks Dick,


I need the same thing as you suggested.In all the cases,I am writing error message to the spool.But I don't know,how to terminate with some return code in REXX.



Appreciate your help!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Mar 07, 2011 11:46 am
Reply with quote

what about reading the manual about the RETURN and EXIT statements
and IKJEFT01 IKJEFT1B difference
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/Shelves/IKJ4BK90
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Mar 07, 2011 4:31 pm
Reply with quote

expat wrote:
May I suggest that you read the REXX / TSO manuals for the EXIT statement.
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 Mar 07, 2011 8:08 pm
Reply with quote

Hello,

In addition to reading the manual, you might also search in this Clict & REXX part of the forum. I believe there are previous topics that will help.
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
Search our Forums:

Back to Top