Tuesday, December 29, 2015

Instance Method vs Static Method



Instance method can access both – instance components as well as static components. Static method can only access static components. In the following example we have instance component v_var and static component cl_v_var. We have an instance method m_one and a static method cl_m_one. We can access both of those components from the instance method but when we want to access instance component from the static method then it will give a syntax error as follows.


REPORT  zsr_test NO STANDARD PAGE HEADING.

*----------------------------------------------------------------------*
*       CLASS cl_one DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_one DEFINITION.
  PUBLIC SECTION.
    DATA v_var TYPE char40 VALUE 'Instance Component'.
    CLASS-DATA cl_v_var TYPE char40 VALUE 'Static Component'.

    METHODS m_one.
    CLASS-METHODS cl_m_one.
ENDCLASS.                    "cl_one DEFINITION

*----------------------------------------------------------------------*
*       CLASS cl_one IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_one IMPLEMENTATION.
  METHOD m_one.
    WRITE: / v_var,
           / cl_v_var.
  ENDMETHOD.                    "m_one

  METHOD cl_m_one.
    WRITE: / cl_v_var.
  ENDMETHOD.                    "cl_m_one
ENDCLASS.                    "cl_one IMPLEMENTATION

START-OF-SELECTION.
  CALL METHOD cl_one=>cl_m_one.
  SKIP.

  DATA obj TYPE REF TO cl_one.
  CREATE OBJECT obj.
  CALL METHOD obj->m_one.

The program generates the following output.

20 comments:

Yaso Technosap said...

Nice news and thanks for sharing this here to let me know this updates,please know the recent updates by visiting this link also…because I had gain some info from here also:
SAP Training Tutorials | SAP Support Portal

Ramya k said...

Thanks for the great information in your blog SAP HR Training in Chennai

Dinesh Kumar said...

Thanks for sharing this Information, Got to learn new things from your Blog on Sap abap.
http://thecreatingexperts.com/sap-abap-training-in-chennai/

Divya Dheen said...

Thanks for sharing this Information, Got to learn new things from your Blog on sap abap training in chennai

simashree said...

Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about SAP ABAP.
http://thecreatingexperts.com/sap-abap-training-in-chennai/

sanayamohit said...

Thanks for a great information in your blog. I have read all the post of your blog. Great work on sap abap training in chennai

Rahul said...

It was very nice blog to learn about SAP HR.Thanks for sharing new things.SAP HR

Bhavya Kumar said...

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

sanayamohit said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

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

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

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

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!!!!!!

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...

Really i enjoyed very much. And this may helpful for lot of peoples. So you are provided such a nice and great article within this.

SAP HR Training in Chennai

SAP SD Training in Chennai

SAP Basis Training in Chennai

gilledashivani said...

Great information. the information provided is of great use as i got to learn new things. If you are looking for real time training in SAP ABAP, kindly contact sieve software
Sieve software offers real time training by industry experts with live projects and placement support.
SAP ABAP TRAINING IN HYDERABAD

leka said...

Nice blog, Given simple and useful instruction.SAP HR TRAINING in hyderabad



sieve software said...

Thank you for your information about sap training which is very informative. Those who are looking for sap mm training in Hyderabad; sieve software is the best institute for sap mm training providing the 100% hands-on practice in SAP Materials Management projects provided by MNC certified SAP MM Trainers.
SAP MM Training in Hyderabad at Sieve Software

sieve software said...

Thank you for your post which is very informative and very helpful, those who are looking for sap SD training Sieve software is the best Institute providing 100% hands-on practice in SD project provided by MNC real-time certified SAP SD Trainers. SAP SD Training in Hyderabad at Sieve Software

sieve software said...

thank you for your great post which is very helpful, and those who are looking for sap fico training in Hyderabad, sieve software is the best institute providing real time sap certified trainers with fico project. SAP Fico Training in Hyderabad at Sieve Software

sieve software said...

Thank you for your post which is very informative .those who want to get sap abap training in Hyderabad, sieve software is the best institute with Online and Class Room ABAP course with 100% hands-on practice in live project provided by MNC real-time certified SAP ABAP Trainers
SAP ABAP Training Institute in Hyderabad