|
Introduction to IMS. Your Complete Guide to IBM's Information Management System Authors: Meltz D., Long R., Harrington M. Published year: 2003 Pages: 88-91/226 |
Part IV: IMS Application Development
Chapter 14. Application Programming Overview Chapter 15. Application Programming for the IMS Database Manager Chapter 16. Application Programming for the IMS Transaction Manager Chapter 17. Editing and Formatting Messages Chapter 18. Application Programming in Java |
Chapter 14. Application Programming OverviewThis section explains application program basics for any program that runs in an IMS environment. IMS programs (online and batch) have a different structure than non-IMS programs (see "Application Program Structure" on page 218). An IMS application program is always called as a subroutine of the IMS region controller and must have a program specification block (PSB) associated with it. The PSB provides an interface from the program to IMS services that the program needs to use. These services can be:
The IMS services available to any program are determined by the IMS environment in which the application is running. In This Chapter:
|
Java ProgramsThe IMS Java function allows you to write Java application programs that access IMS databases from:
Related Reading: IMS Java application support is discussed in Chapter 18, "Application Programming in Java," on page 311 and not covered in this chapter. |
Application Program StructureDuring initialization, both the application program and its associated PSB are loaded from their respective libraries by the IMS system. The IMS modules interpret and execute database CALL requests issued by the program. These modules can reside in the same or different z/OS address spaces, depending on the environment in which the application program executes. Application programs that execute in an online transaction environment are executed in a dependent region called the message processing region (MPR) or Fast Path region (IFP). The programs are often called message processing programs (MPPs). The IMS modules that execute online services run in the control region while the full-function database services run in the DL/I separate address space (DLISAS). The association of the application program and the PSB is defined at IMS system generation time through the APPLTN and TRANSACTION macros. Batch application programs can execute in two different types of regions .
For both of these types of batch application programs, the association of the application program to the PSB is done on the PARM keyword on the EXEC statement. Figure 14-1 on page 219 illustrates how the program elements of an application program interface with IMS and are functionally structured. The program elements are: Figure 14-1. Structure of an IMS Application Program
An ENTRY statement
A PCB or AIB
An input/output (I/O) area
Some DL/I calls
A status code processing section
A termination statement
Recommendation: If your program does not use the return code in this way, it is a good idea to set it to 0 as a programming convention. Your program can use the return code for this same purpose in BMP programs. MPPs cannot pass return codes. The PCB mask and I/O area are described in the program's data declaration section. Program entry, calls to IMS processing, and program termination are described in the program's procedural section. Calls to IMS, processing statements, and program termination can reference PCB masks or I/O areas. In addition, IMS can reference these data areas. The individual program elements mentioned in the previous list are discussed in the following sections. Entry to the Application ProgramAs shown in Figure 14-1, IMS passes control to the application program through the entry point. At entry, all the PCBs or AIBs used by the application program are specified. The order of the PCB names in the ENTRY statement must be the same as in the PSB for this application program. The sequence of PCBs in the linkage section or declaration portion of the application program need not be the same as in the ENTRY statement. IMS passes the PCB pointers to a PL/I program differently than it passes them to an assembler language, C language, COBOL, or Pascal program. In addition, Pascal requires that IMS pass an integer before passing the PCB pointers. IMS uses the LANG keyword or the PSBGEN statement of PSBGEN to determine the type of program to which it is passing control. Therefore, you must be sure that the language specified during PSBGEN is consistent with the language of the program. Application interfaces that use the AIB structure (AIBTDLI or CEETDLI) use the PCB name rather than the PCB structure and do not require the PCB list to be passed at entry to the application program. When you code each DL/I call, you must provide the PCB you want to use for that call. For all IMS TM application programs, the list of PCBs the program can access is passed to the program at its entry point.
Restriction: DB batch programs cannot be passed parameter information using the PARM field from the EXEC statement. AIB MaskThe AIB is used by your program to communicate with IMS when your application does not have a program communication block (PCB) address or the call function does not use a PCB. The AIB mask enables your program to interpret the control block defined. The AIB structure must be defined in working storage, on a fullword boundary, and initialized according to the order and byte length of the fields as shown in Table 14-1. The notes at the bottom of the table describe the contents of each field. Table 14-1. AIB Fields
The application program can use the returned PCB address, when available, to inspect the status code in the PCB and to obtain any other information needed by the application program. PCB MaskA mask or skeleton PCB structure is used by the application program to access data from a TP PCB or DB PCB. One PCB is required for each view of a database or online service. The program views a hierarchical data structure by using the DB PCB mask. The program uses a TP PCB to communicate with a terminal or other application program. Figure 14-2 on page 224 shows the structure of a PCB mask and how that structure maps to the database. Figure 14-2. Application PCB Structure
One PCB is required for each data structure. An example of a database PCB mask is shown in Figure 14-3 on page 225 and explained in the text that follows the figure. An example of a TP PCB mask is shown in Figure 14-5 on page 227. Figure 14-3. Example of a DB PCB Mask in COBOL01 PCBNAME. 02 DBD-NAME PICTURE X(8). 02 SEG-LEVEL PICTURE XX. 02 STATUS-CODE PICTURE XX. 02 PROC-OPTIONS PICTURE XXXX. 02 RESERVED-DLI PICTURE S9(5). 02 SEG-NAME PICTURE X(8). 02 LENGTH-FB-KEY PICTURE S9(5). 02 NUMB-SENS-SEGS PICTURE S9(5). 02 KEY-FB-AREA PICTURE X(n). Figure 14-5. Example of an Online Application PCB Mask
01 IOPCB.
02 LTERM PICTURE X(8). Logical Terminal Name
02 FILLER PICTURE XX. Reserved
02 STATUS-CODE PICTURE XX. Status Code
02 LOCAL-TIME PICTURE X(8). Local Date/Time
02 SEQ-NUMBER PICTURE X(4). Input Message Sequence Number
02 MOD-NAME PICTURE X(8). Message output descriptor name
02 USERID PICTURE X(8). USERID
02 RACF PICTURE X(8). RACF Group
02 TIMESTMP PICTURE X(12). 12-Byte Timestamp
02 USER-INDIC PICTURE X. Userid Indicator
02 FILLER PICTURE X(3). Reserved
Define the PCB mask as an assembler DSECT, a COBOL linkage section entry, or a PL/I-based variable because the PCB does not actually reside in the application program. The PCB provides specific areas used by IMS to inform the application program of the results of its calls. At execution time, all PCB entries are controlled by IMS. Access to the PCB entries by the application program is for read-only purposes. The PCB masks for a TP PCB and a database PCB are different. DB PCB MaskFigure 14-3 shows an example of a program's DB PCB mask, which defines the PCB area used by IMS to return the results of the call. The following items comprise a PCB for a hierarchical data structure from a database: Name of the PCB (PCBNAME)
Name of the database (DBD-NAME)
Segment hierarchy level indicator (SEG-LEVEL)
DL/I status code (STATUS-CODE)
DL/I processing options (PROC-OPTIONS)
Reserved area for IMS (RESERVED-DLI)
Segment name feedback area (SEG-NAME)
Length of key feedback area (LENGTH-FB-KEY)
Number of sensitive segments (NUMB-SENS-SEGS)
Key feedback area (KEY-FB-AREA)
Recommendation: Do not use the key feedback area after a completed unsuccessful call because this area is never cleared and it will contain information from a previous call. TP PCB MaskFigure 14-5 shows an example of an online program's PCB mask, which defines the PCB area used by IMS to return the results of the call. Calls to IMSActual processing of IMS messages, commands, databases, and services is accomplished using a set of input and output functional call requests. A call request is composed of a CALL statement with a parameter list. The parameter list varies, depending on the type of call to be made. The call request consists of the following components :
Table 14-2 briefly describes the components of a call request. The call request components for database processing are discussed in more detail in Chapter 15, "Application Programming for the IMS Database Manager," on page 241. The online services and commands call request components are discussed in more detail in Chapter 16, "Application Programming for the IMS Transaction Manager," on page 281. Table 14-2. IMS Call Request Components
Status Code ProcessingAfter each IMS call, a 2-byte status code is returned in the AIB or PCB that is used for that call. There are three categories of status codes:
The grouping of status codes in these categories somewhat depends on the installation. It is recommended that you use a standard procedure for status code checking and the handling of error status codes. The first two categories should be handled by the application program after each single call. Figure 14-6 shows an example of a COBOL application program that is testing status codes. Figure 14-6. Example of a COBOL Application Program Testing Status CodesCALL 'CBLTDLI' USING.... IF PCB-STATUS EQ 'GE' PERFORM PRINT-NOT-FOUND. IF PCB STATUS NE ' Notice that it is more convenient to directly test the regular exceptions inline instead of branching to a status code check routine. In this way, you clearly see the processing of conditions that you want to handle from an application point of view, leaving the real error situations to a central status code error routine. Termination of the ApplicationAt the end of the processing of the application program, control must be returned to the IMS control program. Table 14-3 shows examples of the termination statements. Table 14-3. Examples of Termination Statements in Different Languages
For application programs that are written in C or C++, when there are no more messages for the program to process, the program returns control to IMS by returning from main or by calling exit(). For application programs that are written in Pascal, when there are no more messages for your MPP to process, you return control to IMS by exiting the PASCIMS procedure. You can also code a RETURN statement to leave at another point.
Warning: Returning to IMS causes storage that was occupied by your program to be released because IMS links to your application program. Therefore, you should close all non-DL/I data sets for COBOL and Assembler before return, to prevent abnormal termination during close processing by z/OS. PL/I automatically causes all files to be closed upon return. |
|
Introduction to IMS. Your Complete Guide to IBM's Information Management System Authors: Meltz D., Long R., Harrington M. Published year: 2003 Pages: 88-91/226 |