Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interpret with "IF THEN DO END" 1

Status
Not open for further replies.

Rigdzin

Technical User
May 18, 2010
6
DE
Hello
I am trying the following Rexx :
TRACE R
STGGrp = 'P2WA'
CNT_P2WA = 11
Interpret "IF CNT_"StgGrp" > 10 THEN" ,
"SAY CNT_"StgGrp /* <<< FUNCTIONS *OK */

Interpret "IF CNT_"StgGrp" > 10 THEN" , /* <<< FUNCTIONS NOT */
"DO" ,
"SAY CNT_"STgGrp " "
"END"
First Interpret works OK (no DO-END)
2nd. does not work. I already a few variations but nothing helped.

Anyone know how to do this ???

THanks
 
Try terminating your statements! This works:

interpret "if cnt_"stggrp" > 10 then do; say cnt_"stggrp"; end
 
HI Thanks for the answer. [medal]

Adding the ";" did the job

StgGrp = 'P2WA'
Cnt_P2WA = 11
Interpret "IF Cnt_"StgGrp" > 10 THEN" ,
"DO ;" ,
"SAY Cnt_"StgGrp ";" ,
"SAY Cnt_"StgGrp ";" ,
"END"

Giovanni, Munich Germany
 
Why are you using "interpret"? There's nothing there that requires it. Am I missing something?

Frank Clarke
--America's source for adverse opinions since 1943.
 
Hi Frank,
the supplied REXX was just a sample.

The real rexx is an AF/OPERATOR rexx that Traps the MSG :

IGD17272I VOLUME SELECTION HAS FAILED FOR INSUFFICIENT SPACE FOR
DATA SET PDB2DBS.PDB2KAT3.SYSCOPYI
JOBNAME (PMDBKAT3) STEPNAME (STEP02 )
PROGNAME (IKJEFT01) DDNAME (SYSPRINT)
REQUESTED SPACE QUANTITY = 24901 KB
STORCLAS (DB2STD) MGMTCLAS (PDB2STD) DATACLAS (DATA)
STORGRPS (PDB2 )



Depending on the Storage-Group we automatically add a volume to the Storgrp (Max 1x per day and only Weekends and nights)

I Keep counters for the Storgrps that are involved. Instead of checking each Storgrp by itself, I use the supplied Storgrp in the message to do this :

Here part of this process :


IF StgGrp = 'PBAUBG' ! ,
StgGrp = 'P2WA' ! ,

..
..
StgGrp = 'WD7S' ! ,
StgGrp = 'WD8S' THEN
DO

/**********************************************************************/
/*==> OK = 'SHARVGET'("SYSTEM","CNT_P2WA") Beispiel */
Interpret "OK = 'SHARVGET'(""SYSTEM"",""CNT_"stggrp""")" /* */
IF OK = 8 THEN /* not found, init it */
DO
/**********************************************************************/
/*==> CNT_P2WA = 0 not found, init it */
Interpret "CNT_"StgGrp" = 0"
/**********************************************************************/
/*==> OK = 'SHARVPUT'("SYSTEM","CNT_P2WA") and store */
Interpret "OK = 'SHARVPUT'(""SYSTEM"",""CNT_"stggrp""")"
END

/**********************************************************************/
/* ==> IF CNT_P2WA = 0 THEN */
/* ==> DO */
/* ==> ADD_VOL= 'Y' */
/* ==> END */
Interpret "IF CNT_"StgGrp" = 0 THEN ;" , /* only add 1 time/day */
"DO ;" ,
"ADD_VOL = 'Y' ;" ,
"END"

