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

declaring constants

Former Member
0 Likes
2,475

hiii

i was wondering is it make sense to declare local constants in a report program

i mean constants is created so that it can be access globally then what's the use of declaring it in a perform like below



perform f_processdata

constants:
 lc_test type c value 'X'

endform

i always declare my constant in my top include. i just wanted to know the difference

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,368

the difference is only in scope.....if you declare it in an include then it is available globally wherever the include is used....a local constant has only a local scope...

7 REPLIES 7
Read only

Former Member
0 Likes
1,369

the difference is only in scope.....if you declare it in an include then it is available globally wherever the include is used....a local constant has only a local scope...

Read only

Former Member
0 Likes
1,368

Hi,

The only difference comes for there scope.

If we declare the constants in INCLUDE then it has a global scope i.e. we can use this constants in number of programs.

And if we declare in any program its scope is local i.e we can use that in program only.

thanx.

Read only

Former Member
0 Likes
1,368

There is no difference except for the availability of the constant. It will be locally available in this case and cant be accessed from other subroutines.

Read only

Former Member
Read only

Former Member
0 Likes
1,368

Hi Friend,

Declaring constants within a perform has the scope within that subroutine only. It cannot be accessed out of that subroutoine.

Declaring globally, it can be accessed throught the program.

You can check this in debugging.

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
1,368

hiii

yes, if you declare constant globally then anywhere you can use it.and if you declare it in any subroutine then whenever you call that subroutine you can have that constant value.if some variables are really used for so many programs then it is better to declare it as global but constant value will not be used that much time so it is better to declare it as local and call that subroutine whenever you need it.

regards

twinkal

Read only

Former Member
0 Likes
1,368

Hi,

perform f_processdata
 
constants:
 lc_test type c value 'X'
 
endform

If you declare inside a form routine then that is accessible with in that form routine itself.

we cant use them outside the form routine.

If this constant is used only in a particular form routine then it better to declare locally then globally.

If the constant or variable is used in many instances then we declare it globally.

Best regards,

raam