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

Multiple branching using Signal


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rajesh-amigos
Currently Banned

New User


Joined: 03 Aug 2007
Posts: 25
Location: India

PostPosted: Tue Aug 14, 2007 4:49 pm
Reply with quote

I am using LISTDS and EDIT macro in my Rexx Exec.
I want to code it in such a fashion that if the RC from LISTDS is not 0 certain statments(Error_Handler) should be executed, and if RC from EDIT is not 0 certain other statments(Open_Error) should be executed.

Can somebody tell me how to achieve this using Signal?
Below is my code:-

000190 Signal on error name Error_Handler
000200 Signal on failure name Error_Handler
000210
000300 Address tso
000400 Say "Please enter the PDS you want us to traverse"
000500 Pull var1
000510 /*Say "The macro you want to use on the members"
000520 Pull Var2*/
000530
000540 If var1 = "" Then
000541 Do
000550 Say "No PDS name was entered"
000560 Exit
000570 End
000580
000600 var3 = "'"var1"'"
000700 Listc=0
000801
000810 DSINFO=LISTDSI(var3 DIRECTORY)
000812
000814 If SYSDSORG = 'PO' Then Do
000900 X=Outtrap(Listc.)
001000 "LISTDS '"var1"' MEMBERS "
001100 X=Outtrap("OFF")
001112
001120 Do I=1 to 3
001130 say listc.i
001140 End
001200 Say "There are " ((Listc.0)-6)" members in the PDS"
001300
001400 "ISPEXEC LMINIT DATAID(datain) DATASET('"var1"')"
001500 Say "Members Returncode"
001510 varcount = 0
001600 Do I=8 to listc.0
001700 Listc.i = STRIP(Listc.i)
001800 Address ISPEXEC "EDIT DATASET('"var1"("listc.i")')
001801 MACRO ("packoff")"
001810 Say listc.i RC
001820 Signal on Error name Open_Error
001830 Signal on Error name Open_Error
001840 End
001890 End
001891 Else
001892 Do
001893 Say "This file is not a PDS"
001894 Say "However we will still try to process the file"
001895 Address ISPEXEC "EDIT DATASET('"var1"')
001896 MACRO ("packoff")"
001897 End
001898
001899 Error_Handler :
001900 If SYSREASON <> 0 Then DO
001901 Say "SYSREASON =" SYSREASON
002000 Select
002100 When SYSREASON == 3 then
002200 Say "Dataset is a type that cannot be processed"
002300 When SYSREASON = 5 then
002400 Say "Dataset not Cataloged Moron"
002500 When SYSREASON == 8 then
002600 Say "Dataset is not on a DASD"
002700 When SYSREASON == 9 then
002800 Say "DFHSM migrated the Dataset. NORECALL prevents retrieval"
002900 When SYSREASON == 11 then
003000 Say "You haven't got sufficient authority for this operation"
003100 When SYSREASON == 12 then
003200 Say "Cannot process VSAM"
003300 Otherwise
003400 End
003500 Exit
003600 End
003700
003800 Open_Error :
003900 Say "There were some errors"
004000 Say "The report has been written to the file"


Also Please let me know if there is anyway to optimise this code. I am new to Rexx, and am learning without books, directly by coding.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Tue Aug 14, 2007 6:27 pm
Reply with quote

You need to trap the RC from the commands

Code:

XYZ = DSINFO=LISTDSI(var3 DIRECTORY)
IF XYZ > 0 THEN DO
  SAY "RC = "XYZ  "SYSREASON = "SYSREASON
END
Back to top
View user's profile Send private message
rajesh-amigos
Currently Banned

New User


Joined: 03 Aug 2007
Posts: 25
Location: India

PostPosted: Tue Aug 14, 2007 8:36 pm
Reply with quote

Hi Expat,

Thanks a lot for the suggestion!!!
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Tue Aug 14, 2007 9:19 pm
Reply with quote

I'm curious: Why aren't you learning from books? icon_eek.gif

O.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Wed Aug 15, 2007 4:08 am
Reply with quote

ofer71 wrote:
I'm curious: Why aren't you learning from books? icon_eek.gif

O.


Hey Ofer, where did you think I got that from icon_eek.gif icon_biggrin.gif icon_confused.gif
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Wed Aug 15, 2007 10:49 am
Reply with quote

Sorry, the question was directed to the o/p. This is a quote from the o/p:
Quote:
I am new to Rexx, and am learning without books, directly by coding


O.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Wed Aug 15, 2007 1:09 pm
Reply with quote

There is a link in the CLIST / REXX forum that goes to the IBM manuals,
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Aug 15, 2007 1:26 pm
Reply with quote

