Searchfor a string in 2 or 3 pds in rexx



IBM's Command List programming language & Restructured Extended Executor

Searchfor a string in 2 or 3 pds in rexx

Postby chintu » Fri Aug 02, 2019 12:13 am

Hello
I am new into rexx and have been asked to write few codes. So i wrote a code where we can open a copybook directly from cobol code by placing the cursor on the copybook name. I dont have the code with me right now but i can attach it tomorrow. Basically whats happening is first it will search the copybook name in the endevor stage libraries and open the copybook if available. The stage library names i am giving as input through PULL command. Suppose if i enter library A and the the element is not present it will throw a message. Then again i enter library B to check if it is present or not. Can this be made simpler? What i was thinking like if i could do a SRCHFOR for the copybook name in the libraries and somehow i could capture the status code for example FOUND in this library(just like normal srchfor when it displays found next to the pds or ps) and accordingly open that dataset directly. That way i would not have to manually check evry dataset. Is that possible? Kindly help as i have started two weeks ago learning rexx and i dont know how to call srchfor.
chintu
 
Posts: 14
Joined: Sun Jan 08, 2017 8:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searchfor a string in 2 or 3 pds in rexx

Postby willy jensen » Fri Aug 02, 2019 12:52 am

It is not clear to me if you are looking for a membername in a number of PDSs, or members with a given content in a number of PDSs.
If membername then use the REXX SYSDSN builtin function to locate the dataset with the member. Yes you will have to do a number of SYSDSNs in a loop till you locate the member, but that will just be a 4 line loop. If you are looking for contents then I highly recommend the PDS86 command from CBTTAPE.ORG file 182. You will still have to loop around one search per dataset. Perhaps IBM File Manager can do it, but I am not so familiar with that product. And you might not have it.
willy jensen
 
Posts: 338
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 44 times

Re: Searchfor a string in 2 or 3 pds in rexx

Postby chintu » Fri Aug 02, 2019 1:06 am

Hello thanks for the response. No its not contents. Its just the member name. I am already using SYSDSN function in the code. Thats how, when i enter library A it checks the SYSDSN condition and throws a message that the member is not present in library A. So then again I have to reexecute the Rexx and then it asks me to enter the library
Name and this time I enter library B to check if it is present or not. If it is present it will not throw any message and directly open the member. So the check is not happening before I enter the lib name. First I have to enter the lib name then it will tell me if the membername is present or not. If present it will open. So suppose that membername might be present in five libraries and it is present in the 5th. Then i would have to execute the rexx 5 times to open that member according to my code. So i wanted to know if there is a possibility where I can get rid of entering the 5 datasets five times and hardcode the dataset names and do a searchfor for the member name and based on the result of searchfor(in which dataset it is present) view the member name directly
Last edited by chintu on Fri Aug 02, 2019 1:09 am, edited 1 time in total.
chintu
 
Posts: 14
Joined: Sun Jan 08, 2017 8:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searchfor a string in 2 or 3 pds in rexx

Postby chintu » Fri Aug 02, 2019 1:07 am

Maybe I can use a loop for the sysdsn like you said and keep entering the library names untill the correct one. Am i right
chintu
 
Posts: 14
Joined: Sun Jan 08, 2017 8:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searchfor a string in 2 or 3 pds in rexx

Postby willy jensen » Fri Aug 02, 2019 1:14 am

You write
it will search the copybook name in the endevor stage libraries and open the copybook if available. The stage library names i am giving as input through PULL command
which led me to believe that you had a list of datasets to search in the stack. But now you write that you have to manually enter the library names?
As an aside, some members of this forum will likely tell you that neither SYSDSN nor any other REXX function throws anything, they return a number or a text.
willy jensen
 
Posts: 338
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 44 times

Re: Searchfor a string in 2 or 3 pds in rexx

Postby chintu » Fri Aug 02, 2019 1:23 am

The messages thrown were coded by me based on the condition. And yes they are endevor stage libraries. There are 4 endevor stage libraries. Stage1, stage2, stage3 and stage4. So i am searching that copybook member in those 4 libraries. So my code will ask me "enter the stage library"
I will enter the value stage1. And then the code runs and based on the sysdsn check it will tell me whether it is present or not. If present it will open the member. If not it will come out of the rexx. I have to again execute the rexx if it is not present. So when i said hardcode i mean i want to include those 4 in the code and do a srchfor at once and display the name of the library(stage1,2,3or 4) which has the member. I just want only till that part. The further logic i will take care later. I cannot simplify more than this. Sorry if you are still dont understand. Thanks anyways for the response. I will definitely try the sysdsn looping for all 4 datasets
chintu
 
Posts: 14
Joined: Sun Jan 08, 2017 8:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searchfor a string in 2 or 3 pds in rexx

Postby willy jensen » Fri Aug 02, 2019 1:28 am

ok, if you can provide a list of datasets somehow, then here is one sample...
/* using datasets in a list  */                
 dsl='SYS1.MACLIB SYS1.MODGEN'                    
 member = 'IHASDWA'                              
 fds=''                                          
 do n=1 to words(dsl) until fds<>''              
   ds = word(dsl,n)                              
   if sysdsn("'"ds"("member")'")='OK' then fds=ds
 end                                              
 if fds='' then do                                
   say member 'not found in any library'          
   exit 12                                        
 end                                              
 say member 'is in' fds        
willy jensen
 
Posts: 338
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 44 times

Re: Searchfor a string in 2 or 3 pds in rexx

Postby NicC » Fri Aug 02, 2019 1:32 am

As Willy stated - nothing is "thrown" in zOS. Programs abend, fail, issue non-zero return codes, issue error message etc but these are not "thrown" (Health and Safety don't like it!).
Why do you have to execute the program again? Why not simply prompt for another member and do the search again. Prompting and reading the response is just the same as reading the next record in batch programs - you do not run the program for each record you run the program for all records.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3026
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Searchfor a string in 2 or 3 pds in rexx

Postby chintu » Fri Aug 02, 2019 1:39 am

Hi Nic thanks for the response. Sorry for the word thrown.
Yes im gonna do the prompting again and search till the correct one.
chintu
 
Posts: 14
Joined: Sun Jan 08, 2017 8:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searchfor a string in 2 or 3 pds in rexx

Postby chintu » Fri Aug 02, 2019 1:41 am

Thanks willy for the help :)
chintu
 
Posts: 14
Joined: Sun Jan 08, 2017 8:51 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post