IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Question reqgaring Db2 usage in subprogram and main program


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
gokuldass

New User


Joined: 18 Mar 2005
Posts: 48
Location: india

PostPosted: Wed Mar 03, 2010 12:27 pm
Reply with quote

Hi,

I have two programs main and sub program.

My main program doesn;t have any db2 statements and hence no package was created during compile and linkedit.

My sub program have db2 statements and hence compiled and linked edit with a package/plan.

My question:
Do I need to give the below statement in JCL while running the main program ???

//SYSTSIN DD *
DSN SYSTEM(TEST)
RUN PROG(SUB) PLAN(SUB)
END
/*

Thanks in advance.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Mar 03, 2010 6:27 pm
Reply with quote

My first reaction is- is it the very first appication of this kind written at your shop? You must have some standard JCLs to execute such things, don't you?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Mar 03, 2010 6:40 pm
Reply with quote

You've 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.

From MVS(z/OS, OS/390...) point of view, 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. Remember, DB2 is running as just another sub-system and 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 (and forget about the dynamic SQL for the time being).

So MVS(z/OS, OS/390...) environment in the JCL instead of coding a EXEC PGM=PureCobol, you would code a call to TSO, as in EXEC PGM-IKJEFT01, passing the actual execution in the SYSIN.
Back to top
View user's profile Send private message
sampathkmn
Warnings : 1

New User


Joined: 12 Dec 2005
Posts: 31
Location: bangalore

PostPosted: Wed Mar 03, 2010 6:55 pm
Reply with quote

Does this mean, even if main program does not contain SQL statements we need to precompile/bind it?
If yes, does this has any changes based on type of call(static/dynamic) to sub program?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Mar 03, 2010 7:00 pm
Reply with quote

Anuj Dhawan wrote:
From MVS(z/OS, OS/390...) point of view, 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. Remember, DB2 is running as just another sub-system and 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 (and forget about the dynamic SQL for the time being).
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Mar 03, 2010 7:09 pm
Reply with quote

You can not bind the main program as it has no DBRM.

While your environment setup is surely different than mine, in a similar situation I would set this up like:

//SYSTSIN DD *
DSN SYSTEM(TEST)
RUN PROG(MAIN) PLAN(SUB)
END
/*

This arrangement would startup the DB2 System, use the attributes in the Plan(SUB) and run the Cobol program MAIN.

This is using a dynamic call, since I have not done a static call in many years.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Wed Mar 03, 2010 7:27 pm
Reply with quote

It would be like this in our shop,

Code:
//CG25EXEC EXEC PGM=purecobol   
//SYSCAFIP DD *                 
DB2D planname                   
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts How to go into a subprogram in IBM De... IBM Tools 5
Search our Forums:

Back to Top