IBM Support

RPG Cafe: Spring 2024: Define constant standalone fields and data structures



Information about the PTFs to provide the ILE RPG enhancement to define constant standalone fields and data structures


You are in: RPG Cafe > RPG Cafe: Spring 2024: Define constant standalone fields and data structures

Short URL:

Spring 2024: Define constant standalone fields and data structures

  • Add the CONST keyword for a standalone field or data structure. Similar to parameters defined with the CONST keyword, the variable cannot be modified in the module.
  • Unlike ordinary data structures which default to being initialized to blanks, all the subfields of a constant data structure are initialized.

Example of a constant standalone field

The originalUserid field is initiaiized at the beginning of the procedure to the current user profile. The compiler does not allow any statements that would change the value of the field. The example shows the error message when the procedure tries to change the constant variable.

          dcl-proc myproc;
             dcl-s originalUserid char(10) inz(*user) const;

             ... code that may swap the current user profile
             if originalUserid <> getCurrentUserid();
                ... code to restore the current user profile
                originalUserid = *BLANK;
          *RNF5346 30 a      002500  The operation modifies the field,
                                     but the field cannot be modified.

Example of a constant data structure

The programmer can rely on the fact that the subfields of the defaults data structure can never change after they are initialized.

          dcl-ds defaults qualified const;
             account_type int(10) inz(STANDARD_ACCOUNT);

          dcl-proc create_new_account;
             dcl-pi *n;
                new_account likeds(account_t);
                cust_id int(10) const;
                cust_type int(10) const;
             dcl-ds new_account likeds(account_t);

             eval-corr new_account = defaults;
             new_account.customer_id = cust_id;
             if cust_type <> defaults.account_type;
                setup_special_account (new_account : account_type);

.                                                            .
.                                                            .

PTFs for 7.4 and 7.5


  • ILE RPG compiler: 5770WDS SJ00635


  • ILE RPG compiler: 5770WDS SJ00650
  • ILE RPG compiler, TGTRLS(V7R4M0): 5770WDS SJ00653

The PTFs will also be available with later 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.


The 7.4 and 7.5 ILE RPG Reference and ILE RPG Programmer's Guide are updated with full information about these enhancements.

[{"Type":"MASTER","Line of Business":{"code":"LOB73","label":"Power TPS"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SS69QP","label":"Rational Development Studio for i"},"ARM Category":[{"code":"a8m0z0000000C4BAAU","label":"IBM i"}],"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.4.0;7.5.0;and future releases"}]

Document Information

Modified date:
04 June 2024