IBM CのOUTMODルーチンの生成 - FastExport

Teradata® FastExport リファレンス

Product
FastExport
Release Number
17.00
Published
2020年6月
Language
日本語
Last Update
2021-01-07
dita:mapPath
ja-JP/ups1544831946863.ditamap
dita:ditavalPath
ja-JP/ups1544831946863.ditaval
dita:id
B035-2410
Product Category
Teradata Tools and Utilities

以下のIBM Cの例は、リリース テープの<dbcpfx>.SAMPLIB (CHKTRANC)にあります。

プロシージャはIBM C exec LC375CLを実行します。LC375CLはソース文をメンバーChktranとしてUSER loadlibにコンパイルします。

OUTMODルーチンの入口点名が_dynamnでないため、LC375CL procにはENTRY=NONEパラメータが必要です。連係編集に際してもENTRYパラメータの指定が必要です。LC375CL procはこのパラメータを生成しないためです。

//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)
      ##