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

Search for a string in PDS


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

New User


Joined: 30 Jul 2008
Posts: 32
Location: Pune

PostPosted: Fri May 15, 2009 12:42 pm
Reply with quote

Hi,

I am trying to search for a string in PDS.

The requirement is: To read a flat file which are having the Dataset names.

I have to read each record from file, which I have coded till now.
Now I have to search for a string in the PDS(first record from flat file) and if found write the members to an output file.
Then read the second PDS name from file, search the string and then carry out the same process.

Could you help me out here.

Thanks,
Praveen.
Back to top
View user's profile Send private message
acs_amit

New User


Joined: 30 Apr 2009
Posts: 14
Location: Noida

PostPosted: Fri May 15, 2009 2:41 pm
Reply with quote

Why don't you try with POS command..

Suppose you are reading your dataset thru EXECIO function and reading lines in a stem variable.. for ex.. 'input.'

Now check

Code:
Do i =1 to input.0
   If POS('String_to_be_searched', Input.i) > 0 Then
      /* Code if string is found */
   Else
     /*  Code if string is not found */
End


Here 'FIND' command also can be used.. but in that case searching_string must be a seperate word.

Please correct me if i am wrong or incomplete..
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri May 15, 2009 2:53 pm
Reply with quote

What will you use to perform the search of the PDS.
The method suggested by acs_amit will work, but is probably the least efficient.

Have you considered searching the PDS for all strings and parsing the output.
Back to top
View user's profile Send private message
praveensn

New User


Joined: 30 Jul 2008
Posts: 32
Location: Pune

PostPosted: Fri May 15, 2009 3:16 pm
Reply with quote

Hi,

I did not understand the statement:

"What will you use to perform the search of the PDS."

As mentioned by Amit, I am using EXECIO to read the dataset name and storing it into a varible.

Please find the code till now:

"EXECIO * DISKR INPUT(STEM PSNAME. FINIS)"
SAY 'PSNAME SIZE: ' PSNAME.0
SAY 'PSNAME 1ST: ' STRIP(PSNAME.1)
SAY 'PSNAME 2ND: ' STRIP(PSNAME.2)
SAY 'PSNAME 3RD: ' STRIP(PSNAME.3)
SAY 'PSNAME 4TH: ' STRIP(PSNAME.4)
DO I=1 TO PSNAME.0
IF SYSDSN("'"STRIP(PSNAME.I)"'")= 'OK' THEN
SAY 'PS EXISTS:' PSNAME.I
ELSE
SAY 'PS DOESNT EXIST: ' PSNAME.I
END


Thanks,
Praveen.
Back to top
View user's profile Send private message
acs_amit

New User


Joined: 30 Apr 2009
Posts: 14
Location: Noida

PostPosted: Fri May 15, 2009 3:44 pm
Reply with quote

Praveen:

Probably EXPAT was asking about your exact requirements .

As per my assumption. there might be 3 conditions.

1. Probably you are looking for a Member name in the PDS. and if found wants to write in output file.

Or
2. You are searching any specific string in the PDS Name itself and then writing either PDS name or its members name in the output file. This is what i thought in your first post.

Or
3. You are reading a PDS name and then reading its member and then searching a particular string in that member and if found then write member name in output file.

May be i am over thinking...bt explaining your exact requirement will only help us to help you in best way.
Back to top
View user's profile Send private message
praveensn

New User


Joined: 30 Jul 2008
Posts: 32
Location: Pune

PostPosted: Fri May 15, 2009 3:47 pm
Reply with quote

Hi,

Yes

The 3rd point mentioned above is my actual requirement.

Thanks,
Praveen.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri May 15, 2009 3:47 pm
Reply with quote

Let me see if I have this correct.

You read a name from an external file.
This name is the name of a PDS
You check to see if the PDS exists
If it does exist then you search the PDS for a given string

Assuming that I am correct in my interpretation of the situation
How do you propose to search the PDS for the given string.
Back to top
View user's profile Send private message
praveensn

New User


Joined: 30 Jul 2008
Posts: 32
Location: Pune

PostPosted: Fri May 15, 2009 3:53 pm
Reply with quote

Hi,

In my above code,

IF SYSDSN("'"STRIP(PSNAME.I)"'")= 'OK' THEN
SAY 'PS EXISTS:' PSNAME.I
ELSE
SAY 'PS DOESNT EXIST: ' PSNAME.I

The file is having list of PDS names.I am checking whether PDS exists or not, if present then writing some message.

Now I have to read every member in PDS, check for the string, if present then write the member in to an output file.

Could you please help me to proceed further.


Thanks,
Praveen.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri May 15, 2009 4:02 pm
Reply with quote

Quote:
How do you propose to search the PDS for the given string.

This is my question.
Back to top
View user's profile Send private message
neeharika

New User


Joined: 23 May 2008
Posts: 14
Location: Hyderabad

PostPosted: Fri May 15, 2009 4:06 pm
Reply with quote

Praveen,

Please see the below code. It may be helpful for you.

Code:

/*******************************REXX***********************************/
/*TRACE R*/                                                             
DROP ID                                                                 
DSN = XFSPERM.TBNEPAN.SRCLIB                                           
STRING = 'ALVARO MEJIA'                                                 
/**********************************************************************/
/*            GET DATAID FOR DATASET AND ISSUE LMOPEN                 */
/**********************************************************************/
MEMBER = ' '                                                           
ADDRESS ISPEXEC 'LMINIT DATAID('ID'),                                   
        DATASET('"'"DSN"'"') ENQ(SHR)'                                 
