|
Programming in COBOL |
|
|
XCICS supports COBOL programs that have been compiled using either:
With COBOL you must use only EXEC CICS commands to invoke operating system services. Some COBOL statements must not be used. Simplified based addressing using cell pointer variables and the ADDRESS special register. Programming restrictions This section describes COBOL language elements that you cannot use under CICS, or whose use is restricted or can cause problems under XCICS. In general, neither the XCICS translator nor the COBOL compiler detects the use of COBOL words affected by the following restrictions. The use of a restricted word in a CICS environment may cause a failure at execution time. The following restrictions apply to a COBOL program that is to be used as an XCICS application program. (See the appropriate COBOL programming guide for more information about these functions.)
Using based addressing with COBOL XCICS application programs need to access data dynamically when the data is in a XCICS internal area, and only the address is passed to the program. Examples are:
COBOL provides a simple method of obtaining addressability to the data areas defined in the LINKAGE SECTION using pointer variables and the ADDRESS special register. The ADDRESS special register holds the address of a record defined in the LINKAGE SECTION with level 01 or 77. This register can be used in the SET option of any command in ADDRESS mode. These commands include GETMAIN, LOAD, READ, and READQ. Calling subprograms from COBOL In an XCICS system, when control is transferred from the active program to an external program, but the transferring program remains active and control can be returned to it, the program to which control is transferred is called a subprogram. There are three ways of transferring control to a subprogram: EXEC CICS LINK The calling program contains a command in one of these forms: EXEC CICS LINK PROGRAM('subpgname') In the first form, the called subprogram is explicitly named as a nonnumeric literal within quotation marks. In the second form, name refers to the COBOL data area with length equal to that required for the name of the subprogram. Static COBOL call The calling program contains a COBOL statement of the form: CALL 'subpgname' Dynamic COBOL call The calling program contains a COBOL statement of the form: CALL identifier The identifier is the name of a COBOL data area that must contain the name of the called subprogram. COBOL programs can call any language programs statically or dynamically. LINK or XCTL are not required for inter-language communication, unless you wish to use CICS functions such as COMMAREA. Each LINK command creates a new logical level, the called program being at a level one lower than the level of the calling program (XCICS is taken to be at level 0). Figure 3 in topic 1.4.4.2 shows logical levels and the effect of RETURN commands and CALL statements in linked and called programs. Rules for calling subprograms The following rules describe the requirements and behavior of called or linked subprograms. Translation LINK The linked subprogram must be translated if it, or any subprogram invoked from it, invokes XCICS commands. Static and Dynamic COBOL CALL The called subprogram must be translated if it contains CICS commands or references to the EXEC interface block (DFHEIBLK) or to the CICS communication area (DFHCOMMAREA). Compilation All programs must be compiled. XCICS configuration entries LINK The linked subprogram must be defined in PPT. If the linked subprogram is unknown or unavailable, even though autoinstall is active, the LINK fails with the PGMIDERR condition. Static & Dynamic COBOL CALL The calling program must not be defined in PPT. Return from subprogram LINK The linked subprogram must return using either RETURN or a native language return command such as the COBOL statement GOBACK. Static and Dynamic COBOL CALL The called subprogram must return using a EXIT PROGRAM. The use of RETURN in the called subprogram leads to unpredictable results. Language of subprogram LINK Any language supported by XCICS. Static and Dynamic COBOL CALL Any language. Passing parameters to subprogram Data can be passed by any of the standard CICS methods (COMMAREA, TWA, TCTUA, TS queues) if the called or linked subprogram is processed by the CICS translator. LINK If the COMMAREA is used, its address must be passed in the LINK command. If the linked subprogram uses 24-bit addressing, and the COMMAREA is above the 16MB line, CICS copies it to below the 16MB line, and recopies it on return. Static COBOL CALL The CALL statement may pass DFHEIBLK and DFHCOMMAREA as the first two parameters, if the called program is to issue EXEC CICS requests, or the called program can issue EXEC CICS ADDRESS commands. The COMMAREA is optional but if other parameters are passed, a dummy COMMAREA must also be passed. Dynamic COBOL CALL The CALL statement may pass DFHEIBLK and DFHCOMMAREA as the first two parameters, if the called program is to issue EXEC CICS requests, or the called program can issue EXEC CICS ADDRESS commands. The COMMAREA is optional but if other parameters are passed, a dummy COMMAREA must also be passed. Using 3rd party software When using third party programs, you must be aware of their API interface. Normally there is no problem on big endian systems, which represent binary data as the mainframe does, while there may be incompatibilities with little endian systems, which manage binary data using a inverted notation. On little endian systems, the third party product API may require the usage of native data types (COMP-5), while XCICS/TS APIs, by default, require big endian binaries (COMP). The tipical scenario is the usage of Oracle precompiler with Linux or Windows on Intel CPUs: the oracle precompiler needs COMP-5 binaries, while XCICS/TS needs COMP fields. A program coming from the mainframe normally provides COMP field to the middleware APIs (CICS, SQL, MQ, etc.). Therefore, in order to execute correctly the program in the above scenario , you have two options:
The latter, is the easiest solution. In this sample, with Microfocus COBOL on Linux, we set the compiler options in xcob.conf export XCOB_TP_COBOPT3="MAKESYN \"comp-5\" == \"comp\"" and we configure XCICS/TS in xcics.conf set force_little_endian_api=yes; |