Page 1 of 1

when main program calls sub program?

PostPosted: Wed May 06, 2009 11:49 am
by deepak.punglia
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...........

Re: when main program calls sub program?

PostPosted: Thu May 07, 2009 1:48 am
by dick scherrer
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.

Re: when main program calls sub program?

PostPosted: Thu May 07, 2009 12:42 pm
by deepak.punglia
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?

Re: when main program calls sub program?

PostPosted: Thu May 07, 2009 1:03 pm
by dick scherrer
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).

Re: when main program calls sub program?

PostPosted: Thu May 07, 2009 1:34 pm
by deepak.punglia
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

Re: when main program calls sub program?

PostPosted: Fri May 08, 2009 3:01 am
by dick scherrer
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.