rajesh-amigos,

if you have a pc at home, suggest you visit rexxinfo which was created by Howard Fosdick. He has collected links for a variety of things:
  • Free REXX interpreters for the pc
  • tutorials
  • manuals
  • articles
  • rexx implementation info for nearly any and all platforms - pc and mainframe (tso, cics, etc...)
  • rexx forums


If you are interested in becoming a proficient REXXer, I would suggest visiting his site.
Back to top
View user's profile Send private message
rajesh-amigos
Currently Banned

New User


Joined: 03 Aug 2007
Posts: 25
Location: India

PostPosted: Thu Aug 16, 2007 8:02 pm
Reply with quote

/*REXX */
/*****************************************************
/* This code browses through the PDS given by the user
/* each member in edit mode. The EXEC then runs a ISRE
/* on each of them. The EXEC also writes a report in t
/* errors encountered along with the RC.
/*
/*****************************************************
Trace all
Signal on error name Error_Handler
Signal on failure name Error_Handler

Address tso
Say "Please enter the PDS you want us to traverse"
Pull var1
/*Say "The macro you want to use on the members"
Pull Var2*/
Pull Var2*/

If var1 = "" Then
Do
Say "No PDS name was entered"
Exit
End

var3 = "'"var1"'"
Listc=0
/*"alloc dataset('"var1"') f(datain)shr reuse"*/

/*X=Outtrap(Listc.)*/
DSINFO=LISTDSI(var3 DIRECTORY)
/*X=Outtrap("OFF")*/

Say SYSDSORG
If SYSDSORG = 'PO' Then Do
X=Outtrap(Listc.)
"LISTDS '"var1"' MEMBERS "
X=Outtrap("OFF")

Do I=1 to 3
say listc.i
End
Say "There are " ((Listc.0)-6)" members in the PDS"

"ISPEXEC LMINIT DATAID(datain) DATASET('"var1"')"
Say "Members Returncode"
varcount = 0
Do I=8 to listc.0
Listc.i = STRIP(Listc.i)
Address ISPEXEC "EDIT DATASET('"var1"("listc.i")')
MACRO ("packoff")"
RC_Open = RC
Say listc.i RC
End
End
Else
Do
Say "This file is not a PDS"
Say "However we will still try to process the file"
Address ISPEXEC "EDIT DATASET('"var1"')
MACRO ("packoff")"
End

Error_Handler :
/*If SYSREASON <> 0 Then DO
Say "SYSREASON =" SYSREASON
Select
When SYSREASON == 3 then
Say "Dataset is a type that cannot be processed"
When SYSREASON = 5 then
Say "Dataset not Cataloged Moron"
When SYSREASON == 8 then
Say "Dataset is not on a DASD"
When SYSREASON == 9 then
Say "DFHSM migrated the Dataset. NORECALL prevents retrieval"
When SYSREASON == 11 then
Say "You haven't got sufficient authority for this operation"
When SYSREASON == 12 then
Say "Cannot process VSAM"
Otherwise
End
Exit*/

If RC_OPEN = 14
Say "There were some errors"
Say "The report has been written to the file"
Say Listc.i
End


My Queston is if the Sysreason from LISTDSI is not 0, Then the Control does move to Error_Handler :.

However when the Return code from EDIT DATASET is non zero, the control doesnt move to Error_Handler, instead I get a Screen named ISPF ISRE093, which says "Member in Use". When Runing the code in Trace mode, I found out that the controld goes to ISPF as soon as the code for Editing the open member is encountered.

How can I supress the screen and deliver the message from my own code?
_________________
Regards,
Rajesh
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Thu Aug 16, 2007 8:44 pm
Reply with quote

I'm not all that familiar with the SIGNAL ON and CALL ON functions, so I had to read up on them a bit. From what I read, they are invoked when a COMMAND fails. Apparently, LISTDSI is not considered to be a command, so it won't cause a SIGNAL ON or CALL ON to fire.

I'd rewrite your exec like this:

Code:

/* REXX */                                                         
Say "Please enter the PDS you want us to traverse"                 
Pull var1                                                           
If var1 = "" Then                                                   
  Do                                                               
    Say "No PDS name was entered"                                   
    Exit                                                           
  End                                                               
