I am Linking from Program A to Program B.
In Program B i am storing some values in Working storage (B).I am passing the values back to Program A via a common Pointer.
I am dereferencing the pointer and using the values.
Now my clarification is ,whether the memory (Working storage of B) will be made availble to for use after this Pgm B ends or the entire task completes.
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
As I see it, the return back from a EC LINK will free all storage associated with the linked level, i.e., the pointers 'may' no longer point to valid values.
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
In a LINK-API, a new LE "Enclave" (love this term), is created and upon return, is terminated, with all WS returned to the operating system.
So, I would NOT rely upon the ability of the LINKING program to address WS which "had" (past tense) existed in the LINKED-TO program, who has now returned control to the LINKER. You may find that you can get away with this in a TEST environment, but as soon as this is placed into Production, all bets are off and you'll find yourself chasing down some "opportunities".
If you really need addressability, then you'll need GETMAIN storage, acquired by either the LINKER or the LINKEE.
Then, this storage address and its data will be preserved until task termination. However, the LINKER must have the ability to obtain this address, so it might be best if the storage were acquired first by the LINKER.
Try to avoid GETMAIN SHARED, because if an abend occurs after obtaining this SHARED storage, this storage becomes orphaned and cannot be addressed until the region is recycled. A high degree of orphaned storage may result in the region terminating with an "S80A" abend.
Another issue regarding SHARED storage is that it must be explicitly FREEMAINed and (unlike non-SHARED GETMAIN storage) will NOT automatically be FREEMAINed upon task termination.
The bottom line is, try not to use GETMAIN SHARED and if you do, understand the pitfalls.
One last thought. Have you looked into EXTERNAL WS data? This might also be a viable option.