2013 Feb 17 3:12 PM
Hi everyone,
I have very simple abap programming question.
Can sombody tell me why do we use prefixes ls, lo, lr ,lt when defining local variables inside abap.
Example:
DATA: lo_dim TYPE REF TO cl_uja_dim,
lr_dim_data TYPE REF TO if_uja_dim_data,
lt_attr_name TYPE uja_t_attr_name,
lt_sel TYPE uj0_t_sel,
ls_sel TYPE uj0_s_sel.
What is the meaning of programming this way. Why cant people in abap use simple variable names the way we do it java.
Also whats the different between all these.
So far I found out that cl is used to denote classes and if denotes interfaces.
but these lo, lr, lt, ls, lv have been confusing for me to understand. I tried to look all over the place and couldn't find meaning for it.
Helpful answers would be rewarded points.
Much Thanks.
Ibrahim
2013 Feb 17 3:24 PM
lo - local object
lr - local range (not sure about this)
lt - local table
ls - local structure
lv - local variable
These kinds of declarations may be project specific as specified by the client or used in one project in order to have uniformity in coding practices within the team.
2013 Feb 17 3:51 PM
Hi Ibrahim,
To your question, why can't you use simple variable names like in other programming languages, the answer is you can. You can very well go ahead and name your ABAP variables without the prefixes you mentioned. However, these prefixes have the advantage that just looking at the name you know the scope ('l' standing for local and 'g' standing for global) as well as the type (variable, structure, internal table etc.) of the variable.