| Home • Tips • Tutorials • Forums • Certification Q's • Interview Q's • Jobs • Testimonials • Contact Us | ||
Tips Categories:
Contribute?What's New?
What's Hot? |
Difference between static and instance variablesby Vikram Chellappa Static
attributes:
Instance
attributes:
Go to SE38 and
create the following program. *&---------------------------------------------------------------------* *& Report ZLOCALCLASS_VARIABLES * *& * *&---------------------------------------------------------------------* *& By * *& Vikram.C for SAPTechnical.COM * *&---------------------------------------------------------------------* REPORT ZLOCALCLASS_VARIABLES.
*General local class by using static and instance.
*Define the class
CLASS CL_LC DEFINITION.
PUBLIC SECTION.
DATA: A TYPE I VALUE 10.
CLASS-DATA: B TYPE I VALUE 20.
METHODS DISPLAY.
CLASS-METHODS DISP.
ENDCLASS.
*Implement the class
CLASS CL_LC IMPLEMENTATION.
METHOD DISPLAY.
WRITE:/ 'IT IS INSTANCE METHOD',
/ 'INSTANCE VARIABLE = ', A.
ENDMETHOD.
METHOD DISP.
WRITE:/ 'IT IS STATIC METHOD' COLOR 2,
/ 'STATIC VARIABLE = ', B COLOR 2.
ENDMETHOD.
ENDCLASS.
*Create the object
DATA OBJ TYPE REF TO CL_LC.
START-OF-SELECTION.
CREATE OBJECT OBJ.
*Call the instance method
CALL METHOD OBJ->DISPLAY.
*Call the static method.
CALL METHOD CL_LC=>DISP.
Save it, check it,
activate it after that execute it. Then the output is
like this.
|
|
|
Please send us your feedback/suggestions at webmaster@SAPTechnical.COM Home • Contribute • About Us • Privacy • Terms Of Use • Disclaimer • Safe • Companies: Advertise on SAPTechnical.COM | Post Job • Contact Us ©2006-2007 SAPTechnical.COM. All rights reserved. All
product names are trademarks of their respective companies. SAPTechnical.COM
is in no way affiliated with SAP AG. Graphic Design by Round the Bend Wizards |
||