Generate an IBM C OUTMOD Routine - FastExport

Teradata® FastExport Reference

Product
FastExport
Release Number
16.20
Published
September 2020
Language
English (United States)
Last Update
2020-09-11
dita:mapPath
lki1527114222329.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
B035-2410
lifecycle
previous
Product Category
Teradata Tools and Utilities

The following IBM C example is in <dbcpfx>.SAMPLIB (CHKTRANC) on the release tape.

The procedure executes the IBM C exec LC375CL, which compiles the source statements into the USER loadlib as member Chktran.

The ENTRY=NONE parameter to the LC375CL proc is required because the entry point name of the OUTMOD routine is not _dynamn. The ENTRY parameter to the linkedit is also required because the LC375CL proc does not generate such a parameter.

//USEREXP   JOB (20750000),'USERNAME',MSGCLASS=A,NOTIFY=USER,
//             CLASS=B,MSGLEVEL=(1,1),REGION=5120K
//CCOMPL  EXEC LC375CL,ENTRY=NONE
//C.SYSIN   DD DATA,DLM=##
      /* TITLE CHKTRAN ... Output procedure for TranLogTable export run  */
      /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
      /*                                                                 */
      /* Purpose   This procedure is called by the Teradata FastExport   */
      /*           utility for each response row returned to the host.   */
      /*           The procedure examines each row to determine if the   */
      /*           row should be output to an error data set and then    */
      /*           either dropped or written to the standard data set.   */
      /*           One error data sets contain records with a null       */
      /*           region code the other contains records with a total   */
      /*           sales value less than $100.  These latter records     */
      /*           are not written to the standard data set.             */
      /*                                                                 */
      /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
      #include <stdio.h>
      #define chkbit(a,b) (((0x80 >> (b-1)) & (a)) ? 1 : 0)
      /* Define the structure of the response row */
      struct tranlog
       {
      char     Indicators;
      char     Region[3];
      char     Product[8];
      long     Qty;
      long     Price;

                                                                              
       } ;#define minsale     100    /* minimum sales to report */
      FILE *file1, *file2;
      int  chktran(EntryType, StmtNo,
                   RespLen, RespRec,
                   OutLen, OutRec)
      int         *EntryType;
      int         *StmtNo;
      int         *RespLen;
      struct tranlog*RespRec;
      int         *OutLen;
      char        *OutRec;
      {
      long recsize;
      struct tranlog recout;
      /* case on entry type */
      switch (*EntryType) {
      case 1:
         /* Normal start */
         file1 = fopen(“ddn:file1out”, “wb”);
         file2 = fopen(“ddn:file2out”, “wb”);
         break;
      case 2:
         /* EOF for response data */
         fclose(file1);
         fclose(file2);
         break;
      case 3:
         /* Process response record */
         if ((RespRec->Qty * RespRec->Price) < minsale)
           {
            *RespLen = 0;
            recout = *RespRec;
            recsize = fwrite(&recout, sizeof(recout), 1, file1);
           }
         else
           {
           /* If the region is null then change it to a dummy region.
           */ if (chkbit(RespRec->Indicators,1))
              {
                  RespRec->Region[1] = '9';
                  RespRec->Region[2] = '9';
                  RespRec->Region[3] = '9';
                  recout = *RespRec;
                  recsize = fwrite(&recout, sizeof(recout), 1, file2);
               }
           }
            break;
      case 4:
         /* no checkpoints to worry about */
         break;
      case 5:
         /* DBC restart - close and reopen the output files */
         file1 = freopen("ddn:file1out", "wb", file1);
         file2 = freopen("ddn:file2out", "wb", file2);
         break;
      case 6:
         /* Host restart same as normal since there are no checkpoints */
         file1 = fopen("ddn:file1out", "wb");
         file2 = fopen("ddn:file2out", "wb");
         break;
      default:
         printf("Invalid entry code = %d\n", *EntryType);
         break;
      }
      return(0);
      }
      ##
      //LKED.SYSLMOD DD DSN=USER.LIB.LOAD(CHKTRAN),DISP=MOD
      //LKED.SYSIN DD DATA,DLM=##
      MODE AMODE(24) RMODE(24)
      ENTRY CHKTRAN
      NAME CHKTRAN(R)
      ##