The call to CEE5INF returns all the required information on the environment we need to be able to make logical decisions to determine in which environment we’re being executed.
Next, we will use the CEESITST callable service to test the bit values of the returned fields from the CEE5INF call (see Figure 3). Using the CEESITST callable service allows the COBOL program to dissect the bit flag values which indicate environment information returned from the earlier CEE5INF call. We can then set our own local level-88 field to the result and use that wherever we need to perform environment-dependent execution.
Environment-Independent Application Considerations
Now that we’ve established within which environment our application is running, we can perform batch- or CICS-specific processing. However, it’s important to remember that even though this COBOL program will be capable of running in either the batch or CICS environment, we need to accommodate the environment that has the least tolerance for COBOL verbs in a “lowest common denominator” implementation. This means our application must respect the limitations imposed on CICS/COBOL programs in both environment execution flows. The idea here is to avoid receiving error message IGZ0011C while attempting to execute our application. See the CICS Application Programming Guide for a list and description of restricted COBOL verbs.
If there’s a requirement to use one or more of the restricted CICS/COBOL verbs in an application potentially being executed in both batch and CICS environments, then one possible circumvention would be to dynamically call a routine to perform those restricted CICS/COBOL verbs or functions when it has been determined at execution time the environment can support those COBOL verbs or functions.
Using the code in Figure 3, we can now perform specific execution flows based upon our execution environment at run-time.
Figure 4 shows how we would perform some environment-specific processing based on our execution environment. In the batch environment, we will perform some simple batch functions using available LE callable services; then, we will perform some more CICS-specific-type functions in the CICS environment.