17.00 - PL/I INMOD  - Parallel Data Pump

Teradata® Parallel Data Pump Reference

prodname
Parallel Data Pump
vrm_release
17.00
created_date
June 2020
category
Programming Reference
featnum
B035-3021-220K
//SFDPL2 JOB (22150000),’SFD’,MSGCLASS=A,CLASS=B,
// 	REGION=4096K 
//***************************************************************** 
//*                                                               * 
//*      IDENTIFY NECESSARY LOAD LIBRARIES FOR RELEASE            * 
//*                                                               * 
//***************************************************************** 
//JOBLIB  DD DSN=STV.EI80GNR.APP.L,DISP=SHR
// DD DSN=TER2.SASC450F.LINKLIB,DISP=SHR
//STEP1    EXEC ASMFC 
//ASM.SYSGO DD DSN=&&LOADSET1,DISP=(MOD,PASS),UNIT=VIO, 
//       SPACE=(880,(500,100),,,ROUND) 
//ASM.SYSIN DD * 
PLIA     TITLE ’TPump INTERFACE TO PL/I EXIT ROUTINE’ 
DYNAMN   CSECT
         CNOP  0,4
         B     START-*(,R15)            BRANCH AROUND CONSTANTS
         DC    AL1(L’PLIAFLAG)          LENGTH OF CONSTANTS
PLIAFLAG DC    C’ASSEMBLED AT &SYSTIME ON &SYSDATE.. BLKPLIA’
*-----------------------------------------------------------------*
*                                                        G1_01    * 
*                                                                 * 
* ON ENTRY: R1 -> PARAMETER LIST                                  * 
*           PARM 1 -> MULTI-FIELD RECORD                          * 
*                 FIELD 1: COMMAND CODE/RETURN CODE               * 
*                          (32 BIT INTEGER)                       * 
*                          0 = INITIAL CALL                       * 
*                          1 = RECORD CALL                        * 
*                          2 = HOST RESTART - ALSO INITIAL CALL   *
*                          3 = CHECKPOINT                         * *                          4 = DBC RESTART                        * 
*                          5 = FINAL CALL                         * 
*                          6 = W/ INFILE  -  ALSO INITIAL CALL    *
*                          7 = RECEIVE RECORD CALL                *
*                 FIELD 2: DATA RECORD LENGTH                     * 
*                          (32 BIT INTEGER)                       * 
*                 FIELD 3: DATA RECORD                            * 
*                          (UP TO 31K BYTES)                      * 
*           PARM 2 -> EXIT ROUTINE WORK WORD                      *  
*                          (32 BIT INTEGER)                       * 
*                                                                 * 
*                                                                 * 
* OPERATION:                                                      * 
*    INITIAL CALL:                                                * 
*       1) BULK LOADER   LOADS THIS MODULE AND CALLS              * 
*       2) BLKPLIA (THIS PROGRAM) WHICH CALLS                     * 
*       3) BLKPLI (PL/I PROGRAM TO ESTABLISH PL/I ENVIRONMENT)    *
*          WHICH CALLS                                            * 
*       4) BLKASM (ENTRY POINT IN THE PROGRAM) WHICH CALLS        * 
*       5) BLKEXIT (USER EXIT PROGRAM IN PL/I).                   * 
*       UPON RETURN:                                              * 
*       1) BLKEXIT RETURNS TO                                     * 
*       2) BLKASM WHICH PERFORMS MAGIC AND RETURNS DIRECTLY TO    * 
*       3) BULK LOADER, THEREBY PRESERVING THE PL/I ENVIRONMENT   * 
*          FOR SUBSEQUENT CALLS.                                  * 
*    RECORD CALL:                                                 * 
*       1) BULK LOADER CALLS                                      * 
*       2) BLKPLIA WHICH REVERSES THE MAGIC AND BRANCHES INTO     * 
*       3) BLKASM WHICH CALLS                                     * 
*       4) BLKEXIT WITH THE PL/I ENVIRONMENT SAVED BEFORE.        * 
*       UPON RETURN:                                              * 
*       1) BLKEXIT RETURNS TO                                     * 
*       2) BLKASM WHICH PERFORMS MAGIC AND RETURNS DIRECTLY TO    * 
*       3) BULK LOADER, THEREBY PRESERVING THE PL/I ENVIRONMENT   * 
*          FOR SUBSEQUENT CALLS.                                  * 
*                                                                 * 
*-----------------------------------------------------------------*
START    SAVE  (14,12)
         LR    R11,R15                  -> PROGRAM ENTRY POINT
         USING DYNAMN,R11
         L     R2,4(,R1)                -> EXIT ROUTINE WORD
         L     R3,0(,R1)                -> COMMAND WORD
         L     R3,0(,R3)                COMMAND WORD
         CH    R3,=H’0’                 INITIAL CALL?
         BE    INITCALL                 YES , DO INITIAL CODE
         CH    R3,=H’6’                 INITIAL CALL?
         BE    INITCALL                 YES , DO INITIAL CODE
         CH    R3,=H’2’                 INITIAL CALL?
         BNE   CALLPGM                  NO, JUST GO CALL PROGRAM
