CICS Translator for Unix System Services
Are you a Unix/C/C++ developer that has been enlisted to develop
CICS applications? Then you might be interested in knowing that you can
do much of your development work from right within Unix System Services. Read on for more.
CICS applications require a pre-compiler - called the CICS
Translator - which translates the embedded CICS commands into something
that can actually be compiled. For C & C++, the embedded CICS
commands are translated into function calls. The concept is analogous
to the way embedded SQL works on various platforms.
The ‘normal’
way to compile CICS programs is to perform the translation &
compiling from within the traditional mainframe environment, using JCL,
etc. However, for a C/C++ programmer with experience working in Unix
environments, there is a better way: Do all the development and
compiling from within Unix System Services.
To that end, I developed a shell script, cicstran, which can be used to translate CICS C/C++ source from within USS. You can download a zip file containing the script by clicking here.
Please
Note: There are a couple of environment variables inside the script
that MUST be modified for each installation. See near the top of the
script for more information. Also check the README.txt file for
up-to-date information.
Also, I currently do not have mainframe
access, and so some of this is coming from memory. Please let me know
if you encounter any problems so that I can fix them.
How to use ‘cicstran’:
Let’s
work through an example. Save the following code as ‘cicstest.ccics’
(the .ccics extension is important, as it signifies that this is a C
source file with embedded CICS commands):
#include <stdio.h>#include <stdlib.h>#include <cics.h>
int main(int argc, char *argv[]){ long int resp1, resp2; char buf[] = "This is CICS!"; int len = sizeof(buf);
if(iscics()) { EXEC CICS ADDRESS EIB(dfheiptr);
EXEC CICS SEND TEXT FROM(buf) LENGTH(len) RESP(resp1) RESP2(resp2); } else printf("This is NOT CICS!\n");
exit(0);}
You
can then translate the above code with cicstran as follows (assuming
that you have placed the script somewhere in your PATH):
cicstran cicstest.ccics
…This
will then translate the above source, and generate a regular source
file: ‘cicstest.c’, which can then be compiled using the USS C compiler
(c89), as follows:
c89 -Wc,RENT,NOXPLINK -O -c cicstest.c
This will create the object file (but not yet executable): cicstest.o
(Note:
It is my understanding that XPLINK is now supported in the newest
version of CICS. I was using CICS 2.2 when I developed this code, and
so the NOXPLINK option was necessary when compiling. In any case, you
can leave it in and it won’t hurt anything, but in real, production
code, you should use XPLINK [for performance reasons] if your version
of CICS supports it.)
Finally, to link the object file(s) into an executable program:
c89
-D_C89_EXTRA_ARGS=1 -D_C89_PSYSLIB=SYS1.SEZARNT1
-D_C89_LSYSLIB=CTS220.SDFHLOAD:SYS1.SCEELKED:SYS1.SEZATCP:SYS1.SEZACMTX
-v -V -o “//’TEST.CICS.LOADLIB(CICSTEST)’” cicstest.o
“//’CTS220.SDFHLOAD(DFHELII)’” “//’SYS1.SEZATCP(EZACIC17)’”
“//’CTS220.SDFHLOAD(DFHCPLC)’”
Note: The libraries above are
what I used in developing a custom-protocol TCP server that ran under
CICS, and all are not necessarily required for this example - SEZATCP,
for one. Your requirements may vary.
Replace ‘TEST.CICS.LOADLIB(CICSTEST)’ with an appropriate dataset name for your installation.
If
you would like to test the link by creating an HFS executable, just
change the -o above to something like ‘-o cicstest’. Again, you can’t
run this from CICS, but you can test the linking this way, and you can
also run the program from within USS (since we use iscics() in the
sample code above.)
Of course, you will also need to setup a
CICS transaction that references this program to actually use it. Also,
every time you change the program, you will need to tell CICS to
refresh the program (otherwise, it will keep using the old program,
until you refresh it or until the CICS region is restarted.)
If
you run the above example program interactively from within CICS (by
entering the name of the transaction), then it will print out the
following message to your terminal:
This is CICS!
By
the way, since setting up a new transaction in CICS is usually the
responsibility of an administrator, and so can be a hassle from a
programmer’s perspective, I like to setup a test CICS transaction, and
then use that transaction when testing multiple programs: Simply
overwrite the old program with the new one, then tell CICS to refresh
the program.
Hope this is useful to you. If you have any questions, or need any help (or
consulting services!), please feel free to contact me.
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.


I really appreciate your time and effort in writing this up.
It’s so much nicer to compile CICS C programs from USS rather than messing around with JCL.
Thank you very much!