REXX Query



IBM's Command List programming language & Restructured Extended Executor

REXX Query

Postby arya_s » Thu Jul 16, 2009 5:28 pm

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
arya_s
 
Posts: 7
Joined: Thu Jul 16, 2009 4:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX Query

 

Re: REXX Query

Postby MrSpock » Thu Jul 16, 2009 5:45 pm

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.
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: REXX Query

Postby arya_s » Fri Jul 17, 2009 9:31 am

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.
arya_s
 
Posts: 7
Joined: Thu Jul 16, 2009 4:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX Query

Postby expat » Fri Jul 17, 2009 11:55 am

Where are you doing your PULL from ?
expat
 
Posts: 382
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 1 time

Re: REXX Query

Postby arya_s » Fri Jul 17, 2009 2:39 pm

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:(
arya_s
 
Posts: 7
Joined: Thu Jul 16, 2009 4:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX Query

Postby expat » Fri Jul 17, 2009 4:01 pm

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.
expat
 
Posts: 382
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 1 time

Re: REXX Query

Postby MrSpock » Fri Jul 17, 2009 7:08 pm

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?
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: REXX Query

Postby arya_s » Sat Jul 18, 2009 7:27 pm

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) +++
***
arya_s
 
Posts: 7
Joined: Thu Jul 16, 2009 4:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX Query

Postby arya_s » Mon Jul 20, 2009 8:46 am

Can someone please suggest what changes to make in the code.
arya_s
 
Posts: 7
Joined: Thu Jul 16, 2009 4:05 pm
Has thanked: 0 time
Been thanked: 0 time

Re: REXX Query

Postby MrSpock » Mon Jul 20, 2009 6:05 pm

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.
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post