15.00 - COBOL INMOD Example - FastLoad

Teradata FastLoad Reference

prodname
FastLoad
vrm_release
15.00
category
Programming Reference
featnum
B035-2411-034K

COBOL INMOD Example

The INMOD in the following example reads five 80‑byte records from the input data file, combines them, then returns a single, 400‑byte record to the Teradata FastLoad utility.

 
IDENTIFICATION DIVISION.  
PROGRAM‑ID.  BLKEXIT.  
AUTHOR.  STV   .  
INSTALLATION.  TERADATA.  
DATE‑WRITTEN.  05 APRIL 1984.  
DATE‑COMPILED.  
SECURITY.  OPEN.  
REMARKS.
   THIS PROGRAM IS AN EXAMPLE OF A COBOL INMOD ROUTINE.  
   THE NAME MUST BE BLKEXIT.  
   FUNCTION:   THE PROGRAM READS FIVE 80‑BYTE RECORDS AND
            RETURNS A COMPOSITE RECORD WHICH IS 400 BYTES 
            LONG.
 
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      PIC S9(4) COMP VALUE +0.
01    NUMOUT     PIC S9(4) COMP VALUE +0.
    01    FILES_OPEN PIC S9(4) COMP VALUE +0.
 
LINKAGE SECTION.
01    STRUCT.
      02 RETURN‑INDICATEPIC S9(9) COMP.
      02 RECORD‑LEN       PIC S9(9) COMP.
      02 RECORD‑BODY.
         03 DATA‑AREA1  PIC X(80).
         03 DATA‑AREA2  PIC X(80).
         03 DATA‑AREA3  PIC X(80).
         03 DATA‑AREA4  PIC X(80).
         03 DATA‑AREA5  PIC X(80).
PROCEDURE DIVISION USING STRUCT.
BEGIN.
MAIN.
IF RETURN‑INDICATE = 0 THEN 
   DISPLAY ’BLKEXIT CALLED ‑ RETURN CODE 0’ 
   PERFORM OPEN‑FILES 
   PERFORM READ‑RECORDS 
   GOBACK
ELSE 
IF RETURN‑INDICATE = 1 THEN
   DISPLAY ’BLKEXIT CALLED ‑ RETURN CODE 1’ 
   PERFORM READ‑RECORDS 
   GOBACK
ELSE 
IF RETURN‑INDICATE = 2 THEN
   DISPLAY ’BLKEXIT CALLED ‑ RETURN CODE 2’ 
   PERFORM OPEN‑FILES 
   MOVE 0 TO RECORD‑LEN 
   GOBACK
ELSE
    IF RETURN‑INDICATE = 5 THEN
   DISPLAY ’BLKEXIT CALLED ‑ RETURN CODE 5’ 
       IF FILES_OPEN = 1   THEN
       CLOSE INMOD‑DATA‑FILE 
           MOVE 0 TO FILES_OPEN.  
   MOVE 0 TO RECORD‑LEN 
   GOBACK
ELSE
   DISPLAY ’BLKEXIT CALLED ‑ RETURN CODE X’ 
   GOBACK.
OPEN‑FILES SECTION.  
   OPEN INPUT INMOD‑DATA‑FILE.
       MOVE 1 TO FILES_OPEN.
   MOVE 0 TO RETURN‑INDICATE.
READ‑RECORDS SECTION.
   MOVE 0 TO BLOCK‑NUM.  
   READ INMOD‑DATA‑FILE INTO DATA‑AREA1
      AT END GO TO END‑DATA.  
   ADD 1 TO NUMIN.  
   READ INMOD‑DATA‑FILE INTO DATA‑AREA2
      AT END GO TO END‑DATA.  
ADD 1 TO NUMIN.  
   READ INMOD‑DATA‑FILE INTO DATA‑AREA3
      AT END GO TO END‑DATA.  
   ADD 1 TO NUMIN.  
   READ INMOD‑DATA‑FILE INTO DATA‑AREA4
      AT END GO TO END‑DATA     
    ADD 1 TO NUMIN.  
READ INMOD‑DATA‑FILE INTO DATA‑AREA5
   AT END GO TO END‑DATA.  
ADD 1 TO NUMIN.  
MOVE 0 TO RETURN‑INDICATE.  
MOVE 400 TO RECORD‑LEN.
ADD 1 TO NUMOUT.
ENDDATA SECTION.
MOVE 0 TO RETURN‑INDICATE.  
CLOSE INMOD‑DATA‑FILE.
    MOVE 0 TO FILES_OPEN.  
DISPLAY ’NUMBER OF INPUT RECORDS =’ NUMIN.  
DISPLAY ’NUMBER OF OUTPUT RECORDS=’ NUMOUT.  
MOVE 0 TO RECORD‑LEN.  
MOVE 99 TO RETURN‑INDICATE.  
GOBACK.