*-----------------------------------------------------------------* 
*    SETUP WORK AREA AND PL/I ENVIRONMENT                         * 
*-----------------------------------------------------------------*
INITCALL LA    R0,WORKALEN
         SR    R1,R1
         L     R15,=V(DBCMEM)
         BALR  R14,R15
         ST    R1,0(,R2)                SAVE WORKAREA ADDRESS
         ST    R1,WORKADDR              SAVE WORKAREA ADDRESS
         LR    R10,R1                   -> CURRENT WORK AREA
         USING WORKAREA,R10
         SPIE  MF=(E,NOSPIE)            CLEAR PASCAL INTERRUPT EXIT  
         ST    R1,SPIEPAS               SAVE PASCAL SPIE 
         MVC   WRKFLAG,WRKFLAGP         IDENTIFY WORK AREA
         XC    SAVE1(12),SAVE1          CLEAR START OF SAVEAREA
         LA    R1,SAVE1                 INITIAL PROGRAM SAVE AREA
         ST    R13,4(,R1)               BACK CHAIN SAVE AREAS
         ST    R1,8(,R13)               FORW CHAIN SAVE AREAS
         LR    R13,R1                   -> NEW SAVE AREA
         ST    R3,COMMAND               KEEP COMMAND FOR LATER
         LA    R1,PLIPARM               -> STARTUP PARAMETERS
         L     R15,=V(PLISTART)         PL/I SETUP ENTRY POINT
         BALR  R14,R15                  CALL PL/I SETUP PROGRAM
*-----------------------------------------------------------------* 
*    FINAL RETURN FROM PL/I: FREE WORKAREA AND RETURN             * 
*-----------------------------------------------------------------*
         L     R1,SPIEPAS               -> PASCALVS SPIE
         SPIE  MF=(E,(1))               RESTORE PASCALUS SPIE  
         L     R13,4(,R13)              BACK UP SAVE AREA CHAIN
         LR    R1,R10
         LA    R0,WORKALEN
         L     R15,=V(DBCMEM)
         BALR  R14,R15
         DROP  R10                      WORKAREA
RETURN   XR    R15,R15                  INDICATE ALL IS WELL
         ST    R15,16(,R13)             SET CALLER’S RETURN CODE
         RETURN (14,12)                 RETURN TO CALLER
*-----------------------------------------------------------------* 
*    REESTABLISH PL/I ENVIRONMENT AND CALL USER                   * 
*-----------------------------------------------------------------*
 ALLPGM  L     R10,0(R2)                -> WORK AREA
