MainframeSupports
tip week 03/2004:

Many of you will probably wonder why you should execute DFSORT from within the DSN processor. And you will probably ask: is it possible? The answer is yes and the point is that you can code and execute SQL statements in your SORT exit programs using this method. This idea was originally introduced to me by my good friend Johnny Mossin, who is an expert in both DB2 and DFSORT. Here is an example of a job step doing the trick:

//SORTDB2  EXEC PGM=IKJEFT01
//SYSIN    DD *
   OPTION COBEXIT=COB2
   MODS E15=(MYEXIT,160000,MODLIB,C)
   SORT FIELDS=COPY
/*
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=MY.UNSORTED.DATA,DISP=SHR
//SORTOUT  DD DSN=MY.SORTED.DATA,DISP=SHR
//MODLIB   DD DSN=MY.EXIT.LOADLIB,DISP=SHR
//SYSTSIN  DD *
   DSN SYSTEM(DB2)
   RUN PROGRAM(SORT) PLAN(MYPLAN)
   END
/*
//SYSTSPRT DD SYSOUT=*

The program called MYEXIT must be an ordinary COBOL program including SQL statements and coded in the way that COBOL SORT exits must be coded. The DBRM for MYEXIT is created and bound in the usual manner and the resulting package must be in the package list for the DB2 plan MYPLAN. And that is what it takes. The LOAD module for MYEXIT must be located in MY.EXIT.LOADLIB.

If you want to know more about writing SORT exits or just want to know more about DFSORT, you can read it all in the DFSORT R14 Application Programming Guide. The part about SORT exits are in chapter 4.

Previous tip in english        Sidste danske tip        Tip list