Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Efficient or Better Ways for Data Declaration

Former Member
0 Likes
645

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

4 REPLIES 4
Read only

Former Member
0 Likes
622

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

Read only

ThomasZloch
Active Contributor
0 Likes
622

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

Read only

0 Likes
622

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

Read only

0 Likes
622

> 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