Assume there are 2 variables with the same name (Example: var) – One is a class variable, and another is a local variable declared inside a method.

Now if we want to display the class variable’s value from a method where the local variable with the same name is declared – we need to use ME keyword.

Below is the code snippet.

Line 8: Class definition.

Line 16: Class implementation.

Line 11: Class variable ‘var’ is declared. Value is 30.

Line 19: Local variable is ‘var’ declared within the method Display. Value is 60.

Line 30: Object created of type class LCL_ME.

Line 31: Calling the method Display to display both the class and local variable.

Line 20: Here the value of the class variable is displayed using ME keyword.

Line 21: Here the value of the local variable ‘var’ is displayed directly referring to the variable name.

Below is the sample output:

Categories: Abapooabap

1 Comment

Mark · September 12, 2022 at 4:23 am

Thanks for your blog, nice to read. Do not stop.

Comments are closed.