Some time ago a colleague asked me how to make variables in PL/I survive from one call to the next just like variables in COBOL working-storage section. Then I remembered a tip I wrote back in week 44/2004. The tip explains how you make a variable in a procedure survive from one call to the next, but actually controlled variables survives from one program call to the next. Therefore you are able to code your PL/I program like this in order to have the same survival for variables as in COBOL:
In the procedure makeCobolWS you do not need to initialise the ws structure as it will be initialised as any ordinary uninitialised PL/I sttucture. If you need to initialise one or more of the variables in ws with special values, you must do it after the ALLOCATE statement where I have put in a general initialisation of the whole structure. All variables in the ws structure will survive between each call to the program.
I have tested the above program in different combinations. It does not make any difference whether the program is static linked into another programs load module or it is dynamically called: it works! In version 3 of PL/I it does not make any difference whether the call is from COBOL or PL/I. I did not have access to PL/I version 2. If you for some strange reason calls the same program both static and dynamic the two types of calls each get their own working-storage. So please use the same type of calls. Again there is no difference between COBOL and PL/I. The conclusion is that PL/I controlled variables survives in exactly the same way as variables in COBOL working-storage.
In CICS you must be aware that neither controlled variables nor working-storage survives if you make an EXEC CICS LINK to the program. This is very annoying, but at least you are warned. It has always worked like this at least since the introduction of socalled enclaves in CICS.