CALLPGM  L     R10,WORKADDR             -> WORK AREA
         USING WORKAREA,R10
         ST    R3,COMMAND               KEEP COMMAND FOR LATER
         LR    R3,R1                    SAVE -> PARMS FOR LATER
         LA    R1,SAVE1                 -> BLKPLIA SAVE AREA
         ST    R13,4(,R1)               REBUILD BACK CHAIN
         ST    R1,8(,R13)               REBUILD FORW CHAIN
         LM    R12,R13,SAVE2            REESTABLISH PL/I ENVIRONMENT
         B     AGAIN                    CALL EXIT ROUTINE
         DROP  R10                      WORKAREA
         DROP  R11                      BLKPLIA
*-----------------------------------------------------------------* 
*    PL/I CALLS HERE WITH CORRECT ENVIRONMENT                     * 
*-----------------------------------------------------------------*
         ENTRY BLKASM
BLKASM   B     ASMSTART-*(,R15)         BRANCH AROUND CONSTANTS
         DC    AL1(L’ASMFLAG)           LENGTH OF CONSTANTS
ASMFLAG  DC    C’BLKASM’ 
ASMSTART SAVE  (14,12)                  SAVE BLKPLI REGISTERS
         LR    R11,R15                  ADDRESS PROGRAM 
         USING BLKASM,R11 
         SPIE  MF=(E,NOSPIE))           CLEAR PASCAL INTERRUPT EXIT  
         LR     R4,R1                   HOLD PL/I SPIE FOR LATER
*-----------------------------------------------------------------* 
*    PREPARE PROPER PL/I DSA FOR FURTHER MURGLING                 * 
*-----------------------------------------------------------------*
         LA    R0,88                    LENGTH OF NEW DSA
         L     R1,76(,R13)              -> FIRST AVAILABLE STORAGE
         ALR   R0,R1                    -> POSSIBLE END + 1
         CL    R0,12(,R12)              ENOUGH ROOM FOR NEW DSA?
         BNH   ENOUGH                   YES, GO USE IT
         L     R15,116(,R12)            NO, POINT TO OVERFLOW ROUTINE
         BALR  R14,R15                    AND CALL IT
ENOUGH   ST    R0,76(,R1)               NEW FIRST AVAILABLE STORAGE
         ST    R13,4(,R1)               BACK CHAIN SAVE AREAS
         MVC   72(4,R1),72(R13)         COPY LIB WORKSPACE ADDRESS
         LR    R13,R1                   ADDRESS NEW DSA
         MVI   0(R13),X’80’             SET FLAGS IN DSA TO
         MVI   1(R13),X’00’               PRESERVE PL/I
         MVI   86(R13),X’91’              ERROR HANDLING
         MVI   87(R13),X’C0’              IN THE ASSEMBLER ROUTINE
*-----------------------------------------------------------------* 
*    CALL USER PL/I ROUTINE WITH ORIGINAL BULK PARMS              * 
*-----------------------------------------------------------------*
         L     R2,4(,R13)               -> REGISTERS TO BLKASM
         L     R2,4(,R2)                -> PREVIOUS REGISTERS
         L     R2,4(,R2)                -> REGISTERS TO BLKPLI
         L     R2,4(,R2)                -> REGISTERS TO BLKPLIA
         L     R3,24(,R2)               -> PARMS TO BLKPLIA
         L     R1,4(,R3)                -> EXIT ROUTINE WORD
         L     R10,0(,R1)               -> WORK AREA   
         L     R10,WORKADDR             -> WORK AREA.G1_01.
         USING WORKAREA,R10
         CLC   WRKFLAG,WRKFLAGP         DID IT WORK?
         BE    GOODWRK                  YES, USE IT
         ABEND 1,DUMP                   NO, ABEND RIGHT HERE
GOODWRK  STM   R12,R13,SAVE2            SAVE PL/I ENVIRONMENT
         ST    R4,SPIEPLI                SAVE PL/I SPIE 
         L     R11,16(,R2)              -> BLKPLIA ENTRY POINT 
         DROP  R11                      BLKASM
         USING DYNAMN,R11
  AIN    L     R1,SPIEPLI               -> PLI SPIE
         SPIE  MF=(E,(1))               RESTORE PL/I SPIE
