03-06-2008 4:31 PM
hi friends,
can any one tell me wt is instance components an wt is static componets with sm gd examples.....
points will be regarded
regards
satish.
03-07-2008 5:04 AM
hi,
Instance attributes
One per instance
Statement: DATA
Static attributes
Only one per class
Statement: CLASS-DATA
Also known as class attributes
CLASS lcl_airplane DEFINITION.
PUBLIC SECTION.
PRIVATE SECTION.
DATA: weight TYPE saplane-weight,
name TYPE string.
CLASS-DATA: count TYPE I.
ENDCLASS.
There are two kinds of attributes
Static attributes
Instance attributes
Instance attributes are attributes that exist separately for each object.
Instance attributes are defined using the DATA keyword.
Static attributes exist once only for each class and are visible for all (runtime) instances in that class. Static
attributes usually contain information that is common to all instances, such as:
Data that is the same in all instances
Administrative information about the instances in that class (for example, counters and so on)
Static attributes are defined using the CLASS-DATA keyword.
Hope this helps, Do reward.
03-06-2008 4:39 PM
Hi,
Plz check the link u may get idea about them
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
Regards
03-06-2008 9:58 PM
hi satish..!
note : the main difference between instance & Static Components is
Instance components are Object Specific.
we can access them any no. of Objects of that class.
if we didnt create an Object of that class, then we cant access the instance components.
even we can access Static Components though object also.
for each object has its own copy memory.
Static cmponents are accessed driectly from Classes or even from object of that class..
these are Class Specific.
instance components are not accessed directly from the class.
Go through this Documentation and i also provided simple examples
to Understand Very Easily .
The Components of Class can be :
Attributes
Methods
Events
The declaration part can be divided into three sections namely
PUBLIC SECTION, PROTECTED SECTION and PRIVATE
SECTION
which controls the visibility.
Each component of class must be explicitly assigned to one of these three
visibility sections
PUBLIC SECTION : The components in this section are visible to everybody, i.e. users, its own methods and its subclasses.
Therefore, public components form the external interface between the class and its users.
PROTECTED SECTION : The components are visible to the methods of the class and its subclasses.
Therefore, it forms a special interface between the class and its subclasses.
PRIVATE SECTION : Here, components are only visible to its own method.
Instance Components :
Instance Dependent
Exist for each Object
Static Components :
Instance Independent
Exist only once for each class
They are retained for the entire Runtime
All objects of a class can access the static attributes of the class
When a static attribute is changed, this change is reflected in all other objects of the class
EXAMPLES
*1.1 *Accessibility of different sections of a class
Theme
From this program, one will learn:-
1. How to define, implement and instantiate a class.
2. What are the different sections of visibility in a class.
3. How to define instance attributes and get them accessed by external users.
The following program will also show that :-
Data declared in public section can be accessed by the class itself, by its subclasses as well as by other users outside the class.
Data declared in the protected section can be accessed by the class itself, and also by its subclasses but not by external users outside the class.
Data declared in the private section can be accessed by the class only, but not by its subclasses and by external users outside the class.
Brief Description
This program contains a class : parentclass with following attributes in different sections:-
Commondata in public section
Protectdata in private section
Privatedata in private section
The method showval in class : parentclass displays values of all the attributes.
This demonstrates that class can access all its attributes.
Class childclass is a subclass of class parentclass, which has a method : subval.
It displays the value for the data : commondata and protectdata .
Then, it changes the values for both and displays them again.
This demonstrates that subclass can access/change public/ protected attributes of superclass.
In the START-OF-SELECTION event, object : parent is instantiated from class : parentclass and object : child is instantiated from class : childclass.
Then , the method showval of parent(object of parentclass) and method subval of child(object of childclass) is called , which displays the values of different attributes.
Then, the public attribute of object parent is changed and the changed value is displayed.
This demonstrates that external users can change/display public attributes of a class.
Example
REPORT YSUBDEL LINE-SIZE 120.
CLASS parentclass DEFINITION .
PUBLIC SECTION.
DATA : commondata(30) type c value 'Accessible to all'.
METHODS : SHOWVAL.
PROTECTED SECTION.
DATA : protectdata(40) type c value 'Protected data'.
private section.
data : privatedata(30) type c value 'Private data'.
ENDCLASS.
CLASS parentclass IMPLEMENTATION.
METHOD : SHOWVAL.
write:/5 'All data from parentclass shown:-'.
write:/ sy-uline.
WRITE:/5 COMMONDATA,
/5 PROTECTDATA,
/5 PRIVATEDATA.
endmethod.
endclass.
CLASS childclass DEFINITION INHERITING FROM parentclass.
PUBLIC SECTION .
METHODS : subval.
ENDCLASS.
CLASS childclass IMPLEMENTATION.
method : subval.
skip 1.
write:/5 'Data of parent shown from child-'.
write:/5 sy-uline.
WRITE:/5 COMMONDATA,
/5 PROTECTDATA.
Commondata = 'Public data changed in subclass'.
Protectdata = 'Protected data changed in subclass'.
write:/5 sy-uline.
WRITE:/5 COMMONDATA,
/5 PROTECTDATA.
endmethod.
endclass.
START-OF-SELECTION.
DATA : parent type ref to parentclass ,
child type ref to childclass .
create object : parent ,
child .
call method : parent->showval ,
child->subval.
skip 2.
parent->commondata = User changing public data.
write:/5 parent->commondata.
output :-
All data from parentclass shown:-
Accessible to all
Protected data
Private data
Data of parent shown from child-
Accessible to all
Protected data
Public data changed in subclas
Protected data changed in subclass
User changing public data
1.2 Subclass cannot access the private component of superclass
Theme The program demonstrates that subclasses cannot access the private components of superclass.
Program description The program used here is similar to above with change in the method : subval of class : childclass . This method is now attempting to access the attribute : privatedata , which is a private attribute of its superclass : parentclass.
On compilation, the program will give a compilation error.
This demonstrates that private components of superclass cannot be accessed by subclasses.
Take the first program. Only change the method : subval of class : childclass as follows:-
method : subval.
skip 1.
write:/5 'All data from parent class shown by subclass'.
write:/5 sy-uline.
WRITE:/5 COMMONDATA,
/5 PROTECTDATA,
/5 privatedata.
endmethod.
Output The program will not compile. It will show an error message:-
The filed "PRIVATE DATA" is unknown, But there is afield with the simliar name " PROTECTED DATA'.
1.3 Use of Static Attributes
This program will demonstrate that : Static sttributes of a class are retained throughout the entire runtime. All the objects within a class can access its static attributes.
Program Description
The program contains a class C1 with static attribute : NUM . The method : M1 increments the static attribute by 1 and displays the value each time it is called.
In the main START-OF-SELECTION portion, two objects : OBJ1 and OBJ2 are created from class C1.
First, static attribute : NUM is changed and accessed outside the class using the class component selector , =>.
Then, both objects OBJ1 and OBJ2 are used to call method : M1 which shows the new value of static attribute : NUM .
That the value of the static attribute gets incremented each time when the method M1 of different objects is called shows that this variable is able to retain its value through the entire runtime.
CLASS c1 DEFINITION .
PUBLIC SECTION.
CLASS-DATA : NUM TYPE I .
METHODS : M1.
ENDCLASS.
CLASS c1 IMPLEMENTATION.
METHOD m1 .
num = num + 1.
write:/5 num .
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
c1=>num = 3.
write:/5 c1=>num .
DATA : OREF1 TYPE REF TO C1 ,
OREF2 TYPE REF TO C1 .
CREATE OBJECT : OREF1 ,
OREF2 .
CALL METHOD OREF1->M1 .
CALL METHOD OREF2->M1.
output : 3
4
5
If useful Reward...!
Cheers,
Rajsh.
03-07-2008 5:04 AM
hi,
Instance attributes
One per instance
Statement: DATA
Static attributes
Only one per class
Statement: CLASS-DATA
Also known as class attributes
CLASS lcl_airplane DEFINITION.
PUBLIC SECTION.
PRIVATE SECTION.
DATA: weight TYPE saplane-weight,
name TYPE string.
CLASS-DATA: count TYPE I.
ENDCLASS.
There are two kinds of attributes
Static attributes
Instance attributes
Instance attributes are attributes that exist separately for each object.
Instance attributes are defined using the DATA keyword.
Static attributes exist once only for each class and are visible for all (runtime) instances in that class. Static
attributes usually contain information that is common to all instances, such as:
Data that is the same in all instances
Administrative information about the instances in that class (for example, counters and so on)
Static attributes are defined using the CLASS-DATA keyword.
Hope this helps, Do reward.
03-07-2008 5:23 AM
http://help.sap.com/saphelp_nw70/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
Instance Attributes
The contents of instance attributes define the instance-specific state of an object. You declare them using the DATAstatement.
Static Attributes
The contents of static attributes define the state of the class that is valid for all instances of the class. Static attributes exist once for each class. You declare them using the CLASS-DATA statement. They are accessible for the entire runtime of the class.
All of the objects in a class can access its static attributes. If you change a static attribute in an object, the change is visible in all other objects in the class.
The technical properties of instance attributes belong to the static properties of a class. It is therefore possible to refer in a LIKE addition to the visible attributes of a class through the class component selector or through reference variables, without prior creation of an object.
03-07-2008 5:32 AM
Hi,
General Tutorial for OOPS
check all the below links
http://www.sapgenie.com/abap/OO/index.htm
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.brabandt.de/html/abap_oo.html
Check this cool weblog:
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
these links
http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
For funtion module to class
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
for classes
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
for methods
http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
for inheritance
http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
for interfaces
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
Check these links.
http://www.henrikfrank.dk/abapuk.html
Go through the below links,
For Materials:
1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
😎 http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
OO ABAP links:
1) http://www.erpgenie.com/sap/abap/OO/index.htm
2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
go through these links
http://www.erpgenie.com/abap/index.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
ABAP_OBJECTS_ENJOY_0 Template for Solutions of ABAP Object Enjoy Course
ABAP_OBJECTS_ENJOY_1 Model Solution 1: ABAP Objects Enjoy Course
ABAP_OBJECTS_ENJOY_2 Model Solution 2: ABAP Objects Enjoy Course
ABAP_OBJECTS_ENJOY_3 Model Solution 3: ABAP Objects Enjoy Course
ABAP_OBJECTS_ENJOY_4 Model Solution 4: ABAP Objects Enjoy Course
ABAP_OBJECTS_ENJOY_5 Model Solution 5: ABAP Objects Enjoy Course
DEMO_ABAP_OBJECTS Complete Demonstration for ABAP Objects
DEMO_ABAP_OBJECTS_CONTROLS GUI Controls on Screen
DEMO_ABAP_OBJECTS_EVENTS Demonstration of Events in ABAP Objects
DEMO_ABAP_OBJECTS_GENERAL ABAP Objects Demonstration
DEMO_ABAP_OBJECTS_INTERFACES Demonstration of Interfaces in ABAP Objects
DEMO_ABAP_OBJECTS_METHODS Demonstration of Methods in ABAP Objects
DEMO_ABAP_OBJECTS_SPLIT_SCREEN Splitter Control on Screen
check these also
check the below links lot of info and examples r there
http://www.sapgenie.com/abap/OO/index.htm
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.brabandt.de/html/abap_oo.html
Check this cool weblog:
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
these links
http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
For funtion module to class
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
for classes
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
for methods
http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
for inheritance
http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
for interfaces
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
For Materials:
1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
😎 http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
1) http://www.erpgenie.com/sap/abap/OO/index.htm
2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
Regards
Eshwar