Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Search for a string in PDS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
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    Post subject: Search for a string in PDS
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri May 15, 2009 2:53 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri May 15, 2009 3:47 pm    Post subject:
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri May 15, 2009 4:02 pm    Post subject:
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    Post subject: Reply to: Search for a string in PDS
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri May 15, 2009 4:10 pm    Post subject:
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    Post subject:
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    Post subject: Reply to: Search for a string in PDS
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri May 15, 2009 4:38 pm    Post subject:
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Fri May 15, 2009 4:50 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm
No new posts How to insert a lengthy string havin... vidyaa DB2 7 Thu Aug 25, 2016 5:20 pm
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm
No new posts Need a help how to replace a string i... gurunath82 CLIST & REXX 12 Tue Jul 26, 2016 11:43 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us