View previous topic :: View next topic
|
Author |
Message |
praveensn
New User
Joined: 30 Jul 2008 Posts: 32 Location: Pune
|
|
|
|
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 |
|
|
acs_amit
New User
Joined: 30 Apr 2009 Posts: 14 Location: Noida
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
praveensn
New User
Joined: 30 Jul 2008 Posts: 32 Location: Pune
|
|
|
|
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 |
|
|
acs_amit
New User
Joined: 30 Apr 2009 Posts: 14 Location: Noida
|
|
|
|
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 |
|
|
praveensn
New User
Joined: 30 Jul 2008 Posts: 32 Location: Pune
|
|
|
|
Hi,
Yes
The 3rd point mentioned above is my actual requirement.
Thanks,
Praveen. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
praveensn
New User
Joined: 30 Jul 2008 Posts: 32 Location: Pune
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Quote: |
How do you propose to search the PDS for the given string. |
This is my question. |
|
Back to top |
|
|
neeharika
New User
Joined: 23 May 2008 Posts: 14 Location: Hyderabad
|
|
|
|
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 |
|
|
praveensn
New User
Joined: 30 Jul 2008 Posts: 32 Location: Pune
|
|
|
|
Hi,
I think ISRSUPC can be used to search the string in a PDS.
Thanks,
Praveen. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
ISRSUPC can be used, and is probably the most efficient method of doing it. |
|
Back to top |
|
|
praveensn
New User
Joined: 30 Jul 2008 Posts: 32 Location: Pune
|
|
|
|
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 |
|
|
neeharika
New User
Joined: 23 May 2008 Posts: 14 Location: Hyderabad
|
|
|
|
Praveen,
Please check my previous post where I gave some sample code for this requirement.
Thanks,
Neeharika. |
|
Back to top |
|
|
praveensn
New User
Joined: 30 Jul 2008 Posts: 32 Location: Pune
|
|
|
|
Hi,
Thanks for the code.
I will try to come up with the solution and let you know.
Thanks,
Praveen. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
praveensn
New User
Joined: 30 Jul 2008 Posts: 32 Location: Pune
|
|
|
|
Hi,
Yes,
I am new to REXX.
Thanks,
Praveen. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
praveensn
New User
Joined: 30 Jul 2008 Posts: 32 Location: Pune
|
|
|
|
Thanks a lot for the help.
Thanks,
Praveen. |
|
Back to top |
|
|
|