‎2008 Nov 26 9:00 AM
Hi Guys,
Basically I've always programmed much the same way for a pretty long time now. Lately I've been asking myself the question - "how can i start improving on my tried and trusted ways".(oftern a linear programming approach). As part of this I'm examining ways to declare data better within in programs and to adopt a neat way to do so.
This may seem pretty trivial but the first question I want to ask is how to declare data better
e.g. I need to declare constants - each constant corresponds to a rule number; 1, 2,3,4,5,6 - 23 etc.
Instead of declaring the following line 23 times - is there a better way to declare in such a way.
Constants: c_rule_1 type c value '1' ,
c_rule_2 type c value '2',
etc etc etc
Your thoughts are greatly appreciated.
Thanks.
DK
Edited by: Damien Kesle on Nov 26, 2008 10:00 AM
‎2008 Nov 26 10:01 AM
Hi,
With my knowledge, data declarations for all constants with DATA comamnd itself is good practise in point of performance. Alternative is dynamic creation of variables. But it consumes more time and is not good to practise. Instead of crating individual parameters for each constant, you could create a structure and add all constants as fields as follows:
constants: begin of con,
1 type c value '1',
2 type c value '2',
-
end of con.
Regards,
Prasanth
‎2008 Nov 26 10:28 AM
Well, if you require 23 constants you should declare 23 constants. I don't see anything wrong with that. Getting funny with data declarations in macros or generated includes or similar will just reduce readability and maintainability of your code, imho.
Thomas
‎2008 Nov 26 1:52 PM
Hi Guys
Thanks for the replies. It's good to get a wider perspective on things -even simple things like this. I guess I'm just reviewing all aspects of things I do and looking for improvements.
Thanks alot
DK
‎2008 Nov 26 2:02 PM
> I guess I'm just reviewing all aspects of things I do and looking for improvements.
Very good practice, I'm trying to do the same (if time allows). Performance improvements especially are very actively debated in this forum
Thomas