Using CICS storage constructs instead of PL/I language statements

In the case when a PL/I routine (routine A, for example) issues an EXEC CICS® LINK to another PL/I routine (routine B, for example), you might want to use EXEC CICS GETMAIN and FREEMAIN commands to get and free storage. This is because the scope of EXEC CICS GETMAIN is the scope of the entire task, not just a single routine. Either routine A or routine B can explicitly free the storage. Alternatively, you can choose to not explicitly free the storage in either routine, but allow the storage to be freed automatically when the task is terminated. Another advantage to using EXEC CICS GETMAIN is that if routine A terminates, the storage is still available to routine B.

When you use PL/I language statements to get and free storage, the scope of PL/I storage statements is the routine, not the task. Although routine B can alter the storage allocated by routine A by using a pointer, routine B cannot free the storage. In addition, if routine A terminates, the storage is automatically freed. Routine B can no longer access the storage.