Manual de Referencia API
Manual de Referencia API
IBM i
Programming
API overview and concepts
7.1
IBM
IBM i
Programming
API overview and concepts
7.1
Note
Before using this information and the product it supports, read the information in Notices, on
page 573.
This edition applies to IBM i 7.1 (product number 5770-SS1) and to all subsequent releases and modifications until
otherwise indicated in new editions. This version does not run on all reduced instruction set computer (RISC)
models nor does it run on CISC models.
Copyright IBM Corporation 1998, 2010.
US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract
with IBM Corp.
Contents
Application programming interfaces . . 1 User spaces and receiver variables . . . . . . 67
APIs overview . . . . . . . . . . . . . . 1 User spaces . . . . . . . . . . . . 67
| What's new for IBM i 7.1 . . . . . . . . . . 3 General data structure . . . . . . . . 68
PDF file for APIs . . . . . . . . . . . . . 4 Common data structure formats . . . . 69
API concepts . . . . . . . . . . . . . . 4 Example: User space format . . . . . . 72
API terminology . . . . . . . . . . . . 5 List sections . . . . . . . . . . . 73
Generic library names . . . . . . . . . . 5 Receiver variables . . . . . . . . . . 73
API naming conventions . . . . . . . . . 6 Bytes available and bytes returned fields 74
Language selection considerations . . . . . . 8 Keyed interface . . . . . . . . . . 75
Types of APIs. . . . . . . . . . . . . 10 User space alternative . . . . . . . . 75
APIs for the program-based environment . . 10 Continuation handle . . . . . . . . . . 76
APIs for the service-program-based List APIs overview . . . . . . . . . . . 76
environment . . . . . . . . . . . . 10 General data structure for list APIs . . . . 76
APIs for the ILE Common Execution User spaces for list APIs . . . . . . . . 79
Environment . . . . . . . . . . . . 12 Logic flow of processing a list of entries . . 80
Differences between program-based APIs and Manipulating a user space with pointers . 81
service-program-based APIs . . . . . . . 12 Manipulating a user space without pointers 82
Example in ILE C: Logging software errors Examples: Changing a user space . . . . 82
(program API without pointers) . . . . 13 Additional information about list APIs and
Example in OPM COBOL: Logging user spaces . . . . . . . . . . . 86
software errors (program API without Example in CL: Listing database file
pointers) . . . . . . . . . . . . 18 members . . . . . . . . . . . . 86
Example in OPM RPG: Logging software Example in OPM RPG: List APIs . . . . . 87
errors (program API without pointers) . . 21 Example in ILE CL: List APIs . . . . . . 94
Example in ILE RPG: Logging software Example in ILE C: List APIs . . . . . . . 98
error (program API without pointers). . . 24 Example in ILE RPG: List APIs . . . . . 104
Example in ILE C: Reporting software Example in ILE COBOL: List APIs . . . . 109
errors (bindable API with pointers) . . . 26 Domains . . . . . . . . . . . . . . 114
Example in ILE COBOL: Reporting Exit programs . . . . . . . . . . . . 114
software errors (bindable API with User index considerations . . . . . . . . 115
pointers) . . . . . . . . . . . . 30 Performance considerations. . . . . . . . 116
Example in ILE RPG: Reporting software APIs and system objects . . . . . . . . . 116
errors (bindable API with pointers) . . . 33 Open list information format . . . . . . . 116
APIs for the UNIX-type environment . . . . 36 Path name format . . . . . . . . . . . 118
Examples: UNIX-type APIs . . . . . . 36 Using APIs . . . . . . . . . . . . . . 120
API information format . . . . . . . . . 47 Examples: Program-based APIs . . . . . . 120
API description . . . . . . . . . . . 47 Example in OPM RPG: Retrieving the HOLD
API format . . . . . . . . . . . . 50 parameter (exception message) . . . . . 121
API field descriptions . . . . . . . . . 51 Example in ILE COBOL: Retrieving the
API error messages . . . . . . . . . . 51 HOLD parameter (exception message) . . . 126
Extracting a field from the format . . . . . 51 Example in ILE C: Retrieving the HOLD
Processing lists that contain data structures . . 52 parameter (exception message) . . . . . 127
API parameters . . . . . . . . . . . . 52 Example in ILE RPG: Retrieving the HOLD
Passing parameters . . . . . . . . . . 53 parameter (exception message) . . . . . 129
Input and output parameters . . . . . . 53 Example in OPM RPG: Retrieving the HOLD
Offset values and lengths . . . . . . . . 54 parameter (error code structure) . . . . . 133
Offset versus displacement considerations for Example in ILE COBOL: Retrieving the
structures . . . . . . . . . . . . . 54 HOLD parameter (error code structure) . . 139
Error code parameter . . . . . . . . . 54 Example in ILE C: Retrieving the HOLD
Error code parameter format . . . . . 55 parameter (error code structure) . . . . . 141
Examples: Receiving error conditions . . . 57 Example in ILE RPG: Retrieving the HOLD
Using the job log to diagnose API errors. . 58 parameter (error code structure) . . . . . 143
Include files and the QSYSINC library . . . . 59 Example in OPM RPG: Printing the HOLD
Internal object types . . . . . . . . . . 62 value . . . . . . . . . . . . . . 145
Data types and APIs . . . . . . . . . . 66 Example in ILE COBOL: Printing the HOLD
Internal identifiers . . . . . . . . . . . 67 value . . . . . . . . . . . . . . 147
Contents v
vi IBM i: Programming API overview and concepts
Application programming interfaces
IBM i application programming interfaces (APIs) allow your application program written in a high-level
language to use specific data or functions of the i operating system.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer
information on page 571.
APIs overview
This API information describes most of the IBM i APIs and some APIs for related licensed programs that
run on the i operating system.
APIs are intended for experienced application programmers to develop system-level and other IBM i
applications. The API information provides reference only. It is neither an introduction to IBM i nor a
guide to writing IBM i applications.
The API information can be found either by the API name through the API finder or by category through
the API categories page.
In the API finder, you can search for APIs by category, by API name, by descriptive name, or by part of
the name. You can also search for new APIs, changed APIs, and exit programs.
The API categories are major functional categories, such as backup and recovery, objects, and work
management. Within the individual categories, the APIs are organized in alphabetical order as follows:
v By the spelled-out name for the program-based APIs, the service-program-based APIs, and the
Integrated Language Environment (ILE) Common Execution Environment (CEE) APIs.
v By the function name for the UNIX-type APIs.
IBM intends that the APIs will continue to work as they originally worked, and any existing applications
that use the APIs will continue to work without any incompatible changes. Significant architectural
changes, however, might necessitate incompatible changes.
Additionally, some API definitions, such as the UNIX type of API definitions, are established by industry
standards organizations, where the degree of compatibility is determined by the organizations.
In future releases, IBM also intends that one of the following statements is true:
v If additional input or output parameters are provided for any of the APIs, the new parameters will be
placed after the current parameters and will be optional parameters. The existing APIs will continue to
work without any changes.
v If an additional data structure is provided, a new format (layout of that data structure) will be created.
v New information might be added to the end of an existing format.
To ensure better compatibility with future releases, retrieve and use all of the following values when you
work with user spaces that are generated by list APIs:
Before system APIs were offered on the system, you had to either code separate CL programs to perform
the needed functions using the appropriate CL commands or code a call to the Execute Command
(QCMDEXC) API in your program. Both methods made coding an application on the system more
cumbersome (less straightforward and not as fast as possible).
CL commands will always be needed; they are ideal for the interactive user and for CL applications that
are performing basic tasks. They provide a complete set of functions on the system.
APIs are not provided as a replacement for CL commands, although in many cases there might be both
an API and a CL command that perform the same function. If a CL command and an API provide the
same function, at times the API provides more flexibility and information.
Some APIs have no equivalent CL commands. These APIs have been provided in areas where customers
and business partners have indicated that they need high-level language (HLL) access.
An API can be categorized by the type of action it performs and by the system function that it relates to.
Listed here are some of the types of APIs that perform actions; several examples of these APIs are
discussed in more detail in later topics.
v List APIs, which return lists of information about something on the system.
v Retrieve APIs, which return information to the application program.
v Create, change, and delete APIs, which work with objects of a specified type on the system.
v Other APIs, which perform a variety of actions on the system.
Although many APIs are used alone, some APIs can be used together to perform tasks or functions as in
these examples:
v Defining, creating, distributing, and maintaining your own software products.
v Controlling systems and networks, which includes configuration, spooled files, network management,
and problem management.
v Handling objects, which includes creating, changing, copying, deleting, moving, and renaming objects
on the system.
Related reference:
Examples: Using data queues or user queues on page 282
Both data queues and user queues provide a means for one or more processes to communicate
asynchronously. Both queues can be processed by first-in first-out (FIFO), last-in first-out (LIFO), or by
key.
| You can find a list of new APIs or changed APIs for this release using the API finder.
| In addition, the following categories of APIs have been enhanced this release.
| v PowerHA for i APIs
| A sub-category of PowerHA for i APIs has been added in the Cluster category.
| v Sockets-related User Exit Programs
| A new subcategory of exit programs has been added in the Unix-type category, Sockets sub-category.
| GSKit API updates have been made to support several new security attributes.
| The new Suspend System Exit Programs and the Resume System Exit Programs exit points for partition
| migration and hibernation have been added to the Work Management category.
| The Command Analyzer Retrieve Exit Program added a new "Before or after indicator" to specify when
| an exit program should be called (either before or after the command processing program has run.)
| The new Compress Files and Directories and the Decompress Files and Directories APIs have been added
| to the UNIX-Type category under the Integrated File System APIs sub-category.
| The new Configure Activation Engine API was added to the Configuration category.
| API updates have been made to support Ethernet Link Aggregation and Ethernet Bridging.
| The new Retrieve Workload Capping Group Information API was added to the Software Product
| category.
| To help you see where technical changes have been made, the information center uses:
| v The image to mark where new or changed information begins.
| v The image to mark where new or changed information ends.
| In PDF files, you might see revision bars (|) in the left margin of new and changed information.
| To find other information about what's new or changed this release, see the Memo to users.
| To view or download the PDF version of overview and concept information for APIs, select API overview
| and concepts (about 4500 KB). PDFs for API descriptions are no longer provided.
You need Adobe Reader installed on your system to view or print these PDFs. You can download a free
copy from the Adobe Web site (www.adobe.com/products/acrobat/readstep.html) .
API concepts
An application programming interface (API) is a functional interface supplied by the operating system or a
separately orderable licensed program that allows an application program written in a high-level
language to use specific data or functions of the operating system or the licensed program.
API terminology
Before using the IBM i APIs, you need to understand several terms that refer to IBM i objects.
*ALLUSR excludes System/36 libraries that have names starting with the symbol # and that do
not contain user data. The following table lists those libraries.
#CGULIB #RPGLIB
#COBLIB #SDALIB
#DFULIB #SEULIB
#DSULIB
Except for the APIs that are defined by formal standards organizations (for example, UNIX-type APIs), an
API name starts with the letter Q, followed by 2, 3, or 4 letters that comprise an internal component
identifier. The last part of the API name identifies the action or function of the API.
The following table contains all of the verbs that are either part of an API name or are implied verbs
associated with an API name.
Table 1. Verbs and abbreviations for program-based and service-program-based APIs
Verb Abbreviation
access access
Add ADD, Add
Change C, CHG, Chg, ch
Related concepts:
Types of APIs on page 10
IBM i APIs exist in several operating environments on a system.
ILE APIs that are implemented as service programs (*SRVPGM) can be directly accessed only by ILE
languages. For non-ILE languages, the Call Service Program Procedure (QZRUCLSP) API is available to
indirectly access service-program-based APIs. In some cases, an ILE API also provides a program (*PGM)
interface so that non-ILE languages can access the function.
The following table shows the languages that are available with the IBM i operating system and the
parameter support that they provide. See the reference information for the specific programming
language that you plan to use.
Table 3. Language selection considerationscall conventions
1
Language Function return values Pass by reference Pass by value
BASIC X
ILE C X X X
VisualAge C++ for IBM i X X X
CL X
2
ILE CL X X X2
3
COBOL X
ILE COBOL X X X
Related concepts:
User spaces for list APIs on page 79
List APIs require a user space to contain returned information.
Types of APIs
IBM i APIs exist in several operating environments on a system.
Bindable procedure APIs, exported from ILE service programs (*SRVPGM), are independent of the
high-level languages. This can be useful when mixed languages are involved.
APIs based on service programs that are defined by IBM use the following naming conventions:
v Start with the letter Q.
v Are followed by a 2-, 3-, or 4-character internal component identifier.
v Can be up to 30 characters.
v Are case sensitive.
APIs based on service programs that are defined by industry standards follow the industry naming
conventions.
Bindable APIs are contained within service programs to which the calling program binds. Some bindable
APIs provide a program interface for the original program model (OPM) languages. You can usually
distinguish between the *SRVPGM interface and the *PGM interface by the name of the API. For
example, the registration facility APIs provide both a program and a service program entry point
(procedure) interface. For the Register Exit Point API, the service program entry point interface is named
QusRegisterExitPoint and the program interface is named QUSRGPT. A bindable procedure name can be
up to 30 characters and mixed uppercase and lowercase. A program interface name can be up to 8
characters and is all uppercase.
A binding directory is used for APIs that are contained in service programs. A binding directory is a list of
names of modules and service programs that provides a reference by name and type. Service programs
that export bindable APIs are in the QUSAPIBD binding directory. This binding directory is implicitly
used by ILE compilers to resolve the bindable API references; therefore, it is not necessary to explicitly
name the service program or the API binding directory when you create programs that use bindable
APIs. If you provide your own APIs with the same name, make sure that you also provide your own
binding directory or service program.
Most APIs (program-based and service-program-based) have a header file supplied by the IBM i
operating system. These header files reside in the optionally installable library QSYSINC. The header files
provide the prototypes for the API and define any structures that are used by the API. The QSYSINC
library is used by the ILE C compiler to search for header files; therefore, it is not necessary to specify a
library qualifier for any header files that reside in the QSYSINC library. When you code in ILE C,
remember to enclose the header file name in less-than (<) and greater-than (>) symbols because this
affects how the library list is processed in locating the header file.
It is typical for an API that is not retrieving information not to return any output to the caller other than
the error code parameter. If no errors occur when APIs are used, the requested function is completed
successfully.
Related concepts:
API information format on page 47
The format of the IBM i API information includes sections such as parameters, authorities and locks,
required parameter group, format, field descriptions, and error messages.
Examples: Service-program-based APIs on page 185
These program examples demonstrate the use of service-program-based APIs in several different
high-level language programs. The example APIs represent two general functions of APIs: change and
The CEE APIs with names that begin with CEE4 or CEES4 are specific to business computing systems.
APIs based on service programs include the UNIX-type APIs and the ILE Common Execution
Environment (CEE) APIs. You must have the ILE language compiler on your system to develop
applications that use any bindable APIs.
The following table shows the differences between program-based APIs and service-program-based APIs.
Table 4. Comparison of program-based and service-program-based APIs
Description Program APIs Bindable APIs
API name Maximum number of characters: 8. Maximum number of characters: 30.
Not case sensitive. Case sensitive.
Required parameters1 Displayed in the parameter box. Displayed in the parameter box.
Optional parameters Can include optional parameters. The No optional parameters.
optional parameters form a group.
You must either include or exclude
the entire group.
Omitted parameters No omitted parameters. Can include omitted parameters.
When these parameters are omitted,
you must pass a null pointer.
Error conditions2 The error code parameter is common The error code parameter is common
to most of the program-based APIs. It to most of the bindable APIs whose
is used to return error codes and names start with the letter Q. The ILE
exception data to the application. The CEE APIs use feedback codes and
errors that are returned for a given conditions. The UNIX-type APIs
API are in the form of an error generally use errnos to provide
message and a 7-character message error-related information.
identifier.
In the examples that follow, a program-based API and a service-program-based API are used to perform
similar functions (log or report software errors). The bindable API uses pointers while the program API
does not. Both APIs log software errors by using first-failure data capture (FFDC).
Related concepts:
API parameters on page 52
After you decide which API to use, you need to code a call to the API and pass to the API the set of
parameters that are appropriate for it.
Related reference:
Errno Values for UNIX-Type Functions
This ILE C program calls the Log Software Error (QPDLOGER) API to perform first-failure data capture
(FFDC) without using pointers.
The ILE C program physically moves the data that is pointed to, as shown at (1), which slows down
performance.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer
information on page 571.
/*********************************************************************/
/* */
/*Program Name: FFDCPGM1 */
/* */
/*Program Language: ILE C */
/* */
/*Description: This program illustrates how to use APIs to log */
/* software errors using FFDC. */
/* */
/* */
/*Header Files Included: except */
/* stdio */
/* string */
/* qmhchgem */
/* qpdloger */
/* qusec */
/* */
/*APIs Used: QPDLOGER */
/* */
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
/* Miscellaneous Includes */
/*********************************************************************/
#include <qmhchgem.h>
#include <qpdloger.h>
#include <qusec.h>
/*********************************************************************/
/* Structures */
/*********************************************************************/
typedef struct {
void *parm1;
void *parm2;
char *pgm_name;
int pgm_name_size;
} ffdc_info_t;
/*********************************************************************/
/* Prototypes */
/*********************************************************************/
void UNEXPECTED_HDLR(_INTRPT_Hndlr_Parms_T *);
/*********************************************************************/
/* FUNCTION NAME: main */
/* */
/* FUNCTION: Generates exception and then passes control */
/* to exception handler. */
/* */
/* INPUT: Two character strings. */
/* */
/* OUTPUT: NONE */
/* */
/* EXCEPTIONS: CPFxxxx - All unexpected CPF exceptions */
/* MCHxxxx - All unexpected MCH exceptions */
/* */
/*********************************************************************/
void main(int argc, char *argv[])
{
/*******************************************************************/
/* NOTE: argv will contain the parameters passed in to this */
/* function. In this case, two parameters are passed */
/* in. */
/*******************************************************************/
/*******************************************************************/
/* The argv parameter contains the parameters that were passed as */
/* character arrays. argv[0] contains the program name, and the */
/* parameter(s) starts with argv[1]. */
/*******************************************************************/
/*******************************************************************/
/* Set up FFDC information for unexpected error. */
/*******************************************************************/
ffdc_info.parm1 = argv[1];
ffdc_info.parm2 = argv[2];
/*******************************************************************/
/* Enable the exception handler, and pass ffdc_info into the */
/* exception handler via the communications area so that data */
/* can be used for FFDC. */
/*******************************************************************/
/*******************************************************************/
/* Set the pointer to null, then try to increment. This will */
/* generate an MCH3601 error that will be trapped by the */
/* unexpected handler. */
/*******************************************************************/
nulptr = NULL;
nulptr++;
#pragma disable_handler
} /* main */
/*********************************************************************/
/* FUNCTION NAME: UNEXPECTED_HDLR */
/* */
/* FUNCTION: Handle unexpected exception. This exception */
/* handler is used to log the software error via */
/* FFDC. */
/* */
/* INPUT: Interrupt handler information */
/* */
/* OUTPUT: NONE */
/* */
/* EXCEPTIONS: CPFxxxx - All unexpected CPF exceptions */
/* MCHxxxx - All unexpected MCH exceptions */
/* */
/*********************************************************************/
void UNEXPECTED_HDLR(_INTRPT_Hndlr_Parms_T *errmsg)
{
typedef struct {
char obj_name[30];
char obj_lib[30];
char obj_type[10];
} obj_info_t;
typedef struct {
int data_offset;
int data_length;
} data_info_t;
char pgm_suspected[10],
msg_id[12],
msg_key[4],
print_job_log,
data[2*(sizeof(char *))],
*data_item,
ile_mod_name[11];
int point_of_failure,
num_items,
num_objs;
data_info_t data_info[2];
obj_info_t obj_info[1];
ffdc_info_t *ffdc_info;
Qus_EC_t ErrorCode;
/*******************************************************************/
/* Getting pointer in local storage to the Communications Area. */
/*******************************************************************/
ffdc_info = (ffdc_info_t *)(errmsg->Com_Area);
/*******************************************************************/
/* Need to notify message handler that we will handle the error. */
/* Leave the message in the job log, just mark it handled. */
/*******************************************************************/
QMHCHGEM(&(errmsg->Target), /* Invocation pointer */
0, /* Call stack counter */
(char *)&errmsg->Msg_Ref_Key,/* Message key */
"*HANDLE ", /* Modification option */
"", /* Reply text */
0, /* Reply text length */
&ErrorCode); /* Error code */
/*******************************************************************/
/* Set up the suspected program. */
/*******************************************************************/
memcpy(pgm_suspected, "*PRV ", 10);
/*******************************************************************/
/* Set up the detection identifier. */
/*******************************************************************/
memset(msg_id, , 12);
memcpy(msg_id, errmsg->Msg_Id, 7);
/*******************************************************************/
/* Set up the message key. */
/*******************************************************************/
memcpy(msg_key, (char *)&errmsg->Msg_Ref_Key, 4);
/*******************************************************************/
/* Set up point of failure. Since this example program is small */
/* and we know where the error occurred, we will just put a dummy */
/* value in. However, this can be very useful information in */
/* larger programs. */
/*******************************************************************/
point_of_failure = 100;
/*******************************************************************/
/* Set up to print the job log. */
/*******************************************************************/
print_job_log = Y;
/*******************************************************************/
/* Set up data items. */
/*******************************************************************/
data_item = data;
/*******************************************************************/
/* Put in first parameter. */
/*******************************************************************/
memcpy(data_item, (char *)ffdc_info->parm1, sizeof(char *)); (1)
/*******************************************************************/
/* Add in the second parameter. */
/*******************************************************************/
data_item += sizeof(char *);
memcpy(data_item, (char *)ffdc_info->parm2, sizeof(char *));
/*******************************************************************/
/* Reset the data item pointer. */
/*******************************************************************/
/* Set up data item offset/length information. */
/*******************************************************************/
data_info[0].data_offset = 0;
data_info[0].data_length = sizeof(char *);
data_info[1].data_offset = sizeof(char *);
data_info[1].data_length = sizeof(char *);
/*******************************************************************/
/* Set up the number of data items. In this case we only have one.*/
/*******************************************************************/
num_items = 2;
/*******************************************************************/
/* Set up the object name array. In this case, we have no objects */
/* to dump, but we will put dummy values in to illustrate. */
/*******************************************************************/
memcpy(obj_info[0].obj_name, "OBJUSRSPC ", 30);
memcpy(obj_info[0].obj_lib, "QTEMP ", 30);
memcpy(obj_info[0].obj_type, "*USRSPC ", 10);
/*******************************************************************/
/* Set the number of objects in name array. */
/*******************************************************************/
num_objs = 0;
/*******************************************************************/
/* Set up the ILE module name. */
/*******************************************************************/
memcpy(ile_mod_name, ffdc_info->pgm_name, ffdc_info->pgm_name_size);
/*******************************************************************/
/* Call QPDLOGER to perform FFDC. */
/*******************************************************************/
ErrorCode.Bytes_Provided = sizeof(ErrorCode);
QPDLOGER(pgm_suspected,
msg_id,
msg_key,
point_of_failure,
&print_job_log,
data_item,
data_info,
num_items,
obj_info,
num_objs,
&ErrorCode,
ile_mod_name);
} /* UNEXPECTED_HDLR */
Related reference:
Example in OPM COBOL: Logging software errors (program API without pointers) on page 18
One OPM COBOL program registers an error handler. After successful completion of the registration, this
program creates a data decimal error. The error causes the error handler, the other OPM COBOL
program, to call the Log Software Error (QPDLOGER) API without using pointers.
Example in OPM RPG: Logging software errors (program API without pointers) on page 21
This OPM RPG program performs a divide-by-zero operation to cause an exception. The exception is
caught with RPG *PSSR support, which calls the Log Software Error (QPDLOGER) API to perform FFDC
without using pointers.
Example in ILE RPG: Logging software error (program API without pointers) on page 24
This ILE RPG program performs a divide-by-zero operation to cause an exception. The exception is
caught with RPG *PSSR support, which calls the Log Software Error (QPDLOGER) API to perform FFDC
Application programming interfaces 17
without using pointers.
Example in OPM COBOL: Logging software errors (program API without pointers):
One OPM COBOL program registers an error handler. After successful completion of the registration, this
program creates a data decimal error. The error causes the error handler, the other OPM COBOL
program, to call the Log Software Error (QPDLOGER) API without using pointers.
The program CBLERR1 registers the error handler and causes the error. The program ERRHDL1 receives
control and calls the QPDLOGER API to perform FFDC.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer
information on page 571.
CBLERR1 program
IDENTIFICATION DIVISION.
***************************************************************
***************************************************************
*
* Program: Register an OPM COBOL Error Handler
* Cause a data decimal exception to demonstrate
* logging of software errors
*
* Language: COBOL
*
* Description: This program registers an OPM COBOL Error
* Handler. After the successful completion of
* the registration of the error handler, this ,
* program creates a data decimal error. This
* exception causes the error handler to be
* called which then logs the software error.
*
* APIs Used: QLRSETCE - Set COBOL Error Handler
*
***************************************************************
*
***************************************************************
PROGRAM-ID. CBLERR1.
INPUT-OUTPUT SECTION.
DATA DIVISION.
WORKING-STORAGE SECTION.
*
* Error Code parameter include. As this sample program
* uses COPY to include the error code structure, only the first
* 16 bytes of the error code structure are available. If the
* application program needs to access the variable length
* exception data for the error, the developer should physically
* copy the QSYSINC include and modify the copied include to
* define additional storage for the exception data.
*
COPY QUSEC OF QSYSINC-QLBLSRC.
*
* Miscellaneous elements
*
01 MISC.
05 Y PIC S9(09) VALUE 0.
05 ERROR-HANDLER PIC X(20) VALUE "ERRHDL1 *LIBL ".
05 SCOPE PIC X(01) VALUE "C".
05 ERROR-HANDLER-LIBRARY PIC X(10).
05 PRIOR-ERROR-HANDLER PIC X(20).
01 NUMERIC-GROUP.
05 X PIC 9(03).
*
* Beginning of mainline
ERRHDL1 program
IDENTIFICATION DIVISION.
****************************