C H A P T E R 16 |
Accessing VSAM Files From External Programs |
This chapter describes how Sun MTP supports the C-ISAM interface and how to execute C programs that are not defined as region resources. The topics include:
C-ISAM is an interface that enables C language batch and online programs to access a region's VSAM files. This section contains:
Note - Refer to the C-ISAM Programmer's Manual for information about using the
|
The C-ISAM functions support both fixed- and variable-length records.
The Sun MTP C-ISAM interface is implemented to operate in one of two environments:
For most functions, the user does not need to be aware in which environment the program is running. However, to properly use isbegin, iscommit, and isrollback, you must consider these factors:
Note - A single batch job might execute multiple steps (programs) before the implicit COMMIT takes effect. |
When using C-ISAM, Sun MTP handles recovery and rollback. Therefore, it is not necessary to create or use C-ISAM log files. The C-ISAM interface provides functions for third-party software that includes calls to islogopen and islogclose. These functions return with a successful indicator when the function is called.
Sun MTP does not support roll forward recovery using after images.
The C-ISAM interface adheres to all Sun MTP requirements. It requires a region to be executing. Because data files are defined and created within the region, functions such as iserase and isbuild are not valid.
The isbuild function is implemented as follows:
It calls isopen passing the filename and mode arguments that were passed to it. The other three arguments are ignored. This call is treated like the normal isopen function. filename must already exist and be defined in the region.
The following functions are implemented and return a status of SUCCESSFUL even though they do nothing but return:
Sun MTP supports two functions that are not part of the C-ISAM standard.
Receives a dataset name and returns the full path name including the file name for that dataset to the specified buffer. The buffer size must be specified with the size argument. A value of -1 is returned if an error occurs. The global variable iserrno contains the specific error code. If the dataset is not part of the Sun MTP region, iserrno contains the value 111 (ENOREC). If the buffer is not big enough to handle the full path name, a value of 98 (MAXFILESEXC) is returned in iserrno.
Used only by third-party software that needs to connect to the Sun MTP region's shared memory before the normal open/close functions are invoked. It is only available to batch jobs.
If an online job tries to execute this function, a -1 is returned, and iserrno contains the value 95 (BTCHONLY95).
This function can be called by a process only once. Any additional calls return a value of -1, and iserrno contains the value 1.
C-ISAM functions only return an integer code. A return code greater than or equal to zero indicates that the function executed successfully. If the return code is negative, the function failed. To determine the reason for failure, examine the global error variable, iserrno.
Four types of errors are returned:
1. Error code ENOENT if file does not exist
2. Sun MTP system errors, Codes 90 through 99
3. VSAM error codes that map directly to C-ISAM error codes as defined in the
C-ISAM Programmer's Manual; from 100 through 171. The control errors, such as EOF and No record found matching Key, are mapped to C-ISAM error codes.
4. VSAM error codes that do not map to C-ISAM errors are returned as the integer equivalent of the VSAM error codes defined as Micro Focus File Status Codes.
Example: A code returned in iserrno is error code 2. This error code is returned on a read next of a dataset that is an Alternate Key Dataset, and for which there exists at least one other record with the same duplicate key.
The record is correctly returned, but the status of -1 is returned and iserrno contains a 2 as a warning to the user that records with duplicate keys exist in this Alternate Key Dataset.
This follows the same logic that occurs when a user reaches the end of file on a read next.
Note - The COBOL variables isstat1, isstat2, isstat3, and isstat4 are not set because they are only used by COBOL programs. |
This section describes how to access VSAM files using C programs that do not use the CICS API. These C programs are not defined as resources within a region.
Sun MTP supports the execution of C language programs that access VSAM files with the C-ISAM interface. Before executing these C programs, you must compile them. You can only execute the programs on a system running the same version of Sun MTP as the system where the programs were compiled.
See Supported Functions.
Compiling the C Language Program |
1. Set the UNIKIX environment variable to the Sun MTP version where this program will execute.
2. Include the isam.h header file in your C program.
This file is located in the $UNIKIX/src/CICS_structures directory.
3. Execute the following command, either on the command line or in a script file, to compile the program and create the executable.
4. Make sure that there are execute permissions on the file.
To Execute the C Program |
1. Verify that the Maximum query jobs field in the region's VCT contains a value of 1 or greater.
This value specifies the number of programs that can execute at the same time.
2. At the command prompt, set the KIXCISAM environment variable to the full path name and file name of the C language executable.
3. Start and connect to the region whose VSAM files the program will access.
4. At the command prompt, execute the kixcisam utility.
This utility runs the program defined by the KIXCISAM environment variable and monitors its execution. Refer to the Sun Mainframe Transaction Processing Software Reference Guide for additional information about kixcisam.
Copyright © 2004, Sun Microsystems, Inc. All rights reserved.