Application Development 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: 

CONSTANTS defined with initial database read possible?

Former Member
0 Kudos

Hi

Is it possible to do dynamic CONSTANTS assignment up front in INITIALIZATION or does ABAP limit you to define CONSTANTS only as data declaration with literal assignment?

Thanks, Adrian

5 REPLIES 5

former_member186052
Active Participant
0 Kudos

Hi Adrian,

Constants are objects that are created "statically" in a declaration statement.

The value of a constant must be defined when you declare it. It cannot be changed subsequently.

Also, the value of a constant cannot be changed during the execution of the program.

If you do so, a syntax error or runtime error occurs.

Regards,

-Sandeep

0 Kudos

Thanks Sandeep. As mentioned, I understand the usage of a CONSTANT, but would like to know if it can be set once without the use of the literal. It's rather limiting don't you think? There is a workaround though, you can define it with a dynamic data declaration, but still that's a lot of effort for something that should be simplistic.

0 Kudos

Hi Adrian,

I'm sorry, " There is a workaround though, you can define it with a dynamic data declaration, but still that's a lot of effort for something that should be simplistic ", I still can not get the idea since you knew could workaround then what is the different? Would you share your point?

Regards,

Dondi.

0 Kudos

Is it hard to understand?

a. I'm trying to find out if the CONSTANTS statement can be defined by using a SELECT statement instead of a literal e.g '3.14'. After some answers It seems NOT to be possible. So that's OK then. Moving on.

b. I don't want to revert to workarounds. In other languages this is a very simplistic data declaration that covers my requirement.

0 Kudos

It is not possible to declare a constant at runtime, yes the only way is using the literal CONSTANT and assign a value to it. I look for a way to create it using RTTS but it's not possible.

For reference http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3041358411d1829f0000e829fbfe/content.htm

Regards,

Felipe