AGAIN    XR    R5,R5                    MUST BE ZERO CALLING PL/I
         OI    4(R3),X’80’              LAST PARAMETER       .G1_01.
         LR    R1,R3                    RESTORE ORIGINAL R1  .G1_01.
         L     R15,=V(BLKEXIT)          -> USER ROUTINE
         BALR  R14,R15                  CALL USER
*-----------------------------------------------------------------* 
*    CHECK WHETHER OR NOT TO HOLD PL/I ENVIRONMENT                * 
*-----------------------------------------------------------------*
         L     R1,SPIEPAS               -> PASCALVS SPIE
         SPIE  MF=(E,(1))               RESTORE PASCALVS SPIE
         L     R13,SAVE1+4              RETURN AROUND PL/I 
         B     RETURN                   GO PERFORM RETURN 
         DROP  R10                      WORKAREA 
         DROP  R11                      BLKPLIA 
         LTORG 
         SPACE 2
NOSPIE   SPIE  MF=L 
         SPACE 2
STRUC    DC    F’0’                     OFFSET OF FIRST ELEMENT 
         DC    F’4’                     OFFSET OF SECOND ELEMENT 
         DC    F’8’                     OFFSET OF THIRD ELEMENT 
         DC    Y(31*1024,0)             31K FIXED LENGTH STRING 
         SPACE 2
PLIPARM  DC    A(*+4+X’80000000’)       -> PL/I INITIAL ARGUMENT
         DC    Y(L’PLIARG)              LENGTH OF PL/I INITIAL ARGUMENT
PLIARG   DC    C’NOSTAE/’             DISABLE ERROR RECOVERY
         SPACE 2
WORKADDR DS    F                        ADDRESS FOR WORKAREA .G1_01.
WRKFLAGP DC    C’BLKPLIA WORK AREA’
         DC    CL(((*-WRKFLAGP+7)/8*8)(*WRKFLAGP))’ ’  FILL TO DWORD
WRKFLAGL EQU   *-WRKFLAGP
         SPACE 2
WORKAREA DSECT
WRKFLAG  DS    CL(WRKFLAGL)
SAVE1    DS    18F                      SAVE AREA FOR BULKPLI
COMMAND  DS    F
SAVE2    DS    2F
SPIEPAS  DS    F
SPIEPLI  DS    F
EXITPRM  DS    A
AGGLOC   DS    2A
         DS    0D                       ALIGN END OF WORK AREA
WORKALEN EQU   *-WORKAREA
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
         END   DYNAMN
/* 
//STEP2    EXEC PLIXC 
//PLI.SYSLIN DD DSN=&&LOADSET2,DISP=(MOD,PASS),UNIT=VIO, 
//       SPACE=(80,(250,100)) 
//PLI.SYSIN  DD DATA,DLM=##
 BLKPLI: /* BULK LOADER INTERFACE TO PL/I USER EXIT ROUTINE */
   PROC OPTIONS (MAIN);
/* THIS PROGRAM IS CALLED BLKPLIA (THE SPECIAL EXIT ROUTINE ENTRY */
/* POINT PROGRAM, WRITTEN IN ASSEMBLER).                          */
/* IT THEN CALLS BLKASM (ANOTHER ENTRY POINT IN BLKPLIA).         */
   DCL BLKASM ENTRY; 
   CALL BLKASM; 
   END;
## 
//STEP3    EXEC PLIXCL 
//PLI.SYSIN  DD DATA,DLM=##
 BLKEXIT: PROCEDURE (X,Y); 
 /* ONLY BLKEXIT ACCEPTED HERE. */ 
