IBM Support

RPG Cafe: Spring 2022: New messaging opcodes SND-MSG and ON-EXCP

News


Abstract

RPG enhancement delivered through PTFs in the fall of 2022. New opcodes SND-MSG and ON-EXCP.

Content

You are in: RPG Cafe > RPG Cafe: Spring 2022: New messaging opcodes SND-MSG and ON-EXCP

Short URL: https://ibm.biz/rpgcafe_spring_2022_new_messaging_opcodes

Spring: New messaging opcodes

  • SND-MSG: Send an info or escape message
  • ON-EXCP: Monitor for a specific message ID

Warning

If you use the SND-MSG or ON-EXCP in your program, you need a runtime PTF on any system where you run the program.

Details

ON-EXCP

Use the ON-EXCP opcode to monitor for a specific message ID. The ON-EXCP opcodes precede any ON-ERROR opcodes in your monitor group.

By default, ON-EXCP can monitor for an unhandled escape message sent to a program or procedure called from the monitor block. If you want to monitor only for messages sent directly to the procedure containing the monitor group, you can specify ON-EXCP(C).

          monitor;
             create_new_account ();
          on-excp 'ARV0203' : 'ARV0204';
             // handle two ARV messages
          endmon;

SND-MSG

Use the SND-MSG opcode to send an informational or escape message. The message type defaults to *INFO.

In the joblog, the "sender" information for the message indicates the procedure and statement number where the message was sent.

The message can be

  • A string
              SND-MSG 'Unexpected error';
    
  • The %MSG built-in function
              arv0203_reptext.badFile = filename;
              arv0203_reptext.badIdno = id_no;
              SND-MSG %MSG ('ARV0203' : 'ARVMSGS' : arv0203_reptext);
    

By default, an informational message is sent to the current procedure and an escape message is sent to the caller of the current procedure. You can use %TARGET to control where the message is sent.

  1. The first operand is the target invocation on the program stack.
  2. The second optional operand is the "stack offset" from that invocation. It defaults to zero. For example, a value of 1 indicates that you want to send the message to the caller of the specified invocation. A value of 2 indicates that you want to send the message to the caller's caller.
          // Send a message to the caller of our main procedure
          // - stack offset = 2 since the "caller" is actually the
          //   PEP for the program
          SND-MSG *ESCAPE 'Unexpected customer type ' + type
                           %TARGET('ARVMAIN' : 2);
.                                                            .
.                                                            .

PTFs for 7.3, 7.4, and 7.5, available in May 2022

Warning: If you use SND-MSG or ON-EXCP in your program, you need a runtime PTF on every system where the program runs. If the runtime PTF is not applied on the system where the program is running, the calling program fails with MCH4437 saying that a program export is not found.

7.3:

  • ILE RPG runtime: 5770SS1 SI79656
  • ILE RPG compiler: 5770WDS SI79717

7.4:

  • ILE RPG runtime: 5770SS1 SI79655
  • ILE RPG compiler: 5770WDS SI79711
  • ILE RPG compiler, TGTRLS(V7R3M0): 5770WDS SI79719

7.5:

  • ILE RPG runtime: 5770SS1 SI79642
  • ILE RPG compiler: 5770WDS SI79659
  • ILE RPG compiler, TGTRLS(V7R3M0): 5770WDS n/a for iAPAR SI79720
  • ILE RPG compiler, TGTRLS(V7R3M0): 5770WDS SI79718

The PTFs are also available with the Db2 for i Fix Packs. See Db2 for IBM i 2022 PTF Group Schedule.

RDi support

The next update for RDi will support these enhancements.

Documentation

The 7.3, 7.4, and 7.5 ILE RPG Reference and ILE RPG Programmer's Guide are updated with full information about these enhancements. Start at the "What's new since 7.3", "What's new since 7.4", or "What's new in 7.5" section in the Reference.

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SS69QP","label":"Rational Development Studio for i"},"ARM Category":[],"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.3.0;and future releases"}]

Document Information

Modified date:
03 May 2022

UID

ibm16568841