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 Functionality already exists
Workspace IBM i
Categories Languages - RPG
Created by Guest
Created on May 19, 2026

Add CCSID keyword to declared constants

Situation

When we run a program in environments with different CCSID's and that program is using literals containing characters with different code points in different CCSID's (like square brackets '[' and ']' in CCSID 1140 and 1148) then ctl-opt CCSID(*EXACT) comes in handy. Thank you for providing that!

Problem description

The downside of using that control option is that functions like %scan, %scanr and %scanrpl (and probably others) become picky when the first parameter is a literal string. I ran into problems concatenating x'0D0A' (CRLF) as well but will focus on %scan in the examples provided below. 

Normally this works well (with default CCSID(*NOEXACT) ) 

dcl-s myText char(10);
dcl-s position int(5);
position = %scan('A': myText);

 

With CCSID(*EXACT) this fails compiling with "RNF0353 The first and second parameters of %SCAN or %SCANR are not of the same type."                                               

ctl-opt ccsid(*exact);

dcl-s myText char(10);
dcl-s position int(5);
position = %scan('A': myText) 

 

When you use this constant value 'A' multiple times, it's always better to create a constant, so let's do that. However, this code still fails compilation with RNF0353.

ctl-opt ccsid(*exact);

dcl-s myText char(10);
dcl-s position int(5);
dcl-c constA 'A';

position = %scan(constA: myText) 

 

Only when 'A' is defined as an initial value for a variable it will compile

ctl-opt ccsid(*exact);

dcl-s myText char(10);
dcl-s position int(5);
dcl-s varA varchar(1) inz('A');

position = %scan(varA: myText) 

position = %scan(%char('A'): myText) 

 

Also an explicit cast to a character value works, provided that the CCSID's match

ctl-opt ccsid(*exact) ccsid(*char: 1148);

dcl-s myText1140 char(10) CCSID(1140);
dcl-s myText1148 char(10); // implicitly ccsid 1148
dcl-s position int(5);

// compiles
position = %scan(%char('A'): myText1148) 

// compiles
position = %scan(%char('A': 1140): myText1140) 

// fails
position = %scan(%char('A'): myText1140) 

 

Suggested solution

What I would like to see is that the functions like %scan can handle a constant as parameter, even with CCSID(*EXACT). I think that this requires the constant to be defined with a CCSID as well because variant characters like '[' and ']' need to be defined with a CCSID in order to know the hex value associated with them. 

ctl-opt ccsid(*exact);

// variant constant characters with different hex representations
dcl-c con1 '[' ccsid(1140);
dcl-c con2 '[' ccsid(1148);
dcl-c con3 '[' ccsid(*utf8);

 

This would be necessary for dcl-enum as well.

 

Idea priority Medium
  • Guest
    May 21, 2026
    With CCSID(*EXACT), the literal values are converted to the required CCSID when it is necessary.

    There may still be a few situations where the compiler does not allow the literal when CCSID(*EXACT) is specified.

    But if there are cases where the literal value is not handled correctly with CCSID(*EXACT), such as in a concatenation, that should be reported to IBM as a defect.

    In general, it would not be a good idea to use a hexadecimal literal to represent a value with a particular CCSID. The RPG programmer would have to be very careful to only use the hexadecimal literal in the context of the intended CCSID.

    - IBM Power Systems Development
  • Guest
    May 21, 2026

    Hi,

    Thank you for your quick response. I wasn't aware of these PTF's and will ask the administrator to load them.

    This solves the compiler issue but still the question remains of how to differentiate between constants with different CCSID's like these

    // variant constant characters with different hex representations
    dcl-c con1 '[' ccsid(1140);
    dcl-c con2 '[' ccsid(1148);
    dcl-c con3 '[' ccsid(*utf8);

    One would need to declare these with a hexadecimal value or declare a variable with the const keyword. Is that one of the intended applications for the const keyword in variables?

    dcl-s var1 varchar(1) inz('[') ccsid(1140) const;
    dcl-s var2 varchar(1) inz('[') ccsid(1148) const;
    dcl-s var3 varchar(1) inz('[') ccsid(*utf8) const;
  • Guest
    May 19, 2026
    With PTFs for 7.5 and 7.6, the compiler no longer gives an error when the operands of %SCAN and the other string built-in functions have different CCSIDs. The compiler now automatically performs any necessary CCSID conversion.

    For information about the implicit CCSID conversions for the string built-in functions, see https://www.ibm.com/docs/en/i/7.6.0?topic=data-conversions.

    For PTF information, see https://www.ibm.com/support/pages/node/7246939.

    - IBM Power Systems Development