when main program calls sub program?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

when main program calls sub program?

Postby deepak.punglia » Wed May 06, 2009 11:49 am

Hello All,

Please answer for the below scenorio...............

My main program is calling subprogram for every record in a loop. First time when it enters into a subprogram, i set some ws-variable to true

Say 01 WS-VARIABLE PIC X VALUE SPECES
88 WS-VAR VALUE 'S'

In procedure division
SET WS-VAR TO TRUE.

I wont initialize this after setting this flag.

After processing first record, it GO BACK to mainprogram, again coming to subprogram for the second record.

Now what will be the value of WS-VARIABLE?

Practically when i did this, WS-VARIABLE still contains 'S' in this.

Note: My subprogram in REENTRANT Program...........
deepak.punglia
 
Posts: 3
Joined: Wed May 06, 2009 11:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: when main program calls sub program?

 

Re: when main program calls sub program?

Postby dick scherrer » Thu May 07, 2009 1:48 am

Hello and welcome to the forum,

Suggest you change the code to pass this "initial" field from the caller to the called module in the linkage section rather than ws.

My subprogram in REENTRANT Program...........
Re-entrant means that multiple processes may use the same copy of the procedure code. Each process still needs a unique set of variables.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: when main program calls sub program?

Postby deepak.punglia » Thu May 07, 2009 12:42 pm

Thanks Dick...

for ur reply.....But my subprogram is running in production from long time and my client wont allow me to change and recompile this program.

Do u have any other way?

As per my understanding for every call from main program to subprogram ..memory need to be refreshed...

Is this a compiler problem?

Please let me know what u think?
deepak.punglia
 
Posts: 3
Joined: Wed May 06, 2009 11:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: when main program calls sub program?

Postby dick scherrer » Thu May 07, 2009 1:03 pm

Hello,

But my subprogram is running in production from long time and my client wont allow me to change
When did the program begin having problems? What was changed at that time? If it is broken, i suspect the client will want it fixed. . .

It may be that the called module is being reloaded for each call (which would reset the variables).

While you might not want/need the module to be reentrant, you may want it to be serially reusable (REUS).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: when main program calls sub program?

Postby deepak.punglia » Thu May 07, 2009 1:34 pm

Subprogram is not changed from long long time( May be 3 yrs). But i am writing a new program that will call this problem. While processing this program i got this issue?

Subprogram is Reentrant only
deepak.punglia
 
Posts: 3
Joined: Wed May 06, 2009 11:33 am
Has thanked: 0 time
Been thanked: 0 time

Re: when main program calls sub program?

Postby dick scherrer » Fri May 08, 2009 3:01 am

Hello,

Suggest you find someone who has successfully called this subroutine with a recently compiled program and make sure your code is set up like theirs - the actual code (ws & procedure), the compiler options, and the linkedit control.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post