1

I am looking for help with my REXX script. Which should open an existing Member and search for a specific string.

Here is my script:

 /* REXX */ 
"ALLOC FILE(input) DA('.....(MEMBER)') SHR REUSE"
"EXECIO * DISKR "input" (STEM input. FINIS"                    
"FREE FILE(input)"                                             
/* Parmlib werden ausgelesen */                                
do i =1 to input.0                                             
   if POS('met,', input.i) > 0 Then                            
      /* Code if string is found */                            
      say Zeile gefunden                                       
   else                                                        
     /*  Code if string is not found */                        
     say Zeile nicht gefunden                                  
end                                                            

zarchasmpgmr
  • 1,422
  • 10
  • 21
  • What help do you want does the program work ???, if not what is happening; I can not see anything obviously wrong with it. Try writing the input line out, putting more `say ...` in – Bruce Martin Oct 25 '21 at 10:16
  • @BruceMartin well it is obvious that I don't need the position of the string in the output. I need the whole searched string in the output. What I am trying is, to understand how to search a specific string in a big Member and then write those string in a new Member. Goal is to make a rexx script which will check if those strings are here and give an output with those strings –  Oct 25 '21 at 10:20
  • @firedotwater Without a question, nothing is obvious! You're asking for help, then please be so polite and ask a question. Don't let us guess what you might want. – phunsoft Oct 25 '21 at 10:28
  • There is one problem with your code that might byte you in the future: In the `ALLOC` and `FREE` statements, the DD-name is exactly `INPUT`. But in the `EXECIO` statement, it is the **content** of variable `input`. If variable `input` happens to become set in a future change, the `EXECIO` might fail. Remove the double quotes around the `input` in the `EXECIO` statement. – phunsoft Oct 25 '21 at 10:32
  • 1
    Please show what you would like the ooutput for matches to look like. Give an example. – phunsoft Oct 25 '21 at 10:34
  • @phunsoft you are right. Alright. I need to read a Member to check if the PARMLIBs are avaiable. If every PARMLIB is found, then it should be generate a new Member with those PARMLIBs. Now my question is, how can I make a rexx script which will search my specific string and put it in the new Member? –  Oct 25 '21 at 10:38
  • I still don't see what the result should look like. "search my specific string and **put it in the new member" is too ambigugous. Do you want the line containing the search string to appear in the new member? Any additional information? – phunsoft Oct 25 '21 at 10:42
  • Please edit your question and add your wishes and example output there. The comment is not the best place for this, since formatting is limited. Thanks. – phunsoft Oct 25 '21 at 10:43
  • The comparison is case sensitive. Are you expecting the string you are looking for to match lower case '`met,`'? If not, you might need to convert input.I to supper case for the comparison. As others have said, what is the expected output and what are you actually seeing? – Hogstrom Oct 25 '21 at 13:25
  • 1
    Is there a reason you're writing code instead of using ISRSUPC ([ISPF 3.14](https://www.ibm.com/docs/en/zos/2.5.0?topic=3-search-utility-option-314))? – cschneid Oct 25 '21 at 13:59

3 Answers3

1

As cschneid stated this looks like something you would just use SuperC for. ISPF Option 3.14 or 3.15 will search for a string and show results. Also you can issue SRCHFOR from a member list and have only the found members then filtered in the member list. Additionally ISPF LM services can be used to go thru members of a PDS and then run an Edit macro to do the find. EXEXIO could be used to write the results to an output file. Note that SuperC will already do this using 3.15

Marv Knight
  • 416
  • 2
  • 4
0

You could also call ISRSUPC from Rexx. There was a nifty Rexx exec published in MVS Update long ago. It searches for a string across all members of a PDS and presents the "hit list" on an ISPF panel, so you can edit or view the members.

I still use it (a descendant of it anyway) on my systems. I found the MVS Update article, here it is :

https://manualzz.com/doc/10913425/mvs0207

rphi
  • 1
  • 1
0

Under ISPF, edit macros seem like a good fit. You can set up an ISPF stack if you're not running one already, works in batch too.

If I'm reading your requirement correctly, maybe something like this might work:

/* REXX-ISPF V/E macro */

Address ISREDIT                                    
"MACRO (needle,dest)"                              
                                                   
"CURSOR = 1 0"                                     
lastHit = 0                                        
i = 0                                              
                                                
"SEEK "needle                                      
Do While RC=0                                      
  "(l#) = CURSOR"                                  
  /* Conditional for multiple hits on same line */ 
  If l# > lastHit Then Do   /* do */               
    "(this) = LINE "l#                             
    i=i+1; out.i = this                            
    lastHit = l#                                   
  End                                              
  "SEEK "needle                                    
End                                                
out.0=i                                            
                                                   
Address TSO                                        
"ALLOCATE F(OUT) DA("dest"') OLD"                  
"EXECIO "out.0" DISKW OUT (FINIS STEM out."        
                                                   
Exit 0                                             

You can do this with much fewer lines with more ISPF services in a Macro (X ALL -> F ALL needle -> DEL ALL X -> CREATE dest). Or through intermittent use of ISPF E clipboard. That has some risks, so not going into that.

Good thing about ISPF E/V Macros is that thy use almost the same command you'd normally use in ISPF E/V. Find is quick. It needs to fit the whole dataset in the Region which might be an issue sometimes.

apo
  • 106
  • 5