To allow your program to access an IMS database you need to have a PSB (program specification block) defined that includes all of the database references that your program will be allowed to make. This PSB will be made up of a number of PCB (program communication block) references - one for each IMS database pointer that the program requires.
The program then in turn needs to define an access to each of these PSBs. The area is not updateable from within your program but instead provides a means for information about the current location of the database pointer and the status of the last call to be accessed by the program. In COBOL these PSB definitions go in the Linkage Section while in PL/1 they are referenced from the main PROC statement. For each PCB listed in the PSB there will be one PCB mask defined and the order that these appear in the Linkage Section or PROC statement needs to match exactly with the list of PCBs in the PSB. The format of each will be as follows (the numbers indicate the field lengths):
database name 8 segment level number 2 status code 2 processing options 4 reserved 4 segment name 8 length of key feedback area 4 number of sensitive segments 4 key feedback area variable
The actual calls to access the database will be done by calling CBLTDLI or PLITDLI (depending on your programming language). PL/1 requires that the first parameter contain a count of the number of parameters being passed, this is optional in Cobol. The first parameter passed (second if a count is passed in the first parameter) is a four character field containing the type of database call that you are making. Valid values for this parameter are 'GU ', 'GHU ', 'GN ', 'GHN ','GNP ', 'GHNP', 'ISRT', 'DLET', 'REPL', 'CHKP', and 'XRST'. The next parameter is the PCB mask that we are discussing. This is then followed by an I/O area to contain the record retrieved from (or to be written to) the database and then a number of optional SSAs (segment search arguments) that identify the record within the database to be accessed.
If you perform a Get Next or other database call that does not fully qualify the record to be retrieved from the database then the information in the pcb area contains the location within the database from which the database call will commence the search for the indicated record. The content of this area after the call gives you information about the current location of the pointer within the database as well as the status of the last call. At the very least you should check the status code returned in this field following the call to ensure that the call was successful.
This article written by Stephen Chapman, Felgall Pty Ltd.