By using input file how to read database through easytrive

//XXXXIN DD DSN=XXXXXXX.XXXX.XXXX.XXXXXXXX.XXXXXXXX,DISP=SHR
//XXXXOUT DD DSN=XXXXXXX.XXXX.XXXX.XXXXXXXX.XXXXXXX,
// DCB=(LRECL=XX,RECFM=FB,BLKSIZE=0),
// UNIT=XXXXX,DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(XXX,XXX),RLSE)
//SYSIN DD *
* ----------------------------------------------*
* DATA DIVISION SECTION *
* ----------------------------------------------*
FILE ABCDEFGH DLI(ABCDEFGH 1)
PCB-DBD-NAME 1 8 A
PCB-SEGMENT-LEVEL 9 2 A
PCB-STATUS-CODE 11 2 A
PCB-PROC-OPTION 13 4 A
PCB-RESERVE-DLI 17 4 B
PCB-SEGMENT-NAME 21 8 A
PCB-LENGTH-KEY-FB 29 4 B
PCB-NUM-SENS-SEGMENT 33 4 B
PCB-KEY-FB-AREA 37 24 A
*-----------------------------------------------*
* WORKING STORAGE SECTION *
*-----------------------------------------------*
WS-AAA W 2 A
SSA-COUNT W 4 B VALUE 1
FUNCTION W 4 A VALUE 'GN '

%XXXXXXXX

* ----------------------------------------------*
* SSA *
* ----------------------------------------------*
SSA-XXXXXXXX-QUAL W 28 A VALUE 'XXXXXXXX'
SSA-XXXXXXXX-LPA SSA-XXXXXXXX-QUAL +08 1 A VALUE '('
SSA-XXXXXXXX-NME SSA-XXXXXXXX-QUAL +09 8 A VALUE 'XXXXXXXX'
SSA-XXXXXXXX-OPR SSA-XXXXXXXX-QUAL +17 2 A VALUE '= '
SSA-XXXXXXXX-KEY SSA-XXXXXXXX-QUAL +19 8 A
SSA-XXXXXXXX-RPA SSA-XXXXXXXX-QUAL +27 1 A VALUE ')'

FILE FILEIN
OXX-XXT 1 7 N
OXX-ABC 9 5 N
OXX-DEF 14 6 N

FILE FILEOUT
OX1-XXT 1 7 N
OX1-ABC 9 5 A
OX1-DEF 14 6 N

WS-XXX-KEY W 8 A
WS-HH WS-XX-KEY 4 N VALUE 1234
WS-AFEG-AA WS-XXX-KEY +04 4 P 00

XXXX-XXXXX-XXX W 10 A
TEMP-ABT XXXX-XXXXX-XXX 7 N
TEMP-ADI XXXX-XXXXX-XXX +07 1 A VALUE '.'
TEMP-DEC XXXX-XXXXX-XXX +08 2 N

WRX-XXXXX-XXX W 9 A
WRK-ADC WXX-XXXXX-XXX 7 N
WRK-DEC WXX-XXXXX-XXX +07 2 N

WS-XXXXX-ONE W 303 A
ADCD-DEFC WS-XXXXX-ONE +04 2 N
ABCF-AA WS-XXXXX-ONE +04 4 P 00
AAA-ADEF WS-XXXXX-ONE +08 4 P 00

XXXX-STATUS-CODE W 2 A

*-----------------------------------------------*
* PROCEDURE DIVISION SECTION *
*-----------------------------------------------*
JOB INPUT (XXXXIN)

WS-AFEG-AA = OXX-XXT
PERFORM GU-XXXXX-READ

*************************************************
GU-XXXXX-READ. PROC
*************************************************
XXXX-STATUS-CODE = ' '
FUNCTION = 'GU'
SSA-XXXXXXXX-KEY = WS-XXX-KEY
SSA-COUNT = 1
DLI ABCDEFGH AAAAAAAA FUNCTION +
SSANO SSA-COUNT +
SSA (SSA-AAAAAAAA-QUAL)

XXXX-STATUS-CODE = DATABASE-STATUS-CODE

//*The get unique call has been passed to read the database. This will be qualified call //*and upon read the record in database the status code (return code) will be in PCB //*status code. For read success the status code will be ‘spaces’ and no record found //*then ‘GE’.

IF XXXX-STATUS-CODE = ' '
OX1-XXX = OXX-XXT
OX1-ABC = OXX-XXX
OX1-DEF = XXXXXXXX:XXXXXXXX-ADC-IND
//* XXXXXXXX – Database name and XXXXXXXX-ADC-IND – Database field.
PUT XXXXOUT
ELSE
DISPLAY 'END---1:' OXX-XXT
END-IF
END-PROC
//*

//*
//*Read input file and load the data into table through easytrive

//XXXXIN DD DSN=XXXXXXX.XXXX.XXXXX.XXXXX.XXX,
// DISP=SHR
//SYSIN DD *
*
FILE FILEIN
IN-XXX 1 80 A
IN-AAA 1 05 N
IN-BBB 7 08 N
IN-CCC 16 10 N
IN-DDD 28 05 A
IN-EEE 35 02 A

TBL-CNT W 7 N VALUE 0
MAX-CNT W 7 N VALUE 0
*

AA-XXXX-TABLE W 30 A OCCURS 5000
AA-AAA AA-XXXX-TABLE 05 N
AA-BBB AA-XXXX-TABLE +05 08 N
AA-AAA AA-XXXX-TABLE +13 10 N
AA-BBB AA-XXXX-TABLE +23 05 A
AA-AAA AA-XXXX-TABLE +28 02 A

JOB INPUT NULL

