Searching a string in a ps using JCL



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Searching a string in a ps using JCL

Postby vinodj » Wed Nov 23, 2011 6:28 pm

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?
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searching a string in a ps using JCL

Postby BillyBoyo » Wed Nov 23, 2011 6:34 pm

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).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Searching a string in a ps using JCL

Postby vinodj » Wed Nov 23, 2011 6:45 pm

Yes Billy I have documentation for DFSORT. Trying to search for the solution in it but didn't get anything yet.
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searching a string in a ps using JCL

Postby BillyBoyo » Wed Nov 23, 2011 7:27 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Searching a string in a ps using JCL

Postby Frank Yaeger » Thu Nov 24, 2011 12:02 am

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)                                                 
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Searching a string in a ps using JCL

Postby vinodj » Mon Nov 28, 2011 6:36 pm

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?
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Searching a string in a ps using JCL

Postby BillyBoyo » Mon Nov 28, 2011 7:23 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post