17.10 - COBOLのINMODの例 - MultiLoad

Teradata® MultiLoadリファレンス

Product
MultiLoad
Release Number
17.10
Release Date
2021年6月
Content Type
プログラミング リファレンス
Publication ID
B035-2409-061K-JPN
Language
日本語 (日本)

このINMODの例は、読み取ってから80バイトのレコード文字列を返します。

              //DBCCB1 JOB 1,'DBC',MSGCLASS=A,NOTIFY=DBC,CLASS=B,REGION=4096K
              //COBCOMPL EXEC COBUCL
              //COB.SYSIN DD *
                     IDENTIFICATION DIVISION.
                     PROGRAM-ID. DYNAMN.
                     AUTHOR. JAMES KIM.
                     INSTALLATION. TERADATA.
                     DATE-WRITTEN. 05 SEPTEMBER 1989.
                     DATE-COMPILED.
                     SECURITY. OPEN.
                     REMARKS.
                        THIS PROGRAM IS AN EXAMPLE OF A COBOL INMOD ROUTINE FOR
                        MULTILOAD.
                        FUNCTION: THIS PROGRAM READS AND  RETURNS A RECORD
                                  OF 80 BYTES LONG VIA STRUCT-1 AND STRUCT-2.
                     ENVIRONMENT DIVISION.
                     CONFIGURATION SECTION.
                     SOURCE-COMPUTER. IBM-370.
                     OBJECT-COMPUTER. IBM-370.
                     INPUT-OUTPUT SECTION.
                     FILE-CONTROL.
                         SELECT INMOD-DATA-FILE ASSIGN TO SYSIN-INDATA.
                     DATA DIVISION.
                     FILE SECTION.
                     FD  INMOD-DATA-FILE
                         BLOCK CONTAINS 0 RECORDS
                         LABEL RECORDS STANDARD.
                     01  INPUT-PARM-AREA            PICTURE IS X(80).
                     WORKING-STORAGE SECTION.
                     01  NUMIN                      PICTURE S9(4) COMP VALUE +0.
                     01  NUMOUT                     PICTURE S9(4) COMP VALUE +0.
                     LINKAGE SECTION.
                    *MLOAD COMMUNICATES WITH INMOD VIA STRUCT-1 AND STRUCT-2.
                     01  STRUCT-1.
                         02  RETURN-INDICATE        PIC S9(9) COMP.
                         02  RECORD-LEN             PIC S9(9) COMP.
                         02  RECORD-BODY.
                         03  DATA-AREA1             PIC X(80).
                     01  STRUCT-2.
                         02  SEQ-NUMBER             PIC S9(9) COMP.
                         02  PARM-LIST.
                             05 PARM-LENTH          PIC X(2).
                             05 PARM-STRING         PIC X(80).
                     PROCEDURE DIVISION USING STRUCT-1, STRUCT-2.
                     BEGIN.
                     MAIN.
                         DISPLAY "=============================================="
                         DISPLAY STRUCT-1.
                         DISPLAY STRUCT-2.
                         IF RETURN-INDICATE = 0 THEN
                    *       INMOD INITIALIZATION - OPEN FILE AND READ THE 1ST REC.
                            DISPLAY "INMOD CALLED - RETURN CODE 0 "
                            PERFORM OPEN-FILES
                            PERFORM READ-RECORDS
                            GOBACK
                         ELSE
                         IF RETURN-INDICATE = 1 THEN
                    *       READ A RECORD.
                            DISPLAY "INMOD CALLED - RETURN CODE 1 "
                            PERFORM READ-RECORDS
                            GOBACK
                         ELSE
                         IF RETURN-INDICATE = 5 THEN
                    *       CLOSE INMOD - JUST SEND RETURN CODE = 0
                            DISPLAY "INMOD CALLED - RETURN CODE 5 "
                            MOVE 0 TO RECORD-LEN
                            MOVE 0 TO RETURN-INDICATE
                            GOBACK
                         ELSE
                    *       UNKNOWN CODE.
                            DISPLAY "INMOD CALLED - RETURN CODE X "
                            MOVE 0 TO RECORD-LEN
                            MOVE 16 TO RETURN-INDICATE
                            GOBACK.
                     OPEN-FILES.
                         OPEN INPUT INMOD-DATA-FILE.
                         MOVE 0 TO RETURN-INDICATE.
                     READ-RECORDS.
                         READ INMOD-DATA-FILE INTO DATA-AREA1
                              AT END GO TO END-DATA.
                         ADD 1 TO NUMIN.
                         MOVE 80 TO RECORD-LEN.
                         MOVE 0 TO RETURN-INDICATE.
                         ADD 1 TO NUMOUT.
                     END-DATA.
                         CLOSE INMOD-DATA-FILE.
                         DISPLAY "NUMBER OF INPUT RECORDS  = " NUMIN.
                         DISPLAY "NUMBER OF OUTPUT RECORDS = " NUMOUT.
                         MOVE 0 TO RECORD-LEN.
                         MOVE 0 TO RETURN-INDICATE.
                         GOBACK.
              /*
              //LKED.SYSLMOD DD DSN=JCK.INMOD.LOAD(INMODG1),DISP=MOD
              //LKED.SYSIN  DD *
                 ENTRY DYNAMN
                 NAME INMODG1(R)
              /*
              //*****************************************************************
              //*  NEXT 3 STEPS PREPARE TERADATA DBS FOR THE MULTILOAD'S INMOD  *
              //*  TEST.                                                        *
              //*****************************************************************
              //MLOADDEL  EXEC PGM=IEFBR14
              //MLOADLOG  DD  DSN=JCK.INMOD.TDQ8.MLOADLOG,
              //          DISP=(MOD,DELETE),UNIT=SYSDA,SPACE=(TRK,0)
              //MLOADCAT  EXEC PGM=BLKMAIN
              //SYSPRINT  DD  SYSOUT=*
              //MLOADLOG  DD  DSN=JCK.INMOD.TDQ8.MLOADLOG,DISP=(NEW,CATLG),
              //          UNIT=SYSDA,DCB=(RECFM=F,DSORG=PS,LRECL=8244),
              //          SPACE=(8244,(12,5))
              //SYSIN     DD  *
              //*****************************************************************
              //*  THIS STEP WILL ONLY DROP THE TABLES IF MLOAD NOT IN APPLY    *
              //*  PHASE.                                                       *
              //*****************************************************************
              //CREATE    EXEC BTEQ
              //STEPLIB   DD  DSN=STV.GG00.APP.L,DISP=SHR
              //          DD  DSN=STV.TG00.APP.L,DISP=SHR
              //          DD  DSN=STV.RG00.APP.L,DISP=SHR
              //SYSPRINT  DD  SYSOUT=*
              //SYSABEND  DD  SYSOUT=*
              //SYSIN     DD  DATA,DLM=##
              .LOGON TDQ8/DBC,DBC;
              RELEASE MLOAD XXXX.INMODCB1;
              .IF ERRORCODE = 2572 THEN .GOTO NODROP;
              DROP TABLE XXXX.LOGTABLE;
              DROP TABLE XXXX.ET_INMODCB1;
              DROP TABLE XXXX.UV_INMODCB1;
              DROP TABLE XXXX.WT_INMODCB1
              .QUIT;
              .LABEL NODROP;
              .EXIT 4;;
              DROP USER XXXX;
              ##
              //******************************************************************
              //*                                                                *
              //*    RUN MULTILOAD                                               *
              //*                                                                *
              //******************************************************************
              //LOADIT   EXEC PGM=MLOAD
              //LOADIT   EXEC PGM=MLOAD
              //STEPLIB  DD  DISP=SHR,DSN=JCK.INMOD.LOAD
              //SYSPRINT DD  SYSOUT=*
              //SYSTERM  DD  SYSOUT=*
              //SYSOUT   DD  SYSOUT=*
              //SYSIN    DD  DATA,DLM=##
              .LOGTABLE XXXX.LOGTABLE;
              .LOGON TDQ8/XXXX,XXXX;
              /*  TEST DATAIN, DATALOC          */
              DROP TABLE XXXX.INMODCB1;
              CREATE TABLE INMODCB1 (F1 CHAR(10), F2 CHAR(70));
              .BEGIN IMPORT MLOAD TABLES INMODCB1;
              .Layout layname1;
              .Field L1Fld1 1 Char(10);
              .Field L1Fld2 * Char(70);
              .DML Label DML1;
              INSERT INMODCB1(F1,F2) VALUES (:L1FLD1, :L1FLD2);
              .IMPORT INMOD INMODG1 USING ("AAA" "BBB") LAYOUT LAYNAME1 APPLY DML1;
              .End Mload;
              .LOGOFF;
              ##
              //INDATA  DD DATA,DLM=##
              01COBOL1  AAAAAAAAAAAAAAAA
              02COBOL1  BBBBBBBBBBBBBBBB
              03COBOL1  CCCCCCCCCCCCCCCC
              04COBOL1  DDDDDDDDDDDDDDDD
              ##
              //SELECT   EXEC BTEQ
              //STEPLIB  DD  DSN=STV.GG00.APP.L,DISP=SHR
              //         DD  DSN=STV.TG00.APP.L,DISP=SHR
              //         DD  DSN=STV.RG00.APP.L,DISP=SHR
              //SYSPRINT DD  SYSOUT=*
              //SYSABEND DD  SYSOUT=*
              //SYSIN    DD  DATA,DLM=##
              .LOGON TDQ8/XXXX,XXXX;
              SELECT * FROM INMODCB1;
              .LOGOFF;
              ##
              //