Page 1 of 2

REXX Query

PostPosted: Thu Jul 16, 2009 5:28 pm
by arya_s
Hi, I am new to REXX and I need some help in the following Requirement. Can some one please tell how to go about doing it in REXX

I need to check that a given pattern is present in which PDS names(only in PDS name not in PDS members)
We have to check the position of the given pattern in the PDS names,since all the PDS names have a standard format name we need to check for the position of the pattern in PDS name.
We dont know the total number of PDS's present.
Can we use a SUBSTR Function and check the position of the pattern?
Since I dont know the PDS name, I think we need to use OUTTRAP command.
Can someone please tell me how to write the REXX code for the above requirement.


eg:
Pattern : REXX
PDS:
AAA.REXX.abc1
AAA.Cobol.abc
AAA.IMS.abc

Re: REXX Query

PostPosted: Thu Jul 16, 2009 5:45 pm
by MrSpock
arya_s wrote:Can we use a SUBSTR Function and check the position of the pattern?
Since I dont know the PDS name, I think we need to use OUTTRAP command


Sure, that would work. A PARSE would probably work also.

Re: REXX Query

PostPosted: Fri Jul 17, 2009 9:31 am
by arya_s
The following is the code that I have written. Can some one please tell me what changes to make in the code. The code is not complete and anyways it is not working...
***************************** Top of Data ******************************
/*REXX*/
PULL REXX1.
X = OUTTRAP('REXX.')
"LISTA ST"
SAY 'X: ' X
SAY 'REXX.0' REXX.0
SAY 'REXX.1' REXX.1
SAY 'REXX.2' REXX.2
SAY 'REXX.3' REXX.3
SAY 'REXX.4' REXX.4
SAY 'REXX.5' REXX.5
FOUND = 'NO'
I = 1

DO WHILE (FOUND = 'NO') & (I <= REXX.0)
IF LENGTH(REXX.I) >= 9 THEN
DO
IF SUBSTR(REXX.I,3,7) = 'REXX' THEN
DO
SAY 'REXX FOUND'
FOUND = 'YES'
I = I - 1
CONCAT = "'"REXX.I"'"
SAY 'CONCAT: ' REXX.I
END
ELSE
DO
I = I + 1
END
END
ELSE
I = I + 1

END
EXIT
**************************** Bottom of Data ****************************
**************************************************************************************************
O/P coming for the above written code is as follows:
*-* "LISTA ST"
>>> "LISTA ST"
***
X: REXX.
REXX.0 376
REXX.1 --DDNAME---DISP--
REXX.2 SYS1.HELP
REXX.3 SYSHELP KEEP
REXX.4 REXX.SFANHENU
REXX.5 KEEP
**********************************************************************************************
My actual PDS names are :
AAA.REXX.abc1
AAA.Cobol.abc
AAA.IMS.abc
AAA.CICS.abc
AAA.REXX.abc2

Why are the above mentioned PDS's not coming when i do a PULL.
I am checking whether the given pattern "REXX" is present in which PDS names.
SO, my O/P File should have a list of the above mentioned PDS names.
Can some one please tell me how to go about doing this.

Re: REXX Query

PostPosted: Fri Jul 17, 2009 11:55 am
by expat
Where are you doing your PULL from ?

Re: REXX Query

