Page 1 of 3

Search a string in PDS with 2 lines prior & after.

PostPosted: Wed Mar 16, 2016 3:49 pm
by Raja190
Hi,

I need to find a string in members of a PDS and want to strip the lines in to spool with program names. I got the expected results using below job but I want to have results with n lines prior and after with specific to search string.


Example:

this is line number 1
this is line number 2
this is line number 3
this is line number 4
this is line number 5
this is line number 6


Expected result.

Srchfor 'line3' with 2 lines prior and after

this is line number 2
this is line number 3
this is line number 4
this is line number 5
this is line number 6


//SRCHFOR JOB (,,time,lines),'your name',CLASS=class
// EXEC PGM=ISRSUPC,
//NEWDD DD DSN=your.data.set.name,DISP=OLD
//OUTDD DD SYSOUT=*
//SYSIN DD *
SRCHFOR 'string1'
/*


Could you please help me to find a option for it.



Thanks
Raja.R

Re: Search a string in PDS with 2 lines prior & after.

PostPosted: Wed Mar 16, 2016 5:31 pm
by NicC
Could you please help me to find a option for it


No - once again you have posted without using the code tags despite having been requested to do so. Why should we help you if you do not help us to help you?

Also, your inout and expected results do not match with what you wrote.

Re: Search a string in PDS with 2 lines prior & after.

PostPosted: Wed Mar 16, 2016 5:49 pm
by Raja190
let me rephrase the expected result.

Input:

this is line number 1
this is line number 2
this is line number 3
this is line number 4
this is line number 5
this is line number 6



Expected result.

Srchfor 'line4' with 2 lines prior and after

this is line number 2
this is line number 3
this is line number 4
this is line number 5
this is line number 6

Re: Search a string in PDS with 2 lines prior & after.

PostPosted: Wed Mar 16, 2016 6:43 pm
by Terry Heinze
And where are the code tags Nic requested?

Re: Search a string in PDS with 2 lines prior & after.

PostPosted: Wed Mar 16, 2016 6:55 pm
by Raja190
//SRCHFOR JOB (,,time,lines),'your name',CLASS=class
// EXEC PGM=ISRSUPC,
//NEWDD DD DSN=your.data.set.name,DISP=OLD
//OUTDD DD SYSOUT=*
//SYSIN DD *
  SRCHFOR 'string1'
/*


Code'd and silly line numbers removed.

Re: Search a string in PDS with 2 lines prior & after.

PostPosted: Wed Mar 16, 2016 7:57 pm
by Akatsukami
Two requests for Code tags ignored. One more and I lock this thread :x

Re: Search a string in PDS with 2 lines prior & after.

PostPosted: Wed Mar 16, 2016 8:59 pm
by Terry Heinze
Raja190,
Click on PostReply, click the Code button, backspace the cursor to between the ] and the [, key in some JCL, click Preview. If it looks the way you want it, click Submit. An example follows:
JCL goes here
1
 2
  3

Re: Search a string in PDS with 2 lines prior & after.

PostPosted: Thu Mar 17, 2016 12:12 am
by Raja190
Terry,

I have given tags for each JCL lines, I'm not sure what else you are expecting.

Re: Search a string in PDS with 2 lines prior & after.

PostPosted: Thu Mar 17, 2016 12:39 am
by BillyBoyo
What do you mean by "tags"? I've Code'd your previous one for you. If you click on Quote, you can see what I've done. That is what is meant by the code tags.

Re: Search a string in PDS with 2 lines prior & after.

PostPosted: Thu Mar 17, 2016 1:17 am
by Terry Heinze
Raja190,
Read my post of 10:29 again. I gave explicit instructions on how to use Code tags.