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).
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:
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 an idea.
Get feedback from the IBM team and other customers to refine your idea.
Follow the idea through the IBM Ideas process.
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.
See this idea on ideas.ibm.com
It often happens that I have a field from a database og a screen that is fixed length and have to create a field that is varying length but having the same size as the fixed length.
unfortunately it is not possible to do this:
dcl-s fixedField char(40); // this field will normally come from a database or a screen
dcl-s varField varchar( %size(fixedField) );
or this
dcl-c fixedFieldSize %size(fixedField);
dcl-s varField varchar( fixedFieldSize );
So I have to hardcode it:
dcl-s fixedField char(40);
dcl-s varField varchar(40);
But it would be nice if it could be done so we don't have to hardcode it
Idea priority | Medium |
By clicking the "Post Comment" or "Submit Idea" button, you are agreeing to the IBM Ideas Portal Terms of Use.
Do not place IBM confidential, company confidential, or personal information into any field.
The CAAC has reviewed this IBM Idea and recommends that IBM not implement this request.
There is a variety of programing solutions such as defining a constant value.
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 IBM Ideas on the broader IBM i community and has therefore reviewed your Idea.
For more information about CAAC, see www.common.org/caac
Carmelita Ruvalcaba - CAAC Program Manager
Another way of doing it could be that it is possible to override the format like this
If this Idea is implemented, it would most likely involve new syntax for the LIKE keyword.
- IBM Power Systems Development
That works for me, but FixedField must be defined in the same procedure, and it must be defined before the dcl-pi.
ctl-opt nomain;
dcl-proc p;
dcl-s fixedfield char(10);
dcl-pi *n varchar(%len(fixedfield));
end-pi;
return 'x';
end-proc;
If Fixedfield is a global field, you could define a named constant with the length, and use that named constant in the procedure.
ctl-opt nomain;
dcl-s FixedField char(10);
dcl-c FixedFieldLen %LEN(FixedField);
dcl-proc p;
dcl-pi *n varchar(FixedFieldLen);
end-pi;
return 'x';
end-proc;
- Barbara Morris
But it's not working on parm definition:
Dcl-pi *n varchar(%len(FixedField));
Thank you very much for the tip how to do it.
I will suggest that it is included in the RPG manuals.
You can use %LEN to get the length of the fixed-length field.
dcl-s fixedField char(40);
dcl-s varField varchar(%len(fixedField));
If you want the defined length of a varying field, you have to use %LEN(*MAX).
dcl-s varField2 varchar(40);
dcl-s fixedField2 char(%len(varField2 : *max));
However ... To use %LEN like this in a definition, the field specified in the %LEN keyword has to already be defined. So if the %LEN field is coming from an externally-described file, you'd have to define a externally-described data structure and use the subfields for %LEN.
dcl-f myDbFile;
dcl-f myScreens workstn;
dcl-ds myFileDefs extname('MYDBFILE') qualified template;
end-ds;
// might have to define several data structures for screen fields, one for each format
dcl-ds screen1Defs extname('MYSCREENS' : 'SCREEN1' : *all) qualified template;
end-ds;
dcl-s varField varchar(%len(myFileDefs.someField));
dcl-s varField2 varchar(%len(screen1Defs.someOtherField));
- Barbara Morris