View previous topic :: View next topic
|
Author |
Message |
Mahsa Rouzkhatouni
New User
Joined: 27 Feb 2021 Posts: 32 Location: Germany
|
|
|
|
Hi guys,
I am writing a rexx program, calling file manager to find a string in a PDS member.
What I need is to fetch the record number of the found string. For small datasets I used to code
Code: |
DO J=1 TO lastrecord
IDX1=INDEX(rec.1,string)
SAY IDX1
END
|
But of course it's not efficient for a large dataset as it reads record by record.
Now I'm trying to find the string with file manager with CALL *(FMNMAIN)
but I can't figure out in which default variable the record number resides. (like RC which is defined by programe).
Please let me know what you think.
Thanks in advance,
Mahsa Rouzkhatouni |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1222 Location: Bamberg, Germany
|
|
|
|
Why that complicated? Use IEBPTPCH and a tiny SORT Step for example. |
|
Back to top |
|
|
Mahsa Rouzkhatouni
New User
Joined: 27 Feb 2021 Posts: 32 Location: Germany
|
|
|
|
Joerg.Findeisen wrote: |
Use IEBPTPCH and a tiny SORT Step for example. |
Do you mean instead of calling File Manager I can use IEBPTPCH and sort, or just manage the output with that?
I've never used IEBPTPCH I'll start reading about it now, hope I can figure it out.
Thanks Jeorg |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1222 Location: Bamberg, Germany
|
|
|
|
IEBPTPCH will unload the PDS[E] to a PS and there you have Member name and all the content.
Maybe ISRSUPC will also be of use for that purpose, but I don't have a sample at hand. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2010 Location: USA
|
|
|
|
1. Any inefficiency in REXX approach may become significant only when the “members” size is above 10M-100M records, or so. I doubt you are dealing with such amount of lines.
2. Regarding IEBPTPCH: before asking for help, you can try a test run of this utility, to visually verify how its output look like, and then to find out how to deal with it
Code: |
//UNLOAD EXEC PGM=IEBPTPCH
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DISP=SHR,DSN=your.library.name
//SYSUT2 DD SYSOUT=*
//SYSIN DD *
PRINT TYPORG=PO,MAXFLDS=1
RECORD FIELD=(121) - or whatever your LRECL is
//* |
|
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 712 Location: Denmark
|
|
|
|
I am not aware of any FileManager/REXX API, IBM File Manager for z/OS User's Guide and Reference Ver 13.1 indicates that there isn't one.
What you can do, however, is to run you request from the ISPF dialog and mark the 'Batch execution' option. That will give you the JCL and input commands, which can be generated from a REXX pgm.
Quick batch test shows that the FileManager list shows the line number where the data is found. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
from
www.ibm.com/support/knowledgecenter/SSXJAV_14.1.0/com.ibm.filemanager.doc_14.1/base/intprg.html
Code: |
/* REXX */
/* ***************************************************/
/* Example: Execute File Manager functions from REXX */
/* ***************************************************/
parse upper source environment.
/* List the catalog entries on the printout */
FILEMGR "$SCS FUNCTION=PRINT" /* call SCS for the master catalog */
say "SCS return code:" RC
/* Provided the installation default for PRINTOUT is PRINTOUT=REXX */
/* then commands from this platform will be directed to the stem */
/* variable FILEM. */
filem.0=0 /* discard any previous output */
/* call SCS for a user catalog */
FILEMGR "$SCS CATALOG='CATALOG.PRODUCTS.UCAT',DSNAME='ADSM.**'," ,
"FUNCTION=PRINT,SORTBY=DATE"
say "SCS return code:" RC
/* Display the FILEM.n variable contents */
SAY ">>> SCS output:"
DO i=1 to filem.0 /* process all printed lines */
SAY filem.i /* display the printline */
END |
|
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2545 Location: Silicon Valley
|
|
|
|
Code: |
filem.0=0 /* discard any previous output */ |
I am not sure that actually 'discards' the output. Perhaps, use DROP.
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
unless You know what You are doing
drop is a dangerous function
it might trigger a NOVALUE condition and related misbehaviours
setting filem.0=0
will just let a loop do I=1 to filem.0 exit nicely doing nothing |
|
Back to top |
|
|
Willy Jensen
Active Member
Joined: 01 Sep 2015 Posts: 712 Location: Denmark
|
|
|
|
I just found that Filemanager does not set filem.0 in case of errors, so either set if beforehand, or do a DATATYPE test afterwards.
I tried to run the filemanager FCH command as show by the link, but it seems that it still requires the search data in SYSIN. |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Another alternative is to use a Rexx exec and an Edit Macro.
You can call the Edit Macro multiple times by placing it in a loop as needed by your requirement.
You can run this under TSO/ISPF or in Batch mode.
Rexx exec:
Code: |
/* REXX SEARCH FOR A FIELD */
PDS_NAME = 'MY.PDS.NAME'
MEM_NAME = 'MYMEMBER'
FINDWHAT = 'FINDFIELD'
DATA1 = PDS_NAME||'('||MEM_NAME||')'
SAY 'SEARCHING' DATA1 'FOR' FINDWHAT
"ISPEXEC VIEW DATASET ("DATA1") MACRO(FINDIT2) PARM(FINDWHAT)"
EXIT
|
Edit Macro:
Code: |
/* REXX SEARCH FOR A FIELD */
"ISREDIT MACRO (FINDWHAT)"
"ISREDIT RESET"
"ISREDIT F '"FINDWHAT"' FIRST"
RCODE = RC
IF RCODE = 0 THEN DO UNTIL RCODE > 0
"ISREDIT (FINDLINE,FINDCOL) = CURSOR"
"ISREDIT (HOLD1) = LINE "FINDLINE
SAY FINDLINE LEFT(HOLD1,72)
"ISREDIT F '"FINDWHAT"' NEXT"
RCODE = RC
END
ELSE SAY FINDWHAT 'NOT FOUND'
"ISREDIT END"
EXIT |
|
|
Back to top |
|
|
|