Chapter Contents

Previous

Next
The SAS/C CICS Command Translator

How CICS Commands Are Translated

CICS C programs generally do not call a C library function to request operating system services. Instead, the programmer codes a CICS command to issue the request. The translator translates these commands into calls to the CICS EXEC interface program. This program provides the requested service by invoking the appropriate CICS control program.

The translator performs the following actions when it begins translating the CICS commands in your program:

For example, the following program fragment illustrates how a call to read a record in a VSAM file would be coded using the READ CICS command:

/* before translation */
void readin(struct INPUT *record, 
  char *key, short keylen)
{
.
.
.
   EXEC CICS READ DATASET("MASTER")
        INTO(record) LENGTH(sizeof(struct INPUT))
        RIDFLD(key) KEYLENGTH(keylen);
.
.
.
}

During translation, the READ command is converted into the following C statements:

/* after translation */
#include <cics.h>

void readin(struct INPUT *record, 
   char *key, short keylen)
{
.
.
.
   #if 0
   EXEC CICS READ DATASET("MASTER")
        INTO(record) LENGTH(sizeof(struct INPUT))
        RIDFLD(key) KEYLENGTH(keylen);
   #endif
   {
   __ref void (*_ccp_exec_cics)(char *,
    const char *,void *,short,void *,
   short)= (__ref void (*)(char *,const char *,
    void *,short,void *,short))
   _ccpexec;_ccp_exec_cics
     ("\x06\x02\xf8\x00\x09\x00\x00\x80\x00" 
       "00000006",
   "MASTER" "  ",record,sizeof(struct INPUT),
      key,keylen);
   }
.
.
.
}

First, the cics.h header file is included at the top of the output file. Next, the original command remains in the source file, but is surrounded with the #if 0 / #endif . CICS commands are then translated into the following sequence (assuming the PROTO option is in effect):

  1. a left brace.

  2. a function pointer declaration, _ccp_exec_cics . (This pointer is assigned a pointer to the EXEC command interface function _ccpexec that is declared in cics.h . This declaration generates a prototype. Because the translator is not able to determine whether the types of the function arguments are correct, the prototypes allow the compiler to check them.)

  3. a call to the EXEC interface function.

  4. a right brace.

The first argument to the EXEC command interface (\x06\x02 . . .) is a bit string containing encoded information about the type of command, the number of arguments, and whether or not the arguments are dummy arguments. The "00000006" sequence is the number of the line on which the command started. The remaining arguments are the C variables and constants specified in the command. The entry point to the EXEC command interface function used and the bits set in the first argument change according to the command and the options in effect.


Taking Advantage of Prototypes

The translator automatically generates prototypes for CICS command arguments. Prototype generation is useful because it helps determine whether the argument types are correct. For example, this feature enables you to catch mistakes such as specifying an int type variable instead of a short .

The translator also pads short strings in commands. CICS doesn't recognize null-terminated strings, which helps to prevent errors such as incorrectly identifying a program. For example, the EXEC CICS LOAD command could be coded as follows:

EXEC CICS LOAD PROGRAM("FTOC");

After translation, the command appears as the following:

EXEC CICS LOAD PROGRAM("FTOC" "    ");


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.