I am trying to run a COBOL-DB2 program, to get employee data from the database, on which computation is done to find total salary.
in this, the COBOL program takes a single input from PS Dataset and passes it to where the condition of the cursor, for each record from the cursor computes the total salary and writes in an output PS Dataset.
while execution I am facing a file status code 47 while trying to read the input dataset.
PC(Precompilier)
COBOL(compilier)
LKED(link)
BIND is fine during the run.
COBOL code:
File control:
FILE-CONTROL.
*
SELECT DEPTFILE ASSIGN TO DEPTFILE
ACCESS IS SEQUENTIAL
FILE STATUS IS WS-DEPTFILE-STATUS.
*
SELECT EMPRPT ASSIGN TO EMPRPT
ACCESS IS SEQUENTIAL
FILE STATUS IS WS-EMPRPT-STATUS.
*
SELECT DEPTFILE ASSIGN TO DEPTFILE
ACCESS IS SEQUENTIAL
FILE STATUS IS WS-DEPTFILE-STATUS.
*
SELECT EMPRPT ASSIGN TO EMPRPT
ACCESS IS SEQUENTIAL
FILE STATUS IS WS-EMPRPT-STATUS.
100-OPEN-FILES.
OPEN INPUT DEPTFILE
OUTPUT EMPRPT.
*
110-READ-INPUT-FILE.
*
READ DEPTFILE.
DISPLAY "FILE STATUS" WS-DEPTFILE-STATUS.
DISPLAY "WORK-DEPT" WORK-DEPT
IF WS-DEPTFILE-STATUS = 0
MOVE WORK-DEPT TO WS-WORK-DEPT
PERFORM 200-PROCESS-CURSOR.
OPEN INPUT DEPTFILE
OUTPUT EMPRPT.
*
110-READ-INPUT-FILE.
*
READ DEPTFILE.
DISPLAY "FILE STATUS" WS-DEPTFILE-STATUS.
DISPLAY "WORK-DEPT" WORK-DEPT
IF WS-DEPTFILE-STATUS = 0
MOVE WORK-DEPT TO WS-WORK-DEPT
PERFORM 200-PROCESS-CURSOR.
JCL code:
//BIND EXEC PGM=IKJEFT01
//STEPLIB DD DSN=DSNC10.SDSNLOAD,DISP=SHR
// DD DISP=SHR,DSN=&SYSUID..LOAD(CBLDB21)
//DBRMLIB DD DSN=&SYSUID..DBRMLIB(CBLDB21),DISP=SHR
//SYSUDUMP DD DUMMY
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DBCG)
RUN PROGRAM(CBLDB21) PLAN(CBLDB21)
END
//SYSIN DD *
//*****************************************************
//* EXECUTE DB2 PROGRAM
//*****************************************************
//CBLRUN EXEC PGM=CBLDB21
//STEPLIB DD DSN=&SYSUID..LOAD(CBLDB21),DISP=SHR
//
//SYSPRINT DD SYSOUT=*
//* INPUT FILE
//DEPTFILE DD DSN=Z56117.EMPLOYEE.DEPT,DISP=SHR
//* OUTPUT FILE
//EMPRPT DD DSN=Z56117.EMPLOYEE.DEPT.REPORT,DISP=OLD
//SYSOUT DD SYSOUT=*
//STEPLIB DD DSN=DSNC10.SDSNLOAD,DISP=SHR
// DD DISP=SHR,DSN=&SYSUID..LOAD(CBLDB21)
//DBRMLIB DD DSN=&SYSUID..DBRMLIB(CBLDB21),DISP=SHR
//SYSUDUMP DD DUMMY
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DBCG)
RUN PROGRAM(CBLDB21) PLAN(CBLDB21)
END
//SYSIN DD *
//*****************************************************
//* EXECUTE DB2 PROGRAM
//*****************************************************
//CBLRUN EXEC PGM=CBLDB21
//STEPLIB DD DSN=&SYSUID..LOAD(CBLDB21),DISP=SHR
//
//SYSPRINT DD SYSOUT=*
//* INPUT FILE
//DEPTFILE DD DSN=Z56117.EMPLOYEE.DEPT,DISP=SHR
//* OUTPUT FILE
//EMPRPT DD DSN=Z56117.EMPLOYEE.DEPT.REPORT,DISP=OLD
//SYSOUT DD SYSOUT=*
please advice.