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

Doubt in dynamic call.


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
passion_sujesh

New User


Joined: 14 Mar 2008
Posts: 74
Location: India,Chennai

PostPosted: Thu Dec 02, 2010 8:22 pm
Reply with quote

Hi,

I have a doubt in calling a program dynamically. I have an program (prog A) calling a sub program(Prog B). The program B (sub pgm) uses a file(File F1) to do its processing. Program A is calling program B dynamically. My doubt is should i open the file (in sub pgm) every time i call program B (sub pgm), or is it fine if i open the file once in Initial para in Program A (Main pgm).

Can anyone please help me in this.

Thanks in advance,
Sujesh.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Dec 02, 2010 8:36 pm
Reply with quote

No, absolutely not. Open it ONCE in the Caller and access it in the Calling program. When you're done, close it in the Caller.

Try defining the file as EXTERNAL in both programs and see if this helps with your dilemma (requires VS/COBOL II and greater) as well as review the applicable IBM COBOL manual.

What have you tried?

Bill
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Dec 02, 2010 8:38 pm
Reply with quote

Not a programmer, so I could be way off of the mark here ......... but

Surely if you open the file every time, and my understanding is that the file is opened at the first record, your output from the program may not be very accurate.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Dec 02, 2010 9:14 pm
Reply with quote

unless you issue a CANCEL Prog B
in Prog A
and
Prog B does not have the INITIAL clause in the program ID paragraph,

you OPEN the file in Program B on the first CALL from A
(yeah, need to save a switch in Progr B)
read the file in program B
and then a final call from A to B to close it.

or,
use the external clause

but you can do allllllll your file handling in program B without any problem.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Dec 02, 2010 10:29 pm
Reply with quote

dbzTHEdinosauer wrote:
unless you issue a CANCEL Prog B
in Prog A
and
Prog B does not have the INITIAL clause in the program ID paragraph,

you OPEN the file in Program B on the first CALL from A
(yeah, need to save a switch in Progr B)
read the file in program B
and then a final call from A to B to close it.

or,
use the external clause

but you can do allllllll your file handling in program B without any problem.

If you want to have program A control all file handling you should implement a function code in your call parameters to B with (at least) 3 values:
    One for open file, and possibly other initialisation
    One for processing
    One for closing file and other cleanup

You can also do with opening the file at first call, and set a switch to mark that the file has been opened. Closing the file can then be left to the operating system when program A ends, though that is generally not considered good practice.
Back to top
View user's profile Send private message
passion_sujesh

New User


Joined: 14 Mar 2008
Posts: 74
Location: India,Chennai

PostPosted: Fri Dec 03, 2010 1:06 am
Reply with quote

Thanks for ur reply,

I will use the method provided by 'Kjeld'. Can i use the same approach for both statically and dynamically called programs?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Dec 03, 2010 1:18 am
Reply with quote

Quote:
Can i use the same approach for both statically and dynamically called programs?
What, exactly, do you mean by "statically and dynamically called"? The main difference between them is when does the program get loaded -- as part of the compile / linkage edit (bind) process, or when the calling program is executing. It certainly does not sound like this is what you mean, though.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts Call program, directly from panel CLIST & REXX 9
No new posts Synctool-dynamic split job for varyin... JCL & VSAM 7
Search our Forums:

Back to Top