ADDRESS ISPEXEC 'LMOPEN DATAID('ID') OPTION(INPUT)'                     
LMRC = 0                                                               
CNT = 0                                                                 
/**********************************************************************/
/*             LOOP THROUGH ALL THE MEMBERS IN THE PDS                */
/**********************************************************************/
DO WHILE LMRC = 0                                         
   ADDRESS ISPEXEC 'LMMLIST DATAID('ID') OPTION(LIST),                 
                    MEMBER(MEMBER) STATS(NO)'                           
   LMRC = RC                                                           
   IF LMRC = 0 THEN                                                     
    DO                                                                 
      CNT = CNT + 1                                                     
      SAY 'MEMBER'CNT 'IS:' MEMBER                                     
      CALL MEMVIEW                                                     
    END                                                                 
   ELSE                                                                 
      SAY 'MLIST NOT SUCCESSFUL'                                       
END                                                                     
/**********************************************************************/
/*  FREE THE MEMBER LIST AND CLOSE THE DATAID FOR THE PDS             */
/**********************************************************************/
ADDRESS ISPEXEC 'LMMLIST DATAID('ID') OPTION(FREE)'                     
ADDRESS ISPEXEC 'LMCLOSE DATAID('ID')'                                 
EXIT                                                                   
/**********************************************************************/
/*     VIEW THE MEMBER AND SEARCH FOR THE STRING                      */
/**********************************************************************/
MEMVIEW:                                                               
DROP INDD                                                               
DROP INREC.                                                             
MEMBER = STRIP(MEMBER)                                                 
DSNTOT = DSN||'('MEMBER||')'                                           
DSNTOT = "'"DSNTOT"'"                                                   
EOF_FLAG = 2                                                           
RET_CODE = 0                                                           
ADDRESS TSO 'ALLOC FI('INDD') DA('DSNTOT') SHR'                         
ADDRESS TSO 'EXECIO 0 DISKR INDD(OPEN'                                 
DO WHILE RET_CODE \= EOF_FLAG                                           
   ADDRESS TSO 'EXECIO 1 DISKR INDD'                                   
   RET_CODE = RC                                                       
   IF RET_CODE = 0 THEN                                                 
    DO                                                                 
      PARSE PULL INREC.1                                               
      IF POS(STRING,INREC.1) > 0 THEN                                   
         SAY 'STRING PRESENT IN MEMBER:' MEMBER                         
      ELSE NOP                                                         
    END                                                                 
   ELSE                                                                 
    LEAVE                                                               
END                                                                     


Thanks,
Neeharika.
Back to top
View user's profile Send private message
praveensn

New User


Joined: 30 Jul 2008
Posts: 32
Location: Pune

PostPosted: Fri May 15, 2009 4:06 pm
Reply with quote

Hi,

I think ISRSUPC can be used to search the string in a PDS.

Thanks,
Praveen.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri May 15, 2009 4:10 pm
Reply with quote

ISRSUPC can be used, and is probably the most efficient method of doing it.
Back to top
View user's profile Send private message
praveensn

New User


Joined: 30 Jul 2008
Posts: 32
Location: Pune

PostPosted: Fri May 15, 2009 4:17 pm
Reply with quote

Hi,

But, I need help in reading the members of a PDS and search the string in it.

Could you please give some sample code so that i can proceed further.

Thanks,
Praveen.
Back to top
View user's profile Send private message
neeharika

New User


Joined: 23 May 2008
Posts: 14
Location: Hyderabad

PostPosted: Fri May 15, 2009 4:30 pm
Reply with quote

Praveen,

Please check my previous post where I gave some sample code for this requirement.

Thanks,
Neeharika.
Back to top
View user's profile Send private message
praveensn

New User


Joined: 30 Jul 2008
Posts: 32
Location: Pune

PostPosted: Fri May 15, 2009 4:32 pm
Reply with quote

Hi,

Thanks for the code.

I will try to come up with the solution and let you know.

Thanks,
Praveen.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri May 15, 2009 4:38 pm
Reply with quote

Are you going to process this in batch or online, either way ISRSUPC can be invoked by the REXX code to search the PDS members far more efficiently than almost any other method.

I assume that you are quite new to REXX/ TSO / ISPF environments.
Back to top
View user's profile Send private message
praveensn

New User


Joined: 30 Jul 2008
Posts: 32
Location: Pune

PostPosted: Fri May 15, 2009 4:43 pm
Reply with quote

Hi,

Yes,

I am new to REXX.

Thanks,
Praveen.
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri May 15, 2009 4:50 pm
Reply with quote

OK, a little tip for you.

Use option 3.14 and select batch mode for execution. After the job has completed, look at the DD names that it has used and what they were used for.

You can allocate / deallocate the DD names many times in your REXX for each invocation of ISRSUPC.

The example I have used below is used in an ISPF environment, but you can read the manuals for doing this outside of ISPF using TSO CALL which you can find from the links at the top of the TSO/REXX forum.
Code:

"ISPEXEC SELECT PGM(ISRSUPC) PARM(SRCHCMP,'ANYC')"
Back to top
View user's profile Send private message
praveensn

New User


Joined: 30 Jul 2008
Posts: 32
Location: Pune

PostPosted: Fri May 15, 2009 5:01 pm
Reply with quote

Thanks a lot for the help.

Thanks,
Praveen.
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts file manager is doing string conversion IBM Tools 3
Search our Forums:

Back to Top