Previous Topic: Message Handling by Batch Programs

Next Topic: Coding Standards for Help Text

Using the Message Handling API

V2R2 of OS/400 includes new message handling APIs for sending, receiving, and retrieving messages directly from HLL programs (previously, CL had to be used for most operations). You should use the APIs in preference to CL subprograms not only for performance reasons, but because the APIs allow you to identify the destination program message queues by a relative invocation number. This makes it possible to send messages without knowledge of the program name of the destination message queue. (CL only allows you to identify the program previous to the current or a named program, so cannot it cope with recursion). Such a facility is important when writing reusable code routines.

For example, consider the following case of a standard subprogram D, called at the bottom of a program invocation stack A, B, A (the second call is recursive). If program D needs to send a message back to the program that calls the topmost invocation of program A, it can do so by using a relative invocation stack number. With CL this cannot be done.

Sending programs by relative invocation:

QMHSNDPM call