‎2006 Oct 31 9:24 PM
Hi all
Can anybody please explain me instance and static attributes with examples...please
Thanks n Regards
vijaya
‎2006 Nov 29 6:18 AM
Hi Vijaya,
Instance attributes
There exist one instance attribute for each instance of the class, thus they exist seperately for each object. Instance attributes are declared with the DATA keyword.
Static attributes
Static attributes exist only once for each class. The data are the same for all instances of the class, and can be used e.g. for instance counters. Static attributes are defined with the keyword CLASS-DATA.
PRIVATE SECTION.
CLASS-DATA: counter type i,
hope this helps.
Regards,
Kinshuk
‎2006 Oct 31 9:35 PM
Hi Vijaya,
For Instance attributes, we need to create an object before working with them.ie Suppose there are 5 instance attributes, we need to create objects for all these 5 attributes.
While for static attributes, one object is enough for all of them.
Foe eg: Suppose that you have 5 instance attributes, if we want to assign values to them, you have to create 5 objects and then assign value to them.
On the other hand, if you have 5 static attributes, you need to have just one object . Assigning value to attribute of that object once is enough to assign values to all the 5 of them.
This may sound similar to static variables in other languages like C,C++ etc.
<b>Award points if found useful.</b>
Regards,
SP.
‎2006 Oct 31 9:39 PM
Hi sylendar
Can u please give me some example.iam very much confused with this oops concept.also can u suggest me which is the best place to find out some info abt abap objects.
Thanks and regards
vijaya
‎2006 Oct 31 9:44 PM
Hi Vijaya,
You can go through this link which contains OOP documents I have uploaded...
You can also go to transaction code ABAPDOCU and go to <b>ABAP Objects</b> section.
You can also get nice programs in this site.
http://www.erpgenie.com/sap/abap/OO/index.htm
<b>Award points if found useful.</b>
Regards,
SP.
‎2006 Nov 22 6:51 AM
A SIMPLE EXPLANATION TO UR QUESTION WOULD BE
STATIC ATTRIBUTES BELONG TO THE CLASS ITSELF .
WHILE INSTANCE ATTRIBUTES BELONG TO THE INSTANCE OF DAT CLASS i.e. OBJECTS OF THAT CLASS .
STATIC ATTRIBUTES CAN BE ACCESSED EVEN WITHOUT CREATING OBJECT OF DAT CLASS COZ THEY BELONG TO THE CLASS .
WHILE TO ACCESS INSTANCE ATTRIBUTES U NEED TO CREATE OBJECT OF DAT CLASS .
‎2006 Nov 28 10:43 PM
Hi,
Instance attributes are confined to each instance of the class.
Static attributes remain the same for the whole class irrespective of any number of instances.
For example....
Consider there is a scenario where one user is creating 100 sales orders of type 'OR' (Standard Order). The Order type and the user remain the same. Whereas the details for the sales order like Sold to party, Items specific to each sales order.
So, in the above case Order type and User Id are Static variables, they remain the same across all the instances.
Instance attributes are for example the items of the sales order, Sales order number.
Hope I have answered your question.
Regards,
Vara
‎2006 Nov 29 6:18 AM
Hi Vijaya,
Instance attributes
There exist one instance attribute for each instance of the class, thus they exist seperately for each object. Instance attributes are declared with the DATA keyword.
Static attributes
Static attributes exist only once for each class. The data are the same for all instances of the class, and can be used e.g. for instance counters. Static attributes are defined with the keyword CLASS-DATA.
PRIVATE SECTION.
CLASS-DATA: counter type i,
hope this helps.
Regards,
Kinshuk