//*Input null means when start of job it will not read any input file.

TBL-CNT = 0
DO UNTIL EOF XXXXIN
GET XXXXIN
IF EOF XXXXIN
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
DISPLAY ' END OF XXXXIN '
MAX-CNT = TBL-CNT
DISPLAY 'NUM OF LOADED ENTRIES = ' MAX-CNT
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
ELSE
TBL-CNT = TBL-CNT + 1
//* Table count increased one by one and the field values from input file will get loaded //*into table.
AA-AAA(TBL-CNT) = IN-AAA
AA-BBB(TBL-CNT) = IN-BBB
AA-CCC(TBL-CNT) = IN-CCC
AA-DDD(TBL-CNT) = IN-DDD
AA-EEE(TBL-CNT) = IN-EEE
END-IF
END-DO
/*
//*

//*Load the input file into table and read another file then match with input file. When //*there is a match found written into one output file and there is no match found //*written into another output file.

//XXXXIN DD DSN=XXXXXXX.XXXX.XXXXX.XXXXX.XXX,
// DISP=SHR
//AAAAA DD DSN=XXXXXXX.XXXX.XXXX.XXXX.XXXXXXX.XXX,
// DISP=SHR
//XXXXXUT DD DSN=XXXXXXX.XXXXXX.XXXXXX.XXXXXXXX.ALL,
// DISP=(NEW,CATLG,DELETE),
// UNIT=XXXXX,SPACE=(CYL,(X,X),RLSE),
// DCB=(RECFM=FB,LRECL=XX,BLKSIZE=0)
//XXXXXU1 DD DSN=XXXXXXX.XXXXXX.XXXXXX.XXXXXXXX.NOT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=XXXXX,SPACE=(CYL,(X,X),RLSE),
// DCB=(RECFM=FB,LRECL=XX,BLKSIZE=0)
//SYSIN DD *
*
FILE XXXXXUT
XX-REC 1 XX A
*
FILE XXXXXU1
XX-REC 1 XX A
*

FILE AAAAA
HH-AAA 1 80 A
HH-BBB 1 07 N
HH-CCC 80 07 N

FILE XXXXIN
IN-XXX 1 80 A
IN-AAA 1 05 N
IN-BBB 7 08 N
IN-CCC 16 10 N
IN-DDD 28 05 A
IN-EEE 35 02 A

TBL-CNT W 7 N VALUE 0
MAX-CNT W 7 N VALUE 0
TOL-CNT W 7 N VALUE 0
AAA-CNT W 11 N VALUE 0
AAA-FLG W 7 A VALUE 'N'
AAA-CNT W 9 N VALUE 0
AAAA-WK W 2 N VALUE 0
AAAV-WK W 2 N VALUE 0
AAP-CNT W 5 N VALUE 0
AAAAX1 W 5 N VALUE 0
AAAAX2 W 5 N VALUE 0
AAA-DEAL W 11 A
*

AA-XXXX-TABLE W 30 A OCCURS 5000
AA-AAA AA-XXXX-TABLE 05 N
AA-BBB AA-XXXX-TABLE +05 08 N
AA-AAA AA-XXXX-TABLE +13 10 N
AA-BBB AA-XXXX-TABLE +23 05 A
AA-AAA AA-XXXX-TABLE +28 02 A

JOB INPUT NULL

//*Input null means when start of job it will not read any input file.

TBL-CNT = 0
DO UNTIL EOF XXXXIN
GET XXXXIN
IF EOF XXXXIN
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
DISPLAY ' END OF XXXXIN '
MAX-CNT = TBL-CNT
DISPLAY 'NUM OF LOADED ENTRIES = ' MAX-CNT
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
PERFORM MACTH-AAA-BBB
ELSE
TBL-CNT = TBL-CNT + 1
//* Table count increased one by one and the field values from input file will get loaded //*into table.
AA-AAA(TBL-CNT) = IN-AAA
AA-BBB(TBL-CNT) = IN-BBB
AA-CCC(TBL-CNT) = IN-CCC
AA-DDD(TBL-CNT) = IN-DDD
AA-EEE(TBL-CNT) = IN-EEE
END-IF
END-DO
//*
*******************************************
MACTH-AAA-BBB. PROC
*******************************************
DO UNTIL EOF AAAAA
AAA-CNT = AAA-CNT + 1
AAP-CNT = AAP-CNT + 1
IF AAP-CNT >= 5000
DISPLAY ' PROGRESS >> ' AAA-CNT
AAP-CNT = 0
END-IF
GET AAAAA
IF EOF AAAAA
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
DISPLAY ' END OF AAAAA '
DISPLAY ' TOTAL AAAAA PROCESSED ' AAA-CNT
DISPLAY '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! '
STOP
ELSE
PERFORM COMPARE-TABLE
END-IF
END-DO
END-PROC.

*******************************************
COMPARE-TABLE. PROC
*******************************************

AAAAX1 = 1
DO WHILE AAAAX1 <= MAX-CNT
IF AA-AAA = AA-AAA(AAAAX1) AND +
AA-BBB = AA-BBB(AAAAX1)
AA-AAA = AA-AAA
PUT XXXXXUT
//* Each record from AAAAA the file that will be matched against the table which loaded //*based on input file (XXXXIN) and write the output file when there is match found //*(XXXXXUT).
ELSE
A1-AAA = AA-AAA
PUT XXXXXU1
//* Each record from AAAAA the file that will be matched against the table which loaded //*based on input file (XXXXIN) and write the output file when there is not match found //*(XXXXXU1).
END-IF

XXXXX1 = XXXXX1 + 1
END-DO
END-PROC.