IBM Mainframe COBOL and pointers between programs

Sometimes we experience storage violations and CICS crashes caused by incorrect use of pointers in COBOL used to transfer addresses of areas by calling / LINK between main module and submodule.

It must therefore be strongly emphasized that pointers to areas can only be used from top to bottom:

This means that a main program can transfer an address of an area in the program's own working storage to  a subprogram using a pointer.

However, a subprogram cannot transfer an address of an area in the program's own working storage back to the main program using a pointer.

The fact that the latter is not possible is due to the fact that the sub-program's working storage will be released and most likely used for other purposes when returning to the main program. Unfortunately, the likelihood of the area being used for other purposes is not so big in a low frequency test environment, so in some cases one might be "lucky" to get through a test without experiencing this catastrophic problem. In reality, this it is only a real problem when using CICS-LINK and not a problem with dynamic calling in CICS or in batch, since here you reuse working-storage of the subprogram, but in all cases it is a bad design and should be avoided, so one should abide by the good rules that apply in the most restrictive world, in CICS-LINK - otherwise one cannot keep track of the rules.

It should be noted that, of course, a subprogram is allowed to transfer data back to the main program using an area whose address is transferred to the subprogram via a pointer from the main program. The subprogram may not simply "hand over" an area or change any pointers from the main-program.

Yet a reason why a test environment is cruzial to find all defects in an it solution. To many test environments are not based on a thorough analysis of how close to production it is and most important, where it is not even close to production and nobody have an overview of the difference. Could be CICS, network, databases, server capacity, old/limited test data and other differences from production environments, which limits quality assurance/tests.

Like
Reply

To view or add a comment, sign in

More articles by Ole Olsen

  • Matematikken forklarer, hvordan coronavirus spreder sig

    Læs denne spændende men også skræmmende artikel om, hvordan coronavirus spreder sig: Som det fremgår i artiklen, så kan…

    2 Comments
  • MOVE substring in COBOL

    For many years it has been possible in COBOL to make MOVE as: MOVE <field> (<position>: <length>) TO ..

    1 Comment

Others also viewed

Explore content categories