DCL  X FIXED,
     Y FIXED;
 DCL   1 PARM_LIST ALIGNED BASED(P), 
         10 STATUS       FIXED BINARY (31,0), 
         10 RLENGTH      FIXED BINARY (31,0), 
         10 BUFFER       CHAR(80);
 DCL   1 PARM_PARM2 ALIGNED BASED(Q), 
         10 SEQ          FIXED BINARY (31,0), 
         10 LEN          FIXED BINARY (15,0), 
         10 PARAMETER    CHAR(80);
 DCL  COUNT STATIC FIXED BINARY (31,0),
      INSROWS STATIC FIXED BINARY (31,0),
      REJROWS STATIC FIXED BINARY (31,0;
 DCL   I,NOTMATCH FIXED BINARY (31,0); 
 DCL   ADDR BUILTIN; 
 DCL   SUBSTR BUILTIN; 
 P=ADDR(X); 
 Q=ADDR(Y); 
 DISPLAY(’### INSIDE PL/I INMOD ROUTINE...’); 
 DISPLAY(P->STATUS); 
 DISPLAY(P->RLENGTH); 
 DISPLAY(P->BUFFER); 
 DISPLAY(Q->SEQ); 
 DISPLAY(Q->LEN); 
 DISPLAY(Q->PARAMETER);
 SELECT (P->STATUS);
 WHEN (6) DO; /* Initialize */
           COUNT=0;
           REJROWS=0;
           INSROWS=0;
           P->STATUS=0;
          END;
 WHEN (7) DO; /* Process */
DISPLAY('Processing...');
           COUNT=COUNT+1;
           NOTMATCH=0;
           P->STATUS =0;
           DO I = 1 TO Q->LEN;
              IF SUBSTR(P->BUFFER,I,1) ^= SUBSTR(Q->PARAMETER,I,1)
                  THEN DO;
                        NOTMATCH = 1;
                        LEAVE; END;
           END;
           IF NOTMATCH = 1
              THEN DO;
                     DISPLAY('------> REJECTED <--------');
                     REJROWS = REJROWS +1;
                     P->RLENGTH = 0;
           END;
              ELSE DO;
                     DISPLAY('------> accepted <--------');
                     INSROWS = INSROWS +1;
                   END;
          END;
 WHEN (5) DO; /* Finalizing */
           DISPLAY('Finalizing...');
           P->STATUS=0;
          END;
 OTHERWISE DO;
           DISPLAY('UNKNOWN CODE...');
           P->STATUS=99;
           END;
 END;
 DISPLAY('P->STATUS=');DISPLAY(STATUS); DISPLAY('P->RLENGTH=');DISPLAY(RLENGTH);
 DISPLAY('TOTAL  =');DISPLAY(COUNT);
 DISPLAY('INSERTS=');DISPLAY(INSROWS);
 DISPLAY('REJROWS=');DISPLAY(REJROWS);
 DISPLAY('--------------------------------------------------------');
 END BLKEXIT;
##
//LKED.SYSIN DD  *
 INCLUDE BLKPLI
 INCLUDE BLKPLIA
 INCLUDE CLILIB(DBCMEM)
 ENTRY DYNAMN
 NAME INMDPL2(R)
/*
//LKED.BLKPLIA DD DSN=*.STEP1.ASM.SYSGO,DISP=(OLD,PASS),
//        VOL=REF=*.STEP1.ASM.SYSGO
//LKED.BLKPLI  DD DSN=*.STEP2.PLI.SYSLIN,DISP=(OLD,PASS),
//        VOL=REF=*.STEP2.PLI.SYSLIN
//LKED.CLILIB  DD  DISP=SHR,DSN=STV.RG20APP.APP.L,UNIT=3380,
//          VOLUME=SER=CNFG03
//COPY EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=*
//SYSUT2 DD DISP=(NEW,PASS),DSN=&&TEMP,UNIT=SYSDA,
//          DCB=(LRECL=80,BLKSIZE=1760,RECFM=FB),
//          SPACE=(CYL,(1,1),RLSE)
//SYSUT1 DD DATA,DLM=@@
("SASC") A0000000000000000000000000000A                                        ("PASC")  A0000000000000000000000000000A
("COBOL") A0000000000000000000000000000A                     
("ASSEM") A0000000000000000000000000000A
("SASC")  B1111111111111111111111111111B
("PASC")  B1111111111111111111111111111B
("COBOL") B1111111111111111111111111111B
("ASSEM") B1111111111111111111111111111B
("SASC")  C2222222222222222222222222222C
("PASC")  C2222222222222222222222222222C
("COBOL") C2222222222222222222222222222C
("ASSEM") C2222222222222222222222222222C
("PL/I")  C2222222222222222222222222222C
("SASC")  D3333333333333333333333333333D
("PASC")  D3333333333333333333333333333D
("PL/I")  D3333333333333333333333333333D
("SASC")  E4444444444444444444444444444E
("PASC")  E4444444444444444444444444444E
("PL/I")  E4444444444444444444444444444E
("SASC")  F5555555555555555555555555555F
("PASC")  F5555555555555555555555555555F
("PL/I")  F5555555555555555555555555555F
@@  
//**********************************************************************
//* THIS STEP WILL ONLY DROP THE TABLES IF TPump IS NOT IN APPLY PHASE *
//**********************************************************************
//CREATE   EXEC BTEQ 
.LOGON TDP5/DMD,DMD;
/* INMOD TEST CASE II - PL/I      */
RELEASE TPump DMD.INMODPL2;
.IF ERRORCODE = 2572 THEN .GOTO NODROP;
DROP TABLE DMD.LOGTABLE;
DROP TABLE DMD.ET_INMODPL2;
DROP TABLE DMD.UV_INMODPL2;
DROP TABLE DMD.WT_INMODPL2; 
DROP TABLE DMD.INMODPL2;
.QUIT;
.LABEL NODROP;
.EXIT 4;
CREATE TABLE INMODPL2 (F1 CHAR(10), F2 CHAR(70)); 
##
//***************************************************************** 
//*                                                               * 
//*   RUN TPump                                                   * 
//*                                                               * 
//***************************************************************** 
//LOADIT   EXEC PGM=TPump,TIME=(,3)
//STEPLIB  DD  DSN=STV.RG20.APPLOAD,DISP=SHR
//         DD  DSN=STV.EG14MLL1.APP.L,DISP=SHR
//         DD  DSN=STV.TG13BLD.APP.L,DISP=SHR
//         DD  DSN=TER2.SASC450F.LINKLIB,DISP=SHR
//         DD  DSN=*.STEP3.LKED.SYSLMOD,DISP=(OLD,PASS),
//        VOL=REF=*.STEP3.LKED.SYSLMOD
//SYSPRINT DD  SYSOUT=*
//SYSTERM  DD  SYSOUT=*
//SYSOUT   DD  SYSOUT=*
//INDATA  DD DISP=OLD,DSN=*.COPY.SYSUT2,DCB=(LRECL=80,RECFM=F),
//       VOL=REF=*.COPY.SYSUT2
//SYSIN    DD  DATA,DLM=##
.LOGON TDP5/DMD,DMD;
.LOGTABLE DMD.LOGTABLE_SFD;
.BEGIN LOAD TABLES INMODPL2; 
.Layout layname1; 
.Field L1Fld1 1 Char(10); 
.Field L1Fld2 * Char(30);
.Field L1Fld3 * Char(40); 
.DML Label DML1; 
INSERT INMODPL2(F1,F2) VALUES (:L1FLD1, :L1FLD2); 
.IMPORT INFILE INDATA
 INMOD INMDPL2 USING (“PL/I”) LAYOUT LAYNAME1 APPLY DML1; 
.End LOAD; 
.LOGOFF; 
## 
C INMOD -  z/OS 
//JCKLC1 JOB 1,’JCK’,MSGCLASS=A,NOTIFY=JCK,CLASS=B,
REGION=4096K
//******************************************************************
//*                                                                *
//*      IDENTIFY NECESSARY LOAD LIBRARIES FOR RELEASE             *
//*                                                                *
//******************************************************************
//JOBLIB   DD  DISP=SHR,DSN=STV.GG10.APP.L
//         DD  DISP=SHR,DSN=STV.GG00.APP.L
//         DD  DISP=SHR,DSN=STV.TG00.APP.L
//         DD  DISP=SHR,DSN=STV.RG00.APP.L
//         DD  DISP=SHR,DSN=TER2.SASC301H.LINKLIB
//C        EXEC PGM=LC370B

//STEPLIB  DD DSN=TER2.SASC301H.LOAD,DISP=SHR
//         DD DSN=TER2.SASC301H.LINKLIB,DISP=SHR
//SYSTERM  DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUT1   DD UNIT=SYSDA,SPACE=(TRK,(10,10))
//SYSUT2   DD UNIT=SYSDA,SPACE=(TRK,(10,10))
//SYSLIN   DD DSN=&&OBJECT,SPACE=(3200,(10,10)),DISP=(MOD,PASS),
//           UNIT=SYSDA
//SYSLIB   DD DSN=TER2.SASC301H.MACLIBC,DISP=SHR
//SYSDBLIB DD DSN=&&DBGLIB,SPACE=(4080,(20,20,1)),DISP=(,PASS),
//           UNIT=SYSDA,DCB=(RECFM=U,BLKSIZE=4080)
//SYSTMP01 DD UNIT=SYSDA,SPACE=(TRK,25)    VS1 ONLY
//SYSTMP02 DD UNIT=SYSDA,SPACE=(TRK,25)     VS1 ONLY
//SYSIN DD DATA,DLM=##
/* This program is for TPump INMOD testing using C user exit routine.
   When this routine is activated it looks at the content of the
   function code passed (a->code) and depending on its value, it
   0) initializes, i.e., opens a file, etc...
   1) reads a record
   5) acknowledges “close inmod” request.  The user exit routine
   must return “return code”(a->code)  and “length” (a->len). You
   should send return code = zero when no errors occur and non-zero for
   an error. TPump expects length = zero at the end of file. Then
   it sends “CLOSE INMOD” request. THE USER EXIT routine must
   explicitly return “return code” = ZERO to terminate the
   conversation.                                                */
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
typedef unsigned short     Int16;
typedef unsigned char      Int8;
typedef unsigned int  Int32;
/* PASSING parameter structures
*/

typedef struct {
    Int32 code;
    Int32 len;
    Int8  buf[80];
} inmodbuf;
  
typedef struct {
    Int32 seq;
    Int16 len;
    char  param[80];
} inmodpty;
 
  static FILE *IN;
  static int count=0;
  char *memcpy();
   
void _dynamn(a,b)
inmodbuf *a;
inmodpty *b;
{int code=0; 
 char tempbuf[80];
   
  memcpy(tempbuf,a->buf,sizeof(a->buf));
  tempbuf[79]=’\0’;
  printf(“BEGIN--> %d  %d  %s\n”,a->code,a->len,tempbuf);
  printf(“     +++ %d  %d  %s\n”,b->seq ,b->len,b->param);
   code= (int) a->code;

  switch (code) {
   case 0:
    /* Here you open the file and read the first record */
    printf(“## CODE=0, openinig...\n”);
    IN=fopen(“ddn:INDATA”,“rb”);
    if (! ferror(IN)) {
       if (! readrecord(a))
          fclose(IN);
    };
   break;
   case 1:
    /* TPump requested next record, read it */
    printf(“## CODE=1, reading...\n”);
    if (! readrecord(a))
       fclose(IN);
    break;
   case 5:
    /* TPump is closing INMOD routine */
    a->code=0;
    a->len=0;
    printf(“## CODE=5, terminating...\n”);
    break;
    default:
    a->code=12; /* any number not = to zero */
    a->len=0;
    printf(“##### UNKNOWN code ######\n”);a->code=0;a->len=0;
  }; 
  memcpy(tempbuf,a->buf,sizeof(a->buf));
  tempbuf[79]=’\0’;
  printf(“END  --> %d  %d  %s\n”,a->code,a->len,tempbuf);
  printf(“     +++ %d  %d  %s\n”,b->seq ,b->len,b->param);
} 
 
  
int readrecord(a)
inmodbuf *a;
{ 
int rtn=0;
 char tempbuf[80];

     if (fread((char *)&(a->buf),sizeof(a->buf),1,IN)) {
       count++;
   
       memcpy(tempbuf,a->buf,sizeof(a->buf));
       tempbuf[79]=’\0’;
        printf(“        %d  %s  \n”,count,tempbuf);
    
        a->len=80;
        a->code=0;
        rtn=1; 
     };
      if ferror(IN) {
         printf(“==== error ====\n”);
        a->code=16; /* any non zero number */
        a->len=0;
     };
     if feof(IN) {                /* EOF, set length = zero */
        printf(“=== EOF ===\n”);
        a->code=9;
         a->len=9;
     };
     return(rtn);
}   
##
//LKED  EXEC PGM=LINKEDIT,PARM=’LIST,MAP’,COND=(8,LT,C)
//SYSPRINT  DD SYSOUT=*,DCB=(RECFM=FBA,LRECL=121,BLKSIZE=1210)
//SYSTERM   DD SYSOUT=*00153 //SYSLIN    DD
  DSN=*.C.SYSLIN,DISP=(OLD,PASS),VOL=REF=*.C.SYSLIN
//          DD DDNAME=SYSIN
//SYSLIB    DD DSN=TER2.SASC301H.SUBLIB,DISP=SHR
//SYSUT1    DD DSN=&&SYSUT1,UNIT=SYSDA,DCB=BLKSIZE=1024,
//          SPACE=(1024,(200,50))00158 
//SYSLMOD DD  DSN=JCK.INMOD.LOAD(INMODG1),DISP=MOD,UNIT=3380,
//          VOLUME=SER=TSO805
//SYSIN     DD DATA,DLM=##
   NAME INMODG1(R)
##
//BDLDEL   EXEC PGM=IEFBR1400164 
//BDLCAT   EXEC PGM=TPUMP
//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=*00171 
//         UNIT=SYSDA,DCB=(RECFM=F,DSORG=PS,LRECL=8244),
//         SPACE=(8244,(12,5))
//SYSIN     DD  *
//*******************************************************************
//* THIS STEP WILL ONLY DROP THE TABLES IF TPump 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;
DROP TABLE XXXX.LOGTABLE;
DROP TABLE XXXX.ET_INMODLC1;
DROP TABLE XXXX.UV_INMODLC1;
DROP TABLE XXXX.WT_INMODLC1;
.QUIT;
.LABEL NODROP;
.EXIT 4;
##
//******************************************************************
//*                                                                *
//*    RUN TPump                                                   *
//*                                                                *
//******************************************************************
//LOADIT   EXEC PGM=TPump
//STEPLIB  DD  DISP=SHR,DSN=STV.GG10.APP.L
//         DD  DISP=SHR,DSN=STV.GG00.APP.L
//         DD  DISP=SHR,DSN=STV.TG00.APP.L
//         DD  DISP=SHR,DSN=STV.RG00.APP.L
//         DD  DISP=SHR,DSN=TER2.SASC301H.LINKLIB
//         DD  DISP=SHR,DSN=JCK.INMOD.LOAD,VOLUME=SER=TSO805,
//             UNIT=338 
//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.INMODLC1;
CREATE TABLE INMODLC1  (F1 CHAR(10), F2 CHAR(70));
.BEGIN LOAD TABLES INMODLC1;
.Layout layname1;
.Field L1Fld1 1 Char(10);
.Field L1Fld2 * Char(70);
.DML Label DML1;
INSERT INMODLC1(F1,F2) VALUES (:L1FLD1, :L1FLD2);
.IMPORT INMOD INMODG1 USING (“AAA” “BBB”) LAYOUT LAYNAME1 APPLY DML1;
.End LOAD;
.LOGOFF;
##
//INDATA  DD DATA,DLM=##
01C       AAAAAAAAAAAAAAAA
02C       BBBBBBBBBBBBBBBB
03C       CCCCCCCCCCCCCCCC
04C       DDDDDDDDDDDDDDDD00229 ##
//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 INMODLC1;
.LOGOFF;
                ##