Skip to Main Content
IBM Power Ideas Portal


This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Delivered
Workspace IBM i
Categories Languages - RPG
Created by Guest
Created on Mar 12, 2023

Allow use of constant in ON-EXCP

Using constants in ON-EXCP would make the code more readable, and allow to share message ids in includes.


Example:


dcl-c ERR_CUSTOMER_NOT_FOUND 'ERR3452';


monitor;

// do something..

on-excp ERR_CUSTOMER_NOT_FOUND;

// handler

endmon;

Idea priority Medium
  • Guest
    Reply
    |
    May 17, 2023
    IBM believes that the solution for the Idea described is available with PTFs for 7.3, 7.4, and 7.5.

    You can now specify a global named constant for an ON-EXCP statement in a subrocedure.

    The following PTFs provide this support:

    7.3:
    ILE RPG compiler: 5770WDS SI83429

    7.4:
    ILE RPG compiler: 5770WDS SI83497
    ILE RPG compiler, TGTRLS(V7R3M0): 5770WDS SI83483

    7.5:
    ILE RPG compiler: 5770WDS SI83480
    ILE RPG compiler, TGTRLS(V7R4M0): 5770WDS SI83496
    ILE RPG compiler, TGTRLS(V7R3M0): 5770WDS SI83494

    - IBM Power Systems Development
  • Guest
    Reply
    |
    Mar 22, 2023

    Just an idea

    It is possible to specify several individual message ids on the on-excp statement.
    You could enhance it to monitor for a range of message ids using the %range() function.

    like this:

    on-excp %range('ERR1234' : 'ERR1239');




  • Guest
    Reply
    |
    Mar 14, 2023

    If the named constant is defined in the subprocedure, that also works now.

    dcl-proc subp;
    dcl-c ERR_CUSTOMER_NOT_FOUND 'ERR1234';
    monitor;
    on-excp ERR_CUSTOMER_NOT_FOUND; // ok
    endmon;
    end-proc;


    But ... if the constants are in a copy file, it's not ideal to copy the constants into every subprocedure.

    As a temporary circumvention, you could keep the /copy in the global definitions, and create a temporary copy file that just has a /copy of your constants. Then add a /copy statement with the temporary copy file in each of the subprocedures that needs the constants. When this Idea is implemented, you could scan your code for the temporary copy file and remove the extra /copy statements, leaving only the real /copy statement in the global definitions. That way, you would not have to wait to code the named constants in the ON-EXCP statements.

    /copy constants
    dcl-proc subp;
    /copy temp_constants // remove this /copy when IBMI-I-3567 is implemented
    monitor;
    on-excp ERR_CUSTOMER_NOT_FOUND;
    endmon;
    end-proc;


    - Barbara Morris

  • Guest
    Reply
    |
    Mar 14, 2023

    Ok, thanks. We don't write much code in cycle main anymore. Support for named constants in procedures would be appreciated :)

  • Guest
    Reply
    |
    Mar 13, 2023
    IBM will use this Idea as input to planning, but no commitment is made or implied. This Idea will be updated in the future if IBM implements it. IBM will use votes and comments from others in the community to help prioritize this Idea.

    Note that the RPG compiler does support named constants in general for ON-EXCP, but it does not support global named constants in a subprocedure.

    The following source compiles:

    dcl-c ERR_CUSTOMER_NOT_FOUND 'ERR1234';
    monitor;
    on-excp ERR_CUSTOMER_NOT_FOUND;
    endmon;
    return;

    The following source does not compile. Message RNF0203 is issued against the ON-EXCP statement in the subprocedure.

    dcl-c ERR_CUSTOMER_NOT_FOUND 'ERR1234';
    subp();
    return;

    dcl-proc subp;
    monitor;
    on-excp ERR_CUSTOMER_NOT_FOUND; // RNF0203
    endmon;
    end-proc;

    - IBM Power Systems Development