Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COBOL pgm calling a DB2 pgm?

Status
Not open for further replies.

nxm150

Programmer
May 22, 2002
78
US
I have a COBOL DB2 pgm that updates a table with record counts for a request. Can my COBOL pgm pass the request number and record count to my DB2 pgm and succesfully call it?
 
Hi nxm150,
I'm going to talk from an OS390 point of view here. Your standard Cobol program can call a DB2 program without any differences to the Cobol. In the calling program, the 'call' statement is exactly as it would be in any other program.

The difference lies in the 'outside' environment. In order to access DB2 tables, you must start off with in a DB2 environment, and specify a plan (or package) name, which has got the db2 statements already defined to it (let's ignore dynamic SQL for the time being).

What this means in an OS390 environment is that in the JCL rather than coding a EXEC PGM=COBPROGA, you would code a call to TSO, as in EXEC PGM-IKJEFT01, passing the actual execution in the SYSIN.

Hope this has not been a grandmother and eggs situation and if I have over explained things, sorry. If I've not explained things enough, get back to us.

hth
Marc
 
Great. Glad to have been of help, and thanks for letting me know!
 
Can you give me an example jcl for a cobol program calling a db2 sub-routine or sub-program?

Thanks
 
Here is a JCL-sample for a program that uses DB2 itself or in a sub-program:

[tt]
//GO EXEC PGM=IKJEFT01,DYNAMNBR=20,REGION=4M
//STEPLIB DD DISP=SHR,DSN=TEST.LM
// DD DISP=SHR,DSN=PROD.LM
// DD DISP=SHR,DSN=DBNT.DSNEXIT
// DD DISP=SHR,DSN=DBNT.DSNLOAD
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DBNT)
RUN PROGRAM(COBOLPGM) PLAN(BATCH01) -
LIB('TEST.LM')
END
//*
[/tt]

Regards,
Thomas
 
nxm150

While we are back in this thread, I think you owe Marc a star! [bigsmile]

Tom Morrison
 
what if the Calling program needs to be a Non-DB2 program. I wrote the DB2 sub-routine and another programmer who doesn't know DB2 wrote a Non-DB2 Cobol program which should call my DB2 program. I got a -927 sqlcode executing it.

Can I use the above mentioned JCL for my situation?

Thanks to everyone for your time.
 
You HAVE to use the IKJEFT01-JCL even if your main program doesn't use DB2-commands. An you have to bind a plan for this program. Ohterwise you cannot connect to the DB2-system an receive a SQL-Code -927.


Regards,
Thomas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top