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 Not under consideration
Workspace IBM i
Categories Languages - RPG
Created by Guest
Created on Feb 28, 2018

Cast string value to specified CCSID

How do you convert a character field with embedded UCS2 characters into a UCS2 field? It would be nice to be able to substring out a bit and just say that this piece is already UCS2, don't convert it. The only thing we can do right now is say "convert this piece to UCS2" with the %ucs2() built-in. It would be nice to have a %cast(field: *ucs2) or something like that to not convert but just tell the compiler that this thing is already UCS2, don't convert it.


Use Case:

When substringing from a data structure (where the structure contains UCS2 data), the data structure itself assumes the job CCSID, and %substr does not recognise embedded UCS2 characters. The workaround is to convert substringed bits of the datastructure to UCS, and concatenate that directly to the UCS fields, but if %substr() is necessary, This does not compile:

ucs2field = %ucs2(%subst(structure: 1: 11)) + %subst(structure: 12: 2);

Because the operands are not compatible (UCS2 on one side, and Char on the other) even though we know that they are.


Idea priority Low
  • Guest
    Reply
    |
    Jul 6, 2018

    IBM does not intend to provide a solution to this request at this time, so it is being closed.

    If the positions of non-character sections of the data structure are always the same, as in the example, then the solution is to define subfields of the required type.

    However, if the positions are not known in advance, then the solution is to define another data structure with a subfield of the required type. Assign the %SUBST value to the second data structure, and now the subfield in the second data structure will have the required value. Here is an example:

    dcl-ds data len(100) end-ds; // Data with embedded UCS-2
    dcl-ds ucs2_ds qualified; // DS to "cast" to UCS-2
    val ucs2(100);
    end-ds;
    dcl-s start int(10);
    dcl-s len int(10);
    dcl-s ucs2_result varucs2(100);

    data = 'abc' + x'003100320033' + 'def';
    // positions 4-9 have UCS2 data, value '123'

    start = 4;
    len = 6;

    ucs2_ds = %subst(data : start : len);
    ucs2_result = %subst(ucs2_ds.val : 1 : %div(len : 2));

    In debug: UCS2_RESULT = 123

  • Guest
    Reply
    |
    Mar 9, 2018

    Due to processing by IBM, this request was reassigned to have the following updated attributes:
    Brand - Servers and Systems Software
    Product family - Power Systems
    Product - IBM i
    Component - Languages - RPG
    Operating system - IBM i
    Source - None

    For recording keeping, the previous attributes were:
    Brand - Servers and Systems Software
    Product family - Programming Languages
    Product - Developer for Power Systems
    Component - RPG/COBOL Development Tools
    Operating system - IBM i
    Source - None