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 Apr 17, 2019

Enhance DCL-DS to emulate "i-Spec Member Format Identifier" in **free & /free

When using **free (or /free) RPG, there is nowhere to specify the use of i-specs within the particular program.

Overall, I agree with this, as i-specs really shouldn't be used.

However - there are times, because of the way a logical file has been created (multi-member), that using i-specs for record-level identification can be quite helpful.

Let me be clear - I'm not looking to add in an "i-spec" in Free-format - I'm looking to expand upon dcl-ds or similar via key keywords, to provide similar functionality that the "i-specs" had when it came to multi-member logical files.

The way I've been getting around it is via a /define & /include to the "i_specs"

/define pgmA
/include mylib/myfile,my_i_specs

In "my_i_specs"

/if defined(pgmA)
il1rx 01
il2rx 02
il3rx 03
/endif

/if defined(pgmB)
im1rx 01
im2rx 02
im3rx 03
/endif

etc.

While this helps to keep this "ugly" code outside of the program, it would be beneficial if IBM could develop a dcl that could help add-in record-level identification, without needing to resort to "i-specs".

An example could be something like this, where the dcl-ds declaration has a new keyword added to it.

In this example, I made up keyword likembr - maybe something less cryptic such as RecordFormat, RecordID, etc could be used instead.

dcl-ds Record_Formats based(p_Indicators);
L1Record ind likembr(l1rx) pos(1);
L2Record ind likembr(l2rx) pos(2);
L3Record ind likembr(l3rx) pos(3);
end-ds;

I feel that this code is a much better way to identify an "indicator" with a member format than using /include with I-Specs.

Additionally, if there was an easy way to automatically rename fields within the record format, it would be a bonus.

Example:
/if defined(pgmA)
il1rx 01
i l1item ItemNum
i l1cust CustNum
il2rx 02
i l2item ItemNum
i l2cust CustNum
il3rx 03
i l3item ItemNum
i l3cust CustNum
/endif

dcl-ds Record_Formats based(p_Indicators);
L1Record ind likembr(l1rx) pos(1) rename(l1item: ItemNumber) rename(l1cust: CustomerNumber);
L2Record ind likembr(l2rx) pos(2) rename(l2item: ItemNumber) rename(l2cust: CustomerNumber);
L3Record ind likembr(l3rx) pos(3) rename(l3item: ItemNumber) rename(l3cust: CustomerNumber);
end-ds;


Use Case:

Makes code easier to read & maintain


Idea priority Low
  • Guest
    Reply
    |
    Jun 7, 2019

    It is very unlikely that this requirement will be implemented for RPG, so it is being closed.

    However, there is already a way to deal with multi-format logical files without using I specs.

    1. Define an INFDS for your file, so you can find out which record format was read.
    2. Define an ordinary data structure for your file which you can use with EVAL-CORR to copy the data from the data structure in #4. This data structure will just list the fields from the file, without defining any types. It should not be qualified.
    3. Define an externally-described data structure for each of the formats, using the EXTFLD keyword to handle renames.
    4. Define another data structure with subfields defined with POS(1) and LIKEDS of these data structures. You could even define the sub-data structures directly as nested data structures, but this example defines separate data structure templates.
    5. For your READ or CHAIN, specify the data structure from #4 in the result field of the opcode.
    6. After the READ or CHAIN, use the INFDS to find out which format was read, and use EVAL-CORR to copy the subfields from the relevant subfield to the data structure defined in #2. Also, set the *INxx indicators, if your program uses them later.

    dcl-f myfile infds(myfileInfds);
    dcl-ds myfileInfds qualified; // #1
    format *RECORD;
    end-ds;
    dcl-ds myfileFields; // #2
    ItemNumber;
    CustomerNumber;
    ...
    end-ds;

    dcl-ds L1Record_t extname('MYFILE' : 'L1RX') qualified template; // #3
    ItemNumber extfld(l1item);
    CustomerNumber extfld(l1cust);
    end-ds;
    dcl-ds L2Record_t extname('MYFILE' : 'L2RX') qualified template;
    ItemNumber extfld(l2item);
    CustomerNumber extfld(l2cust);
    end-ds;
    ...
    dcl-ds Records qualified; // #4
    L1Record likeds(L1Record_t) pos(1);
    L2Record likeds(L2Record_t) pos(1);
    ...
    end-ds;

    read myfile Records;
    if not %eof(myfile);
    if myfileInfds.format = 'L1RX';
    eval-corr myfileFields = Records.L1Recod;
    *in01 = *on;
    elseif myfileInfds.format = 'L2RX';
    eval-corr myfileFields = Records.L2Recod;
    *in02 = *on;
    ...
    endif;
    endif;
    if CustomerNumber > 1000; // now you can work with the fields

    For example
    dcl-ds

  • Guest
    Reply
    |
    Apr 18, 2019

    Regarding renaming fields, do you have alternate names for those fields in your actual file? If so, you could code the ALIAS keyword on your RPG file definition, and pick up the alternate names instead of the short names.

  • Guest
    Reply
    |
    Apr 18, 2019

    I appreciate the comments & totally agree with new development, other methods could & should be used.

    I'm just dealing with some old code that had some multi-member logic that utilized I-Specs from a software vendor & just thought if other people were dealing with the same situation, it wouldn't hurt to submit an RFE for consideration.

    "Going backwards" was not my intention & I did clarify the request to indicate that I'm not looking to ADD i-specs to modern RPG - just emulate some of its functionality with new keyword(s) within a DCL-DS or similar.

  • Guest
    Reply
    |
    Apr 18, 2019

    I agree with Jon's comments below. Let's not move backwards. Move forward and use more SQL in our RPG programs.

    Jason

  • Guest
    Reply
    |
    Apr 18, 2019

    There are other ways to handle such files without having to go back to I-specs surely? Using reading into a DS with multiple definitions springs to mind. Or having multiple pointer based DSs one for each record format. Either way I don't want to start moving backwards.