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

fetch the record number from FMNMAIN sysprint


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

New User


Joined: 27 Feb 2021
Posts: 28
Location: Germany

PostPosted: Mon Mar 15, 2021 2:31 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 563
Location: Bamberg, Germany

PostPosted: Mon Mar 15, 2021 3:00 pm
Reply with quote

Why that complicated? Use IEBPTPCH and a tiny SORT Step for example.
Back to top
View user's profile Send private message
Mahsa Rouzkhatouni

New User


Joined: 27 Feb 2021
Posts: 28
Location: Germany

PostPosted: Mon Mar 15, 2021 3:09 pm
Reply with quote

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 icon_sad.gif I'll start reading about it now, hope I can figure it out.

Thanks Jeorg
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 563
Location: Bamberg, Germany

PostPosted: Mon Mar 15, 2021 3:19 pm
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1140

PostPosted: Mon Mar 15, 2021 5:42 pm
Reply with quote

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
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 477
Location: Denmark

PostPosted: Mon Mar 15, 2021 7:37 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10795
Location: italy

PostPosted: Mon Mar 15, 2021 8:37 pm
Reply with quote

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
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2243
Location: Silicon Valley

PostPosted: Mon Mar 15, 2021 11:10 pm
Reply with quote

Code:
filem.0=0                       /* discard any previous output     */

I am not sure that actually 'discards' the output. Perhaps, use DROP.
Code:
DROP filem.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10795
Location: italy

PostPosted: Mon Mar 15, 2021 11:18 pm
Reply with quote

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
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 477
Location: Denmark

PostPosted: Tue Mar 16, 2021 3:20 pm
Reply with quote

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
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 762
Location: Pennsylvania

PostPosted: Tue Mar 16, 2021 7:35 pm
Reply with quote

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
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 total number of bytes PL/I & Assembler 10
No new posts Chained RPL - How to get RRN number. JCL & VSAM 0
No new posts COBOL Table data to a flat file with ... COBOL Programming 8
No new posts Write a current record plus previous ... DFSORT/ICETOOL 4
No new posts Error while fetching the record from ... COBOL Programming 3
Search our Forums:

Back to Top