Page 1 of 1

Searching a string in a ps using JCL

PostPosted: Wed Nov 23, 2011 6:28 pm
by vinodj
Hello,

I have a PS like this

------------------
-----------------
mainframe > xxxxxxxxxxxxx
ramesh
suresh
nnnn
end of file

I want to search for the string "mainframe >" (this string is constant) using a JCL and then sort all the following records into another file
so the other file will contain all the following records :
ramesh
suresh
nnnn

Please tell me if this can be done using a JCL and how?

Re: Searching a string in a ps using JCL

PostPosted: Wed Nov 23, 2011 6:34 pm
by BillyBoyo
You can't do it with JCL, you can probably do it with your Sort product, which is a program, and which will use JCL.

Which sort product do you use?

Do you have documentation for the product available? (DFSORT documentation is available on the internet).

Re: Searching a string in a ps using JCL

PostPosted: Wed Nov 23, 2011 6:45 pm
by vinodj
Yes Billy I have documentation for DFSORT. Trying to search for the solution in it but didn't get anything yet.

Re: Searching a string in a ps using JCL

PostPosted: Wed Nov 23, 2011 7:27 pm
by BillyBoyo
I googled for - dfsort after string - and the fourth hit shows you how. Use it, see it works, then use the manual to fully understand how it works, as the technique has many other uses. If you have problems understanding how it works (it does work), let us know.

Re: Searching a string in a ps using JCL

PostPosted: Thu Nov 24, 2011 12:02 am
by Frank Yaeger
vinodj,

You can use a DFSORT job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

//S1 EXEC PGM=SORT                                               
//SYSOUT DD SYSOUT=*                                             
//SORTIN DD *                                                   
------------------                                               
-----------------                                               
mainframe > xxxxxxxxxxxxx                                       
ramesh                                                           
suresh                                                           
nnnn                                                             
//SORTOUT DD SYSOUT=*                                           
//SYSIN DD *                                                     
  OPTION COPY                                                   
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,11,CH,EQ,C'mainframe >'),   
    PUSH=(81:ID=1))                                             
  OUTFIL OMIT=(81,1,CH,EQ,C' ',OR,1,11,CH,EQ,C'mainframe >'),   
    BUILD=(1,80)                                                 
/*

Re: Searching a string in a ps using JCL

PostPosted: Mon Nov 28, 2011 6:36 pm
by vinodj
Hello,

Please tell me if my understanding of this solution is correct :

WHEN=GROUP means we are working on a group of records (so this is input file)
when 'mainframe >' is encounterd in columns 1 to 11 we are assigning an ID to all the subsequent records( in 81st column). We are then omitting the records that have ID blank or those that start with 'mainframe >'
I dont understand why I can't see 81th record. It is not even there. Is there some wrap up?

Re: Searching a string in a ps using JCL

PostPosted: Mon Nov 28, 2011 7:23 pm
by BillyBoyo
Yes, you are correct in your understanding.

If by the 81st record, you mean the 81st byte, the BUILD=(1,80) took care of it - if you want to see it, change the 1,80 to 1,81.

If you meant something else, let us know.