Hi @usrname, @BilliBoyo, I am using IKJEFT01 to execute the program.
No. the program is issung the abend only when I want it to.
I am deliberately making the program abend when there is not even a single row fetched in the cursor. Hence, SQLCODE 100.
So, using a IF structure, if SQLCODE is 100 and the cursor-counter is zero, I am treating this as an abend by moving 4200 to return-code immediately followed by a STOP RUN.
@BilliBoyo
This is my step:
//R010 EXEC PGM=IKJEFT01
//STEPLIB INCLUDE MEMBER=SLIBDUMM
// INCLUDE MEMBER=SLIBDEV1
// INCLUDE MEMBER=SLDBTDB2
//FILEO1 DD DSN=TSOPKUL.GMRFTCSD.R010,DISP=(,CATLG,),
// DCB=(LRECL=50,RECFM=FB),
// SPACE=(TRK,(10,20),RLSE),
// UNIT=SYSDA,
// STORCLAS=PERM
//FILEE1 DD DSN=TSOPKUL.ERRFILE.R010,DISP=(,CATLG,),
// DCB=(LRECL=48,RECFM=FB),
// SPACE=(TRK,(10,20),RLSE),
// UNIT=SYSDA,
// STORCLAS=PERM
//* AVGREC=K
//SYSOUT DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSUDUMP DD DSN=TSOPKUL.GMRFTCSD.R010.SYSUDUMP,DISP=(,CATLG,),
// DCB=(RECFM=VB,BLKSIZE=800),
// SPACE=(TRK,(90,90),RLSE),
// UNIT=SYSDA,
// STORCLAS=PERM
//SYSABEND DD DSN=TSOPKUL.GMRFTCSD.R010.SYSABEND,DISP=(,CATLG,),
// DCB=(RECFM=VB,BLKSIZE=800),
// SPACE=(TRK,(90,90),RLSE),
// UNIT=SYSDA,
// STORCLAS=PERM
//SYSTSIN DD *
DSN SYSTEM(TDB2)
RUN PROGRAM(CDFETCSP) PLAN(CDFETCSP)
END
This is the SYSOUT O/P:
SQLCODE: 0000000100
WS-CURS01-PTR: 000000000
NO ROWS FOUND FOR
DB2 ABEND
This is the error file that was loaded with the value of the return-code passed: TSOPKUL.ERRFILE.R010
FILEE1-STATIC-REC FILEE1-RETURN-CODE FILLER
C(20) (1-20) B(4) (21-22) C(26) (23-48)
-------------------- ------------------ --------------------------
********************************* TOP OF DATA **********************
RETURN-CODE: 4200 ..........................