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

On Hardcoding

Former Member
0 Likes
452

Hi ABAPers and developers alike,

Just for discussion pusposes, I would like your feedback on the following:

1) What is hardcoding in ABAP programming?

2) Why do you hardcode?

3) What are the disadvantages of hardcoding in ABAP?

4) Would elimination of hardcoding make the program run faster (see sample code below)


* which would have faster runtime between the code variations?

* code 1:
if V_1 = 'A'.
  ...
elseif V_1 = 'B'.
  ...
endif.

* code 2:
constants:
  c_a type c value 'A',
  c_b type c value 'B'.

if V_1 = c_a.
  ...
elseif V_1 = c_b
  ...
endif.

5) Why NOT to hardcode?

I appreciate your inputs regarding this. Thanks.

~ Eric

2 REPLIES 2
Read only

Former Member
420

first code is faster. in second code retrieving the values of c_a and c_b takes some time .

Generally Hardcode means...assigning CONSTANT VALUES..

Like...

SELECT * from MARA where MATNR EQ '00000000456'.

Read only

Former Member
420

Hi hard coding is nothing but....passing the value directly to the parameters of the statemtn.

instead of passing value directly...we can first initialize the value with the variable...then that variable will assign to the parameter of the statement..

suppose we need to passed the value more than 2 or 3 times in the program...

in future if we want to change the value...we need to do changes explicitly in the program where exactly we passed that value...that is some what hectic..

so if we pass the variable...simply we can change one time at the variable value...automatically where ever this variable is using there all the places will be effected..

regards,

venkat n