Skip to content

DBzTech-Technology Dossier

A repository of technical findings.

Menu
  • COBOL
  • DB2
  • SAS
  • JCL
  • Google Cloud
  • AI
Menu

Using SRCHFOR Command in Batch- Search strings in PDS

Posted on September 12, 2025May 17, 2026 by DBZtech

In our daily work, we often use the SRCHFOR command interactively to search for specific text within members of a PDS. For batch processing, IBM provides the ISRSUPC utility, which serves as the batch equivalent of the interactive SuperC search.

When using PARM=(SRCHCMP,'ANYC'), the utility performs a case-insensitive search across dataset members. Here’s what the parameters mean:

  • SRCHCMP: Activates search mode instead of comparison mode, enabling the use of SRCHFOR statements.
  • ANYC: Stands for “Any Case”, allowing matches regardless of letter casing (e.g., error, ERROR, Error will all match).

🧾 Sample JCL

//SEARCH EXEC PGM=ISRSUPC,PARM=(SRCHCMP,'ANYC')
//NEWDD DD DSN=TEST.JCL,DISP=SHR
//OUTDD DD DSN=TEST.OUTPUT.SRCH2,DISP=(NEW,CATLG,DELETE),
// SPACE=(133,(5,5)),
// DCB=(LRECL=133,BLKSIZE=133,RECFM=FB)
//SYSIN DD *
SRCHFOR 'TEXT STRING'
SRCHFOR 'TEXT STRING2'
/*
//STEP02 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTMSG DD SYSOUT=*
//SORTIN DD DSN=TEST.OUTPUT.SRCH2,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(30,6,CH,EQ,C' -----')
OUTREC FIELDS=(1,8)
/*


📄 Explanation of SORT Step

The second step uses DFSORT to scan the output file generated by ISRSUPC. It filters lines containing ' -----' starting at column 30 (often used to mark member headers in SuperC output) and extracts the first 8 characters—typically the member names.

If you want to save the extracted member names to a dataset instead of printing to spool, simply replace SYSOUT=* in SORTOUT with a dataset definition.

©2026 DBzTech-Technology Dossier | Design: Newspaperly WordPress Theme