Chapter Contents |
Previous |
Next |
The SAS/C CICS Command Translator |
Command Format |
For example, the original CICS command syntax for the CICS READ command is as follows:
EXEC CICS READ
|
In your C program, this command can be coded as follows:
EXEC CICS READ DATASET("MASTER") INTO(record) LENGTH((short) sizeof(struct INPUT)) RIDFLD(key) KEYLENGTH(keylen);
Coding Conventions |
Observe the following conventions as you write your SAS/C CICS code:
typedef EXEC CICS READ ... ;
Commonly Used Data Types |
malloc
function.
EXEC CICS ADDRESS CSA(csa_ptr);
The argument
csa_ptr
should be declared
as a pointer variable, for example:
struct CSA *csa_ptr;
In this example, the translator will pass
&csa_ptr
to CICS. On return from the ADDRESS command,
csa_ptr
points to the CSA.
Less Common Data Types |
Some less commonly used data types are name, label, hhmmss, and cvda:
int
or
long int
) value always used in the SET and INQUIRE commands.
EXEC CICS SEND MAP("ABC") ... ;
The translator will pass the following string to the command:
"ABC"" "
The following example uses label as the name of a function:
EXEC CICS HANDLE CONDITION ERROR(err_func);
In this example,
err_func
defines an error
handling routine in your C program. See Using C for CICS Application Programs for more details.
For
hhmmss,
the translator expects a pointer to an aggregate object, such as a character
array or structure, because C has no equivalent to packed decimal data. (See
the descriptions for
pdset
and
pdval
in
SAS/C Library Reference, Volume 1.)
The
cvda data
type expects a fullword argument; therefore, you can use an
int
or a
long
,
signed
or
unsigned
. In the SET command, you can use a constant integer or the result
of the DFHVALUE function, although using one of the command options is a more
likely choice. In the INQUIRE command, use an lvalue.
Doubleword, Fullword, and Halfword Arguments |
CICS sometimes describes arguments as doubleword, fullword or halfword. In C terms, a
doubleword is a signed
or unsigned
long long
.
A fullword is a
signed
or
unsigned int
, or a
signed
or
unsigned long
. A halfword is a
signed short
. You can use
unsigned shorts
, but the compiler
will copy it to a temporary and pass the address of the temporary to CICS.
This could cause a problem if the variable in question is passed to CICS and
then assigned a value (for example, record length). In such a case, CICS
will update the temporary, which is probably not what the program is expecting.
Character Arguments |
When a CICS command option
expects
a single character as an argument, you must use a
char
pointer argument rather
than a character variable. If the argument is a data value, you can also
use a string literal. For example, the DATESEP option of the FORMATTIME command
expects a character to be used to separate the parts of a formatted date.
The methods used in either of the following examples can be used to code
this correctly:
Example 1
char *separator = ":"; EXEC CICS FORMATTIME ... DATESEP(separator);
Example 2
EXEC CICS FORMATTIME ... DATESEP(":");
When you use the PROTO translator option (the default)
with a
char
variable or
char
literal, a prototype
mismatch message results.
Prototype Generation |
By default, the translator generates a prototype for each
CICS command. If the translator expects a C pointer argument, it uses
void*
in that argument's place in the function prototype. Since
void*
is the generic pointer type, you can use any pointer type you
want for the argument. For instance, a character pointer and a structure
pointer are equally acceptable when writing to transient data queues with
the WRITEQ TD command using the FROM option, as in the following example:
char *output_buffer; struct FORMATTED_LINE *line; EXEC CICS WRITEQ TD FROM(output_buffer) ... ; EXEC CICS WRITEQ TD FROM(line) ... ;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.