Search code examples
mainframejcl

Find the line number of particular record using JCL


I have a input PS file like
aaa1111zzzz
bbb2222bbbb
ccc3333bbbb
ddd3333cccc
eee7777yyyy

I want to know the line number in this input PS file where the word '3333' is present.. output should be something like
3
4
in this scenario

I am looking for a JCL that can do this, I have searched in net, but no luck.


Solution

  • With respect to NicC's answer, I've tried using SORT to attain the expected result.

    //SORT     EXEC PGM=SYNCSORT                                   
    //SORTIN   DD *                                                
    aaa1111zzzz                                                    
    bbb2222bbbb                                                    
    ccc3333bbbb                                                    
    ddd3333cccc                                                    
    eee7777yyyy                                                    
    //SORTOUT  DD SYSOUT=*                                         
    //SYSOUT   DD SYSOUT=*                                         
    //SYSUDUMP DD SYSOUT=*                                         
    //SYSIN DD *                                                   
      INREC FIELDS=(1:SEQNUM,3,ZD,4:1,11)                          
      SORT FIELDS=COPY                                             
      OUTFIL FNAMES=SORTOUT,INCLUDE=(7,4,ZD,EQ,3333),OUTREC=(1:1,3)
    /*