アセンブラのINMODの例 - FastLoad

Teradata® FastLoad リファレンス

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

次の例のINMODは、入力データ ファイルからレコードを読み取り、そのレコードの前に4バイトの整数フィールドを追加します。新しいフィールドには、1から入力レコードの総数までの、連番レコードが入ります。

BULKCON TITLE’-- CONCATENATE INPUT RECORDS FOR INPUT TO FASTLOAD ’
BULKCON CSECT
      USING BULKCON,15
********************************************************************
*  THIS PROGRAM IS CALLED BY THE TERADATA FASTLOAD PROGRAMS        *
*     TO OBTAIN A RECORD TO BE USED TO INSERT, UPDATE, DELETE,     *
*     OR SELECT ROWS OF A DBC TABLE.                               *
*                                                                  *
*  THIS PROGRAM IS NOT REENTRANT.                                  *
*  FUNCTION:                                                       *
*           READ AN INPUT RECORD AND ADD A FOUR-BYTE INTEGER FIELD *
*           THE FRONT OF THE RECORD.  THE NEW FIELD WILL CONTAIN   *
*           A SEQUENCE NUMBER WHICH RANGES FROM 1 TO ...           *
*           NUMBER-OF-INPUT-RECORDS.                               *
*                                                                  *
*           RETURN TO THE CALLER, FASTLOAD, INDICATING             *
*           EITHER MORE RECORDS ARE AVAILABLE OR NO MORE RECORDS   *
*           ARE TO BE PROCESSED.                                   *
*                                                                  *
*  THIS INMOD PROGRAM CAN BE USED TO ENSURE UNIQUE RECORDS         *
*  IN CERTAIN APPLICATIONS, THE SEQUENCE FIELD                     *
*     CAN BE USED FOR “DATA SAMPLING”.                             *
*                                                                  *
*  DDNAME OF THE INPUT DATA SET: “INDATA”                          *
*                                                                  *
********************************************************************
      B    STOREGS                 BRANCH AROUND EP
      DC   AL1(31)                 DEFINE EP LENGTH
      DC   CL9’BULKIN  ’           DEFINE
      DC   CL9’&SYSDATE’           ENTRY
      DC   CL8’   MVS ’            POINT
      DC   CL5’&SYSTIME’           IDENTIFIER
********************************************************************
*                    SAVE REGISTERS                                *
********************************************************************
STOREGS  DS   0H                     DEFINE AND ALIGN SYMBOL
         STM   R14,R12,12(R13)       STORE OFF CALLER’S REGISTERS
         LR    R12,R15               COPY BASE ADDRESS
         DROP  R15                   DROP VOLATILE BASE REGISTER
         USING BULKCON,R12           ESTAB PERM CSECT ADDRBLTY
         LA    R14,SAVEAREA          POINT AT LOCAL SAVE WORK
         ST    R14,8(,R13)           STORE FWD LINK IN SA CHAIN
         ST    R13,4(,R14)           STORE BWD LINK IN SA CHAIN
         LR    R13,R14               COPY LOCAL SAVE/WORK AREA ADDR
         L     R11,0(,R1)            POINT TO PARM
      SPACE 1
********************************************************************
*                VOPEN  “DATA” DATA SET                            *
*                       (ONLY THE FIRST TIME)                      *
********************************************************************
         USING PREBUF,R11              COVER PRE-PROC AREA
         LA    R9,PREREC               POINT TO START OF PREPROC.  DATA
         L     R15,PRECODE             CHECK ON CODE FROM FASTLOAD
                 OC    PRECODE,PRECODE         FIRST ENTRY ? (0=FIRST ENTRY)
         BNZ   NOOPEN                  NO, SKIP OPEN
         USING IHADCB,R10              YES,COVER DCB FOR OPEN
         LA    R10,INDATA              POINT TO DATA DCB
         OPEN  INDATA                  OPEN INPUT DATA SET
         TM    DCBOFLGS,X’10’          DID IT OPEN ?
         BO    OPENOK                  YES,
         WTO   ’UNABLE TO OPEN INDATADATA SET’,ROUTCDE=11
         B     BADRET                  RETURN WITH ERROR CODE
