Search code examples
zosjcl

search if string from a pds is present in another pds


I have a pds (say A) having jobnames (superset). I have another pds (say B) having lesser number of jobnames (subset).

best way to find a A-B into another file C using JCL ?


Solution

  • Try using SYNCORT JOINKEYS, this example is pretty much what you need. The JCL below is a specific example. AF1 is the Superset file (A) containing all job names, AF2 is the Subset file (B). SORTOUT will contain the difference (A-B).

    //MYJOB   JOB Whatever your job card needs
    //AMINUSB    EXEC  PGM=SYNCSORT,PARM='INCORE=OFF'
    //AF1  DD *                 Superset file 'A'
    J000001
    J000002
    J000003
    J000004
    J000005
    J000006
    J000007
    J000008
    J000009
    J000010
    J000011
    J000012
    /*
    //BF2  DD *                  Subset file 'B'
    J000001
    J000003
    J000004
    J000008
    J000010
    J000011
    /*
    //SORTOUT    DD SYSOUT=*    'A' - 'B'
    //*
    //SORTMSG   DD SYSOUT=*
    //SYSOUT    DD SYSOUT=*
    //CEEDUMP   DD SYSOUT=*
    //STATOUT   DD SYSOUT=*
    //SYSIN     DD *
      JOINKEYS FILE=F1,FIELDS=(1,7,A)
      JOINKEYS FILE=F2,FIELDS=(1,7,A)
      JOIN UNPAIRED,F1,ONLY
      REFORMAT FIELDS=(F1:1,7)
      OPTION COPY
      END
    /*
    

    If you run this, SORTOUT will contain the following data:

    J000002 
    J000005 
    J000006 
    J000007 
    J000009 
    J000012 
    

    Note: You will have to refomat the JOB card to whatever your installation requires. The rest should work pretty much as illustrated.