Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Rexx capture individual lines from a DSN?

Status
Not open for further replies.

ClaudeFountain

Programmer
Jul 23, 2004
1
US
Hi everyone.
I have been searching the various sites for a glimmer of hope. I have found none, so I have joined here to ask for help. I also tried searching the forums, but I'm not sure how to phrase what I am looking to do.

Basically, I have already setup a REXX program to ask for input from the user (a jobname) and then it customizes some JCL to do a CA7 batch execute to display all of the attributes of the specified job. That info is then dumped into a dataset.

Now, I need to extract some of that information. In more specific terms, I need to
1) find the words 'triggered by'.
2) capture the next line of data, if blank, goto 4.
3) goto 2
4) return the captured information into a variable or another dataset.

I used Rexx infrequently three+ years ago at my former employer, and have not used it since. I am trying to rebuild my knowledge of it. (And to automate some dreadfully mind-numbing tasks which our Parent company insists we do)

Thanks for any help.
 
This is pretty straightforward.

To read the dataset :

address MVS "EXECIO * DISKR INTEXT (STEM INTEXT. FINIS"

DO K = 1 TO intext.0

......... process searches etc

END

To locate a particual string I usually use POS

hit = POS('triggered by',INtext.k,length)
if hit <> 0 then do
.... whatever you need to do if the string exists

end

 
Is it a long dataset? I get the feeling it's pretty short. If it is short, I might just pull the whole thing into a huge string
Code:
"EXECIO * DISKR $IN (FINIS"
do queued()
   pull line 
   whole_thing = Space(whole_thing line,1)
end
and then POS() or WORDPOS() to find what you're looking for (especially if you need to find several things in the string).

Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
I was searching for some rexx utilities to achieve some things similar to what Fountain want to achieve.

Requirement: I have a big PDS(Production source) and I want search this PDS on certain Variables/objects only when they are involved in certian oprtations like move, compute and for objects update or insert.

So what I need to do is fist find that variable or object in the source.
Next, go back upto two lines to see that any of the operational statements like move, compute and for objects update or insert are involved with that Varaible or Object.

If Involved, still goback a little till we find the section or paragrapgh where that statement is available.
(I mean go back till you find a character in the 8th place and also there is no '*' in the 7th place)
also extract the line number where the varaible is involved in the operation.
At the end make a report like this:

Module name Varaible Statement Paragrapgh Line number



Now my questions are:
1. It must be possible to do this in RExx, but that would take very long time considering the huge size of the source PDS(currently Allocated tracks: 14,174) ?

2. I am planning to execute this in Batch mode and also planning to provide an user interface to enter the key words for the users.



Let me tell you, this is currently in conceptual stage. Would appreciate if some one provides their ideas and suggestions for this one.








 
You may want to consider doing this as an ISPF Edit macro. The sorts of operations you are describing are the things edit macros excel at: 'find previous word', 'find picture string', etc.

You may also want to consider doing the operations not on the source code, but rather on the compiler listing, since that will have sections containing much of the information you would otherwise have to generate via your own analysis.



Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
Regarding the original post, I think you want to do something like this (should help shake cobwebs);
Code:
"Alloc Fi(IN) Da('CA7.JCL.DATASET') Shr Reu"
"Execio * DiskR IN (Stem IN. Finis)"
"Free Fi(IN)"
Cnt = 0 ; Drop OUT.
do i = 1 to IN.0
  CurrLine = IN.i
  if index(CurrLine, 'triggered by') > 0 then do
    do until NextLine ^= '' | i > IN.0
      i = i + 1
      NextLine = IN.i
    end
    if i <= IN.0 then do
      Cnt = Cnt + 1
      OUT.Cnt = NextLine
    end
  end
end
"Alloc Fi(OUT) Da('OUT.PUT.DATASET') Shr Reu"
"Execio * DiskW OUT (Stem OUT. Finis)"
"Free Fi(OUT)"
 
Regarding "Welcome10", what I do in situations like this is invoke a PDSMAN scan (you could use ISRSUPC) and then read the results. You're given the member name in the results and just the desired lines so it reduces I/O significantly.

Something like this (I recommend run in ISPF in batch);
Code:
queue "OPTION LISTMEM=N MISSMSG=N WILDCARD=N TRANSLATE=Y"
queue "SCAN TARGET='[COLOR=blue]looking for 1[/color]'"  
queue "SCAN TARGET='[COLOR=blue]looking for 2[/color]'"
queue " "
"Alloc Fi(SYSIN) New Lrecl(80) Tracks Recfm(F B) Space(1 1)"
"Execio * DiskW SYSIN (Finis)"
"Alloc Fi(PDSMPDS) Da('"dsn"') Shr Reu"
"Alloc Fi(PDSMRPT) New Lrecl(132) Cylinders Recfm(F B) Space(100 20)" ,
    "DsOrg(PS)"  
"Alloc Fi(PDSMWK1) New Lrecl(132) Cylinders Recfm(F B) Space(100 20)" ,
    "DsOrg(PS)"  
Address 'ISPEXEC' "Select Pgm(PDSM18)"
"Execio * DiskR PDSMRPT (Stem REPORT. Finis)"
"Free Fi(SYSIN PDSMPDS PDSMRPT PDSMWK1)"
do i = 1 to REPORT.0
  Line = REPORT.i
  select
    when index(Line, 'FOUND FOR MEMBER') then ,
        parse var line . 'FOUND FOR MEMBER' Member .
    when index(line, ' HIT ') = 2 then do
      [COLOR=blue]your actions on found lines[/color]
    end
    otherwise nop
  end
end
 
I'd probably go with rexxhead's suggestion to process the compiler listing. The compiler already has a parser, and it's much better than anything you could write in REXX. If it's COBOL, it has an xref section showing all variables and the line numbers where they are referenced and an indicator to show if they are read or modified by the operation.

Beware of group-level moves (e.g. a move to an 01 level item), as this won't flag up as a modification of the 02-49 levels it may contain.

Another alternative is to turn on the compile ADATA (it's designed to be used by IDEs and debuggers), and generate that, but the format is awful, and documentation on the layout is hard to find.
 
Hi, I would really appreciate all your suggestions on this one. After considering all these, I would prefer to use Rexx on sysout rather than source. I would let the forum know in case of any problems while doing this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top