mox512
New User
Joined: 04 Feb 2024 Posts: 24 Location: united arab emirates
|
|
|
|
Hi everyone,
I am writing a stored procedure in COBOL. First, I create the stored procedure using the following code:
Code: |
//COMP11 JOB 'COBOL PGM IN JCL',CLASS=A,NOTIFY=&SYSUID,REGION=0M
//JOBLIB DD DSN=DSNB10.SDSNLOAD,DISP=SHR
// DD DSN=DSNB10.SDSNEXIT,DISP=SHR
//STEP1 EXEC PGM=IKJEFT01,DYNAMNBR=20
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DSNP)
RUN PROGRAM(DSNTEP2) PLAN(DSNTEP11) -
LIB('DSNB10.DSNP.RUNLIB.LOAD')
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
CREATE PROCEDURE DBA.BGCALS
(
IN PANID DECIMAL(16),
OUT CARDID DECIMAL(10)
)
-------------BODY---------------------------
LANGUAGE COBOL
RESULT SETS 0
PARAMETER CCSID UNICODE
FENCED
NOT DETERMINISTIC
NO DBINFO
COLLID CALLSP
WLM ENVIRONMENT DSNPWLM1
EXTERNAL NAME 'BGCALL'
MODIFIES SQL DATA
ASUTIME NO LIMIT
STAY RESIDENT NO
PROGRAM TYPE MAIN
SECURITY DB2
COMMIT ON RETURN NO
|
Then I write my COBOL program like this:
Code: |
***************************
IDENTIFICATION DIVISION.
***************************
PROGRAM-ID. BGCALL.
*****************************
ENVIRONMENT DIVISION.
****************************************************************
DATA DIVISION.
****************************************************************
FILE SECTION.
WORKING-STORAGE SECTION.
01 DCLCARD.
10 CARD-ID PIC S9(10)V USAGE COMP-3.
10 CARD-TYPE-ID PIC S9(4) USAGE COMP.
10 STATUSS PIC S9(4) USAGE COMP.
10 CONTRACT-ID PIC S9(10)V USAGE COMP-3.
10 CREATOR-USER-ID PIC S9(10)V USAGE COMP-3.
10 CUSTOMER-ID PIC S9(10)V USAGE COMP-3.
10 CUSTOMER-STRUCTURE-ID
PIC S9(10)V USAGE COMP-3.
10 INSERT-DATE PIC X(26).
10 LAST-EDIT-DATE PIC X(26).
10 CARD-HOLDER-ADDNAL-DATA.
49 CARD-HOLDER-ADDNAL-DATA-LEN
PIC S9(4) USAGE COMP.
49 CARD-HOLDER-ADDINAL-DATA-TEXT
PIC X(100).
10 CARD-HOLDER-NAME.
49 CARD-HOLDER-NAME-LEN
PIC S9(4) USAGE COMP.
49 CARD-HOLDER-NAME-TEXT
PIC X(120).
10 PAN PIC S9(16)V USAGE COMP-3.
01 SP-SQLCODE PIC S9(9) USAGE COMP.
01 SP-SQLSTATE PIC S9(9) USAGE COMP.
EXEC SQL INCLUDE SQLCA END-EXEC.
LINKAGE SECTION.
77 CARDID PIC S9(10)V USAGE COMP-3.
77 PANID PIC S9(16)V USAGE COMP-3.
PROCEDURE DIVISION USING PANID,CARDID.
MAIN-PROC.
EXEC SQL
SELECT CARD_ID INTO :CARDID
FROM CMS.CARD
WHERE PAN = :PANID
END-EXEC.
DISPLAY'CARD-ID IS:' CARDID.
MAIN-PROC-RETURN.
GOBACK.
|
3. I then precompile, compile, link, and bind the package with this code:
Code: |
//COMPSP JOB 'COBOL PGM IN JCL',CLASS=A,NOTIFY=&SYSUID,REGION=0M,
// MSGLEVEL=(1,1),MSGCLASS=X
//*********************************************************************
//* THIS STEP COMPILES AND LINKS A COBOL PROGRAM *
//*********************************************************************
//JOBLIB DD DISP=SHR,DSN=DSNB10.SDSNEXIT
// DD DISP=SHR,DSN=DSNB10.SDSNLOAD
// DD DISP=SHR,DSN=CEE.SCEERUN
//PH02CS03 EXEC DSNHICOB,MEM=BGCALL,
// COND=(4,LT),
// PARM.PC=('HOST(IBMCOB)',APOST,APOSTSQL,SOURCE,
// NOXREF,'SQL(DB2)','DEC(31)'),
// PARM.COB=(NOSEQUENCE,QUOTE,RENT,
// 'PGMNAME(LONGUPPER)','ARITH(EXTEND),LIB')
//PC.DBRMLIB DD DSN=ETL.DSNP.DBRMLIB.DATA(BGCALL),
// DISP=SHR
//PC.SYSLIB DD DSN=ETL.DSNP.SRCLIB.DATA,
// DISP=SHR
//PC.SYSIN DD DISP=SHR,DSN=DBA.JCL(BGCALL)
//LKED.SYSLIB DD DSN=CEE.SCEELKED,DISP=SHR
// DD DSN=DSNB10.SDSNLOAD,DISP=SHR
//LKED.SYSLMOD DD DSN=ETL.DSNP.RUNLIB.LOAD(BGCALL),DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//LKED.SYSIN DD *
INCLUDE SYSLIB(DSNELI)
MODE AMODE(31) RMODE(ANY)
/*
//*=============================================================
//SQLBIND PROC
//BIND EXEC PGM=IKJEFT01,DYNAMNBR=20
//DBRMLIB DD DSN=ETL.DSNP.DBRMLIB.DATA,DISP=SHR
//STEPLIB DD DISP=SHR,DSN=DSNB10.SDSNEXIT
// DD DISP=SHR,DSN=DSNB10.SDSNLOAD
// DD DISP=SHR,DSN=CEE.SCEERUN
// DD DSN=CEE.SCEELKED,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSTSIN DD DDNAME=SYSTSIN
// PEND
//STEP2 EXEC SQLBIND
//****************************************************************
//* UBAH XXXXXXXX MENJADI NAMA PROGRAM
//****************************************************************
//BIND.SYSTSIN DD *
DSN SYSTEM(DSNP)
BIND PACKAGE(CALLSP) -
MEMBER(BGCALL) -
ACT(REP) ISO(UR) ENCODING(EBCDIC) -
OWNER(HOOMAN)
END
DSN SYSTEM(DSNP)
BIND PLAN(BGCALL) -
OWNER(HOOMAN) -
PKLIST(CALLSP.BGCALL) -
RETAIN -
DYNAMICRULES(BIND) -
VALIDATE(BIND) -
ISOLATION(CS) -
ACQUIRE(USE) -
RELEASE(COMMIT) -
EXPLAIN(YES)
END
|
I received SQLCODE 444 when calling the stored procedure. How can I fix it? |
|