DSINFO=LISTDSI(var1 DIRECTORY)                                     
If SYSREASON <> 0 Then Signal Error_Handler                         
Say SYSDSORG                                                       
If SYSDSORG = 'PO' Then                                             
  Do                                                               
    X=Outtrap(Listc.)                                               
    "LISTDS "var1" MEMBERS "                                       
    X=Outtrap("OFF")                                               
    Do I=1 to 3                                                     
      say listc.i                                                   
    End                                                             
    Say "There are " ((Listc.0)-6)" members in the PDS"             
    "ISPEXEC LMINIT DATAID(datain) DATASET("var1")"                 
    Say "Members Returncode"                             
    varcount = 0                                         
    Do I=8 to listc.0                                     
      Listc.i = STRIP(Listc.i)                           
      "ISPEXEC EDIT DATASET("var1"("listc.i"))"           
      RC_Open = RC                                       
      Say listc.i RC                                     
    End                                                   
  End                                                     
Else                                                     
  Do                                                     
    Say "This file is not a PDS"                         
    Say "However we will still try to process the file"   
    "ISPEXEC EDIT DATASET("var1")"                       
  End                                                     
Exit 0                   

Error_Handler:                                                   
Say "SYSREASON =" SYSREASON                                     
Select                                                           
  When SYSREASON = 3 then                                       
  Say "Dataset is a type that cannot be processed"               
  When SYSREASON = 5 then                                       
  Say "Dataset not Cataloged Moron"                             
  When SYSREASON = 8 then                                       
  Say "Dataset is not on a DASD"                                 
  When SYSREASON = 9 then                                       
  Say "DFHSM migrated the Dataset. NORECALL prevents retrieval" 
  When SYSREASON = 11 then                                       
  Say "You haven't got sufficient authority for this operation" 
  When SYSREASON = 12 then                                       
  Say "Cannot process VSAM"                                     
  Otherwise                                                     
End                                                             
Exit                                                             
Back to top
View user's profile Send private message
rajesh-amigos
Currently Banned

New User


Joined: 03 Aug 2007
Posts: 25
Location: India

PostPosted: Fri Aug 17, 2007 1:11 pm
Reply with quote

Hi Kevin,

In your previous example, you havent handled teh return code form Edit statment.!!!!

My problem is that i want to get some specific statments executed if the return code form Edit is none Zero, and if possible suppressing the system generated ISPF ISRE093 screen. I hope I made my question more clearer this time. Can you help me in this now?
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri Aug 17, 2007 4:41 pm
Reply with quote

Quote:
In your previous example, you havent handled the return code from Edit statment.!!!!


Yes Kevin, how remiss of you icon_eek.gif

rajesh-amigos
Perhaps you should decide on your own logic based on the example given by Kevin for dealing with the other error condition.

After all, this is your problem, not Kev's, but ..............

Code:

Address ISPEXEC "EDIT DATASET('"var1"("listc.i")') MACRO ("packoff")"
RC_Open = RC

IF RC_Open <> 0 THEN DO
  my error handling logic
END
Back to top
View user's profile Send private message
rajesh-amigos
Currently Banned

New User


Joined: 03 Aug 2007
Posts: 25
Location: India

PostPosted: Fri Aug 17, 2007 5:54 pm
Reply with quote

Hi Expat,

icon_eek.gif
Seems nobody is taking my problem seriously.
If you see my original code, You will see that I have handled the error from LISTDSI effectively.

In this case, if a particular member is already opened in Edit mode, the RC is supposed to be 14. However when i run this code for such a PDS, The code doesnt even reach the line "If RC<>0 ", rather it goes to the screen ISPF ISRE093, which tells that a member is opened in edit mode, and after that the EXEC gets terminated. It is this problem, that i wanted a advice on, how to give the control back to Rexx Exec, and if possible, supress the ISPF screen

Now can somebody advice me please.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri Aug 17, 2007 8:15 pm
Reply with quote

We do take your problem seriously, otherwise we wouldn't be here - would we ???

If you have a MACRO called WHOHAS, WHOGOT, WG, or whatever - I have come across this in several sites but each with different names, you can execute this before the edit macro and outtrap the results to see if the dsn has an exclusive, or shr against it.

From then in you can either exec the edit macro or not.

Code:

X = OUTTRAP(TRAP.)           
"WHOHAS 'xxxxxx.xxxxxx.xxxxx'"       
X = OUTTRAP(OFF)             
DO A = 1 TO TRAP.0           
  IF POS(TRAP.3,'USE=EXCLUSIVE) > 0 then skip the edit macro               
END   
Back to top
View user's profile Send private message
t_ctaram

New User


Joined: 15 May 2007
Posts: 20
Location: mumbai

PostPosted: Fri Aug 17, 2007 8:32 pm
Reply with quote

Good Expat,

your example cleared my doubt also regarding WHOHAS posted earlier.

Rajesh,

Try using code given by Expat. its working for me.

Thanks
Ctaram.
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top