PostPosted: Fri Jul 17, 2009 2:39 pm
by arya_s
I am sorry I did not get your question?
The PULL command here, will just take the names of datasets right?
Can someone please tell me how to go about writing the code for the above mentioned requirement, I am just not getting it right:(

Re: REXX Query

PostPosted: Fri Jul 17, 2009 4:01 pm
by expat
Have you actually read the REXX reference manual.

The PULL command reads from the (or a) stack. This stack needs to be populated before a PULL will actually pull anything from it. I can see no EXECIO or PUSH statement to populate the stack.

Re: REXX Query

PostPosted: Fri Jul 17, 2009 7:08 pm
by MrSpock
arya_s, if you want to work this out one piece at a time, that's fine. It sounds as if you need to start by working out the details of reading the dataset with the PDS names and processing each record individually. Am I right?

Re: REXX Query

PostPosted: Sat Jul 18, 2009 7:27 pm
by arya_s
I don't know what datasets are going to be there.
I need to check if the given pattern "REXX" is present in the Pds names or not.
My O/P file should have all the Pds names having the pattern "REXX"
I am attaching the modified code here which is not running properly.
I am not getting how to get the dataset names that I need for pattern matching.
I am new to REXX and therefore I am not comfortable with all the commands and syntax of REXX.
Any help would be kindly appreciated.

***************************** Top of Data ******************************
/*REXX*/
TRACE C
/*ARG DDNAME . */
/*PULL ADDNAME . */
X = OUTTRAP('NAME.')
"LISTA ST"
/*SAY 'X: ' X
SAY 'NAME.0' NAME.0
SAY 'NAME.1' NAME.1
SAY 'NAME.2' NAME.2
SAY 'NAME.3' NAME.3
SAY 'NAME.4' NAME.4
SAY 'NAME.5' NAME.5 */
FOUND = 'NO'
I = 1

DO WHILE (FOUND = 'NO') & (I <= NAME.0)
/*IF LENGTH(NAME.I) >= 18 THEN
DO */
SAY 'IN FIRST DO WHILE LOOP'
IF SUBSTR(NAME.I,3,7) = 'REXX' THEN
DO
SAY 'REXX FOUND'
FOUND = 'YES'
I = I - 1
/* CONCAT = "'"NAME.I"'"
SAY 'CONCAT: ' NAME.I */
END
ELSE
DO
I = I + 1
END
/* END
ELSE
I = I + 1 */

END
SAY 'FOUND: ' FOUND
IF FOUND = 'YES' THEN
DO WHILE (I + 3) <= NAME.0
I = I + 3
IF SUBSTR(NAME.I,1,3) = ' ' THEN
DO
I = I - 1
/*CONCAT = CONCAT",'"NAME.I"'" */
END
ELSE
I = NAME.0
END

ELSE NOP

/* ALLOCATE THE NEW CONCATENATION TO REXX */
"ALLOC F(REXX) DA('"ADDNAME"',"CONCAT") SHR REUSE"
**************************** Bottom of Data **************************

O/P coming:
6 *-* "LISTA ST"
>>> "LISTA ST"
IN FIRST DO WHILE LOOP
***
IN FIRST DO WHILE LOOP
IN FIRST DO WHILE LOOP
IN FIRST DO WHILE LOOP
FOUND: NO
54 *-* "ALLOC F(REXX) DA('"ADDNAME"',"CONCAT") SHR REUSE"
>>> "ALLOC F(REXX) DA('ADDNAME',CONCAT) SHR REUSE"
+++ RC(12) +++
***

Re: REXX Query

PostPosted: Mon Jul 20, 2009 8:46 am
by arya_s
Can someone please suggest what changes to make in the code.

Re: REXX Query

PostPosted: Mon Jul 20, 2009 6:05 pm
by MrSpock
Please explain the premise behind your code. It really doesn't seem to match your original topic.

From what I can tell:

1. You want to use the TSO "LISTA" command to list all of the PDS's allocated to your TSO session.
2. From that list, you want to find all of the PDS's that have a value of 'REXX' in positions 3-6 of the dataset name (you need to adjust that on your SUBSTR statement): i.e.:

aaREXXbb <= would match
a.REXX. <= would match
aa.REXX < = would NOT match

3. If a PDS name matches, then I guess you want to build a variable called "concat" which will contain a string of all of the datasets found with 'REXX'.

4. At the end, I guess you want to create an allocation of concatanated PDS's with the PDS 'ADDNAME' concatanated together with the rest of the found PDS's.