Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Atrributes Issue

Former Member
0 Likes
756

Hi,

i learn now Abap OO and i little confused (i search in the forum),

what i use in attributes .

Maybe someone can give me Example from the FM world.

in fm i declare import Export Tables ...Data Types ....

What is analogous to Attributes ?

Reagrds

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
717

Hi,

If you read the OOABAP documentation it is mentioned that the OOABAP is introduced to work with data objects(Data types ) and functions ( Methods) together

If you wanna compare classes with FM the function group can be considered as Class and the Function modules as Methods in the class and the parameters like Importing Exporting, Tables Ect are Known as attributes. These attributes again classified into Importing Exporting Returning( Public, Private, Protected )

Hope its clear

Regards

Pavan

6 REPLIES 6
Read only

naimesh_patel
Active Contributor
0 Likes
717

It is not good idea to analog the Attribute to FM's parameters.

But you can think like:

Class could have multiple Methods with Import / Export parameter and with some Attributes.

Function Group could have mutliple Function Modules with parameters and with some Global data declaration. Now, if you want to access this global data from outside the FG, than you need to wrap it up in another FM and pass it to calling application.

In class, you can set the attribute and access them from your application, provided it has Public Visibility.

Now, assume that you have a class ZCL_ORDER. This has the method GET_ORDER which can accept the Sales Order and give back the Item data (VBAP). It has one attribute for VBAK to save the header data. This attribute is being set in the same method GET_ORDER.

From your application, you have created an instance of the object. After calling the GET_ORDER method, later in the application you need to know the Header data of the same Order. Here you can just acess the VBAK attribute of the class.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
717

Hi,

Attributes describe the data that can be stored in the objects of a class. They also determine the status of an object.

Regards

Abhijeet

Read only

Former Member
0 Likes
717

Hi Cosmo,

Check this one.

[Attributes|]

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
718

Hi,

If you read the OOABAP documentation it is mentioned that the OOABAP is introduced to work with data objects(Data types ) and functions ( Methods) together

If you wanna compare classes with FM the function group can be considered as Class and the Function modules as Methods in the class and the parameters like Importing Exporting, Tables Ect are Known as attributes. These attributes again classified into Importing Exporting Returning( Public, Private, Protected )

Hope its clear

Regards

Pavan

Read only

0 Likes
717

Thanks pavan kanike,

u write:

Tables Ect are Known as attributes

Are u sure? u can give e.g. .

Regards

Read only

0 Likes
717

Hi Kosmo Cramer,

Please check this regarding Attributes in OOABAP.


Attributesu2026 
...store the internal state of an object (data) 
...can be references to other objects 
u2026can be: read-only, virtual, class attributes 
u2026can be constants 
Virtual attributes: u2018Attributeu2019 from the outside, inside the object Set- and Get-methods. 
Dynamic control of Set-/Get-methods. 
 
{DATA|CLASS-DATA} attr TYPE type 
  [ VALUE val ] 
  [ READ-ONLY ]
  [ VIRTUAL [ SET-METHOD set-method] [GET-METHOD get-method] ].
 
CONSTANTS const TYPE type VALUE val.
Component  Definitions 
Methodsu2026 
u2026are operations on objects (the u2018functionalityu2019) 
u2026are the only way to change the state of an object  
    (other than public attributes) 
...have parameters and can raise exceptions 
   (similar to function modules) 
...can pass back a return value 
No method-name overloading! 
 
{METHODS|CLASS-METHODS} method
  [ IMPORTING    ...<list of import parameters> ]
  [ EXPORTING    ...<list of export parameters> ]
  [ CHANGING     ...<list of import/export parameters> ]
  [ EXCEPTIONS   ...<list of exceptions> ]
  [ RETURNING result TYPE t ].
 
 
 
Using Attributes and Methods 
CLASS c1 DEFINITION.
  PUBLIC SECTION.
    DATA: v1 TYPE I,
          o1 TYPE REF TO c1.
    METHODS: m1 IMPORTING a1 TYPE REF TO c1,
             m2 IMPORTING a1 TYPE REF TO c1
                RETURNING result TYPE I.
  PRIVATE SECTION.
    DATA: v2 TYPE I.
ENDCLASS. 
PROGRAM xy.
  DATA o1 TYPE REF TO c1.
  u2026 
  u201C--- attribute can occur anywhere a u2018normal variableu2019 can occur
  CREATE OBJECT o1.
  x = o1->v1 + sin( o1-> v1 ).
  CALL FUNCTION 'abc' EXPORTING p1 = o1->v1 u2026 . 
  u201C--- some method calls u2026  
  CALL METHOD o1->m1 EXPORTING a1 = o1.
  CALL METHOD o1->m1( o1 ).   u201C-- short form for 1 exporting arg
  u2026 
  y = obj1->m2( x ). u201C-- result can be used in expressions

Like Importing , Exporting and so on... TABLES are not attributes related to OOABAP..

They are related to Function modules only..

Please go through this link which would give you an overview about OOABAP parameters..

http://beingkedar.googlepages.com/ooabapo

( Please close your other threads if they are solved...)

Hope this would help you.

Good luck

Narin