About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
7.4:
ILE RPG compiler: 5770WDS SI84886
7.5:
ILE RPG compiler: 5770WDS SI85009
ILE RPG compiler, TGTRLS(V7R4M0): 5770WDS SI85043
An enumeration can be qualified:
DCL-ENUM sizes QUALIFIED;
small 1;
medium 2;
large 3;
END-ENUM;
DCL-S size INT(10);
size = sizes.medium; // Use the qualified enum item
An enumeration can be unqualified:
DCL-ENUM truefalse;
true '1';
false '0';
END-ENUM;
DCL-S isValid ind;
isValid = true; // Use the unqualified enum item
You can also use enumerations as arrays. For more information, see https://www.ibm.com/support/pages/node/7047175.
- IBM Power Systems Development
Please combine that with the ability to use those enums as conditions in COBOL Level 88 manner!
The CAAC has reviewed this requirement and recommends that IBM view this as a medium priority requirement that should be addressed. This would help RPG become more "normal" -- this is a useful extension to RPG that is found in other languages.
Background: The COMMON Americas Advisory Council (CAAC) members have a broad range of experience in working with small and medium-sized IBM i customers. CAAC has a key role in working with IBM i development to help assess the value and impact of individual RFEs on the broader IBM i community, and has therefore reviewed your RFE.
For more information about CAAC, see www.common.org/caac
Nancy Uthke-Schmucki - CAAC Program Manager
IBM has modified some of the information in this request. Please contact us if you have any questions.
Specifically, the headline has been updated, per earlier Comments in this RFE.
Previous Headline: Allow CONST keyword for data structures
New Headline: Add an enumeration type to RPG so that named constants can be qualified
Hello Stuart. I believe this RFE would attract more votes if the title was about "enum" rather than about a CONST keyword for data structures.
Do we have your permission to change the title to the following:
"Add an enumeration type to RPG so that named constants can be qualified"
Or, feel free to suggest a different new title in your response :-)
- Barbara Morris
IBM will use this request as input to planning but no commitment is made or implied. This request 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 request.
If this request is implemented, it would be in the form of an "enumeration" definition, as indicated in the comments for this RFE.
Jon, it is already possible to use LIKE with a template data structure subfield.
dcl-ds ds_t template qualified;
subf char(10);
end-ds;
dcl-s x like(ds_t.subf);
Yes, a genuine enum would be even better. Maybe I should have been greedier in the first place :)
Would a real enumeration type fulfill this requirement in a more direct way? If not, please give an example of how you would use LIKEDS with a CONST data structure.
Here is a suggestion for what an "enum" might look like for RPG.
// An enum that is really just a list of named constants
dcl-enum *n;
blue 'BLUE';
red 'RED';
yellow 'YELLOW';
end-enum;
paint = red;
// An enum that is basically a qualified named constant
dcl-enum categories qualified;
open 'OPEN';
closed 'CLOSED';
end-enum;
category = categories.open;
// A typed enum that can be used with LIKE
dcl-enum customer_type int(10);
ordinary 1;
special 2;
inactive 3 dft; // this is the default
end-enum;
dcl-s custType like(customerType); // initialized with 3 (the default)
// A qualified typed enum that can be used with LIKE
dcl-enum order_type char(10) qualified;
standard 'Std' dft; // this is the default
discount 'Discount';
end-enum;
dcl-s orderType like(orderType); // initialized with 'Std' (the default)
I think you could probably get most of what you want if IBM relaxed the rules such that a Template DS subfield could be used in a Like definition.
What features do you need that this would not fulfill?
That might be an interesting RFE. May you please share a coding example to give us better insight of it?