Wednesday, March 20, 2013

ME in Method


When we declare a variable of any type in public section of a class then we can use it in the implementation. Let us suppose we declare a variable of any type with an initial value in public section. Then we declare the variable again inside a method initiating with a different value. Now if we write the variable inside the method, the system will print the changed value not the previous one. To reflect the previous value of the variable we have to use ME operator.

In the following example we have declared a public variable v_txt and initiate with a value. Then we have declared the same variable again inside the method but instantiated with different value. Inside the method we are writing that variable with ME operator and get the previously initiated value. By declaring directly we are getting the changed value.

REPORT  zsr_test NO STANDARD PAGE HEADING.

*----------------------------------------------------------------------*
*       CLASS cl_me DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_me DEFINITION.
  PUBLIC SECTION.
    DATA v_txt TYPE char40 VALUE 'Class Attribute'.
    METHODS m_me.
ENDCLASS.                    "cl_me DEFINITION

*----------------------------------------------------------------------*
*       CLASS cl_me IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_me IMPLEMENTATION.
  METHOD m_me.
    DATA v_txt TYPE char40 VALUE 'Method Attribute'.

    WRITE: / me->v_txt,
           / v_txt.
  ENDMETHOD.                    "m_me
ENDCLASS.                    "cl_me IMPLEMENTATION

START-OF-SELECTION.
  DATA obj TYPE REF TO cl_me.
  CREATE OBJECT obj.
  CALL METHOD obj->m_me.

The program generates the following output.

16 comments:

Vemula Ajiteshwar said...

I got the exact answers for what I was searching , Thank You.....!!

Vemula Ajiteshwar said...
This comment has been removed by the author.
Ashwani Sharma said...

please send me any alv oop single screen with multiple table use and single container use.

Emailid-ashwanishrm744@gmail.com
Ashwani

Anonymous said...

Thanks, Nice code demo.

I have a question and trying to find best practise answer for it.

Class_Parent abstract.

Public.
Method1.
Method2.
endlcass.

Class_Child.

redefine method1.

redefine method2.

endclass.

Class_child implementation.

Method 1.

method2().->> Which one is correct and best practise over other

me->method2( ). ->> Which one is correct and best practise over other

endmethod.

method2.
endmethod.

endclass.

Higlighted are my confusion area which one is good practise,because I redine locally.

simashree said...

Thank you for such guidance about astrology,Best Blog on
vasiyam in chennai

Bhavya Kumar said...

Best blog.Got to learn new things.Thanks for this Blog SAP Success Factors Training in Chennai

Shruti Ramalingam said...

From My search…Creating Experts provides Best SAP Training with real time projects assistance.

Most of the modules are equipped with advance level topics which the student can learn from the basics to the advance level stage.

They also provide placement assistance in leading MNC companies across the globe according to the current requirements.

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

And these are the Best SAP training institute which provides Real Time Hands on Training…

codedion Technologies-9003085882

creating Experts-8122241286

http://thecreatingexperts.com/sap-mm-training-in-chennai/

Unknown said...



Best SAP Success Factors Training Institute in Chennai
http://thecreatingexperts.com/sap-successfactors-training-in-chennai/
Best SAP MM Training in Chennai
http://thecreatingexperts.com/sap-mm-training-in-chennai/
Best SAP SD Training in Chennai
http://thecreatingexperts.com/sap-sd-training-in-chennai/
http://thecreatingexperts.com/sap-hr-training-in-chennai/
Best SAP FICO Training in Chennai
http://thecreatingexperts.com/sap-fico-training-in-chennai/
Best SAP ABAP Training in Chennai
http://thecreatingexperts.com/sap-abap-training-in-chennai/
Best SAP BASIS Training in Chennai
http://thecreatingexperts.com/sap-basis-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Keerthi Suresh said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Camelliacanan said...

Thanks for sharing the valuable information here. So i think i got some useful information with this content. Thank you and please keep update like this informative details.

SAP HR Training in Chennai

SAP SD Training in Chennai

SAP Basis Training in Chennai

Arindam ghosh said...

Hi,
i want to get the 'ME' instance name in debugger mode. Is it possible?

gilledashivani said...

Thank you for sharing the great blog. BEST SAP ABAP TRAINING IN HYDERABAD

lakshmi said...

Thanks for sharing the valuable information here. sap training institutes in hyderabad in information with this content. Thank you and please keep update like this informative details.
http://www.sapschool.in/

akhila priya said...

The information which you have provided is very good. It is very useful who is looking for Java online course

calfre services said...

This post is really nice and informative. The explanation given is really comprehensive and informative..sap hr training

Unknown said...

Good demo!