/**********************************************************************/
/* ==> CNT_P2WA = Cnt_P2WA + 1n */
Interpret "CNT_"StgGrp" = CNT_"StgGrp" + 1 " /* incr counter */
/*==> OK = 'SHARVPUT'("SYSTEM","CNT_P2WA") and store */
Interpret "OK = 'SHARVPUT'(""SYSTEM"",""CNT_"stggrp""")"
/* */
/**********************************************************************/
/* ==> IF CNT_P2WA > 10 THEN */
/* ==> DO */
/* ==> wto */
/* ==> RETURN */
/* ==> END */
Interpret "IF CNT_"StgGrp" > 10 THEN" ,
"DO ;" ,
" ""WTO 'MW#17272 Proc For "StgGrp" was called > 10x. We EXIT now '"" ;" ,
"CALL INFORM1 ;" , /* informwe are not addin*/
"EXIT ;" , /* << EXIT Here */
"END" /* */
END /* */
ELSE DO /* for all othe pools */
OK = 'SHARVGET'("SYSTEM","CNT_MW#17272") /* DO we have a counter */
IF OK = 8 THEN CNT_MW#17272 = 0 /* no set to zero */
CNT_MW#17272 = CNT_MW#17272 + 1
OK = 'SHARVPUT'("SYSTEM","CNT_MW#17272")

IF CNT_MW#17272 > 10 THEN
DO
"WTO 'MW#17272 Proc was called > 10x. We EXIT now '" ,
"MSGID(AF-17272)"
RETURN
END
END


The Counters are reseted every night 00:00.
The free-Volumes are in a daily created Free-Volume file (read by AFO).

The New-Volid I get from doing a

X = REDIRECT("line.","*")
"OPER 'D SMS,STORGRP("StgGrp"),LISTVOL' RESP"


Hope you like it :)

Kind regards Giovanni
 
My question stands:

Why use 'interpret' if there's nothing there which requires it? This is considered "a very poor practice".

Frank Clarke
--America's source for adverse opinions since 1943.
 
Hi Frank

The Storage-pool-Names (in the first IF) is quite long.

Doing it this way, I need to code everything in the first DO-END only once.

Othewise I needed to do multiple IFs or "SELECT" + multiple WHENs.

Beside that, it is also a lot easier to add an additional pool-name.

Of course, interpret is not the fastet thing to use, but since it is called, lets say, once every 2 Months, it is worth to do it this way, in my opinion anyway.

What would you change ??

Giovanni
 
I would have a string containing all the valid storage groups:
Code:
validgrps= "PBAUBG P2WA ... WD7S WD8S"
I might even put this into an external dataset so that I didn't have to change the REXX code when adding or deleting a name. When necessary, I would query the string:
Code:
if WordPos( grp,validgrps ) > 0 then ... /* is valid */
Alternatively, if I'm dynamically building the list, I would have a counter for each group:
Code:
grct. = 0
...
/* a strg group name has been parsed as 'newgrp' */
        /* either */
if grct.newgrp = 0 then, /* unknown */
       /*    or    */
if WordPos( newgrp,validgrps ) = 0 then, /* unknown */
   validgrps = validgrps newgrp
grct.newgrp = grct.newgrp + 1

No 'interpret' needed.

Frank Clarke
--America's source for adverse opinions since 1943.
 
Morning Frank,

Agree, it is a bit shorter, but its only to check the name .

What I need is, to have a counter for each member within the group specified.
Like Cnt_P2WA Cnt_WD6S etc etc
Your solution does not handle this problem.

The Interpret I use sets up a variable "CNT_Name" for each member of the Group.

And doing so, I need the other interprets for the "IFs" end "ADDs"

Giovanni
 
If you insist on using underscore as a separator character, yes, that's right, you'll need interpret. If you can use a stem variable as I did, no interpret.

So it appears you chose to use underscore and therefore are forced to use interpret.

De gustibus non disputandum est.

Frank Clarke
--America's source for adverse opinions since 1943.
 
HI

Again "partly" right :) ,

but.. I need to save these CNT_values so I can check them again incase this error situation happens again.

This save is done in an AFO-pool (in a Coupling Facility Structure), and
1. it is not possible to use STEM-Vars there.
( the instr. used is a "SHARVPUT")
2. since the Error (=Message) can happen across our 10 LPARs, the other LPARS need to be aware of the specific pool-counter. so that the ADD-Volume is done only once per day across all Lpars.

This rexx-proc is not the only one that saves values in this AFO-Pool.

Doing it this way the Countername is kind of "meaningful"

But i realy liked the idea with the WORDPOS (mail: 22.5.10)
I think it is a good way to avoid long "IFs" [thumbsup2] [smarty]

And.. as you say : De gustibus non disputandum est. :)

Kind regards

Giovanni
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top