*******************************************************************
*          CHECK FASTLOAD/BULKLOAD STATUS CODES                   *
* 0 =  FIRST ENTRY       (FASTLOAD/BULKLOAD EXPECTS TO RECEIVE A  *
*                         RECORD)                                 *
* 1 =  GET NEXT RECORD   (FASTLOAD/BULKLOAD EXPECTS TO RECEIVE A  *
*                         RECORD)                                 *
* 2 =  Client RESTART CALL (FASTLOAD DOES NOT EXPECT A RECORD)    *
* 3 =  CHECKPOINT CALL   (FASTLOAD DOES NOT EXPECT A RECORD)      *
* 4 =  DBC RESTART CALL  (FASTLOAD DOES NOT EXPECT A RECORD)      *
*                                                                 *
*                                                                 *
*     NOTE: THIS INMOD WAS WRITTEN TO BE COMPATIBLE WITH FASTLOAD *
*           AND BULKLOAD AND THEREFORE CONTAINS INFORMATION ON    *
*           STATUS CODES 2,3, AND 4 WHICH PERTAIN ONLY TO         *
*           FASTLOAD. CODES 2,3, AND 4 ARE NOT HANDLED BY         *
*           THIS PROGRAM.                                         *
*******************************************************************
OPENOK   DS 0H
         MVI  ISPOPEN,1            INDICATE INPUT FILE HAS BEEN OPEN
NOOPEN   L   R15,PRECODE           CHECK ON CODE FROM FASTLOAD
         C     R15,=F’1’           NEED RECORD ?
         BH    NOREC               NO , DO NOT “GET” A RECORD
         L     R15,SAMPNUM         GET CURRENT SAMPLE NUM.
         LA    R15,1(R15)          INCR BY 1
         ST    R15,0(R9)           STORE AT FRONT OF RECORD
         ST    R15,SAMPNUM         RESET COUNTER
         LA    R9,4(R9)            ADVANCE FOR READ ADDR.
         LA    R10,INDATA          COVER INDATA DCB
GETNEXT  GET   INDATA,(R9)            READ A RECORD
INCREC   LH    R9,DCBLRECL          GET RECORD LENGTH
         AH    R9,=H’4’             ADD 4 FOR NEW FIELD
         SR    R15,R15               SET RETURN CODE VALUE
RETURN   ST    R9,PRELEN             SET LENGTH (ZERO AFTER EOF)
         ST    R15,PRECODE
         L     R13,4(,R13)
         RETURN (14,12),RC=0         RETURN
         SPACE
CLEANUP  DS  0H
         CLI   ISOPEN,0              IS INPUT FILE OPEN?
         BE    RETURN                NO - JUST RETURN
         B     EOF                   CLEAN IT UP
         SPACE5
********************************************************************
*        EOF ENTERED AT END-OF-FILE                                *
********************************************************************
EOF      CLOSE INDATA                CLOSE INPUT DATA SET
         MVI   ISOPEN,0              INDICATE FILE NOT OPEN
********************************************************************
NOREC    SR    R15,R15               SET ZERO RETURN CODE
         SR    R9,R9                 SET ZERO LENGTH
         B     RETURN                RETURN
*
BADRET   LA    R15,16               SET RETURN CODE FOR ERROR
         SR    R9,R9                SET LENGTH = 0
         B     RETURN               ERROR RETURN
         EJECT
*
*     CONSTANTS
*
R0       EQU   0
R1       EQU   1
R2       EQU   2
R3       EQU   3
R4       EQU   4
R5       EQU   5
R6       EQU   6
R7       EQU   7
R8       EQU   8
R9       EQU   9
R10      EQU   10
R11      EQU   11
R12      EQU   12
R13      EQU   13
R14      EQU   14
R15      EQU   15
         EJECT
*
*     DATA STRUCTURES AND VARIABLES
*
         SPACE
SAVEAREA DC    18F’0’               SAVE AREA
SAMPNUM  DC    F’0’
ISOPEN   DC    XL1’00’             OPEN FILE INDICATOR
         SPACE 10
INDATA   DCB   DDNAME=INDATA,MACRF=(GM),DSORG=PS,EODAD=EOF
PREBUF   DSECT
PRECODE  DS    F
PRELEN   DS    F
ROWSIZE  EQU   31774    MAXIMUM ROW SIZE
PREREC   DS    0XL(ROWSIZE)
         DCBD  DEVD=DA,DSORG=PS
      END