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

ABAP Objects

Former Member
0 Likes
577

Can anybody send me a detailed document for creation of methods and classes.

4 REPLIES 4
Read only

Former Member
0 Likes
528

Hi,

<b>Please checkout...

http://aspalliance.com/1144_Understanding_ABAP_Object#Page6</b>;

http://www.sapbrainsonline.com/PROJECTS/TECHNICAL/SAP_projects_OBJECTS_Create_employee_class.html

http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5354f411d194a60000e8353423/frameset.htm

This Program is a good example

SAPSIMPLE_TREE_CONTROL_DEMO

++++++

<b>Try out Transaction

ABAPDOCU

Or better in SE38

DEMO* and press F4</b>

======================

DEMO_ABAP_OBJECTS Complete Demonstration for ABAP Objects

DEMO_ABAP_OBJECTS_CONTROLS GUI Controls on Screen

DEMO_ABAP_OBJECTS_DIALOG_BOX Splitter Control for Screen with Dialog Box

DEMO_ABAP_OBJECTS_EVENTS Demonstration of Events in ABAP Objects

DEMO_ABAP_OBJECTS_GENERAL ABAP Objects Demonstration

DEMO_ABAP_OBJECTS_METHODS Demonstration of Methods in ABAP Objects

DEMO_ABAP_OBJECTS_SPLIT_SCREEN Splitter Control on Screen

DEMO_ELEMENTARY_DATA_OBJECTS Demonstration of Elementary Data Objects

DEMO_OBJECTS_REFERENCES Objects and Object References

Regards, ABY

Read only

0 Likes
528

Methods are internal procedures in classes that determine the behavior of an object. They can access

all attributes in their class and can therefore change the state of an object.

Methods have a parameter interface that enables them to receive values when they are called and

pass values back to the calling program.

Methods: Syntax

CLASS <classname> IMPLEMENTATION.

METHOD <method_name>.

...

ENDMETHOD.

ENDCLASS.

CLASS <classname> DEFINITION.

...

METHODS: <method_name>

[ IMPORTING <im_var> TYPE <type>

EXPORTING <ex_var> TYPE <type>

CHANGING <ch_var> TYPE <type>

RETURNING VALUE(<re_var>) TYPE <type>

EXCEPTIONS <exception> ].

ENDCLASS

In ABAP Objects, methods can have IMPORTING, EXPORTING, CHANGING and

RETURNING parameters as well as EXCEPTIONS. All parameters can be passed by value or

reference.

You can define a return code for methods using RETURNING. You can only do this for a single

parameter, which additionally must be passed as a value. Also, you cannot then define EXPORTING

and CHANGING parameters. You can define functional methods using the RETURNING parameter

(explained in more detail below).

All input parameters (IMPORTING, CHANGING parameters) can be defined as optional parameters

in the declaration using the OPTIONAL or DEFAULT additions. These parameters then do not

necessarily have to be passed when the object is called. If you use the OPTIONAL addition, the

parameter remains initialized according to type, whereas the DEFAULT addition allows you to enter

a start value.

Methods and Visibility

CLASS lcl_airplane DEFINITION.

PUBLIC SECTION.

METHODS: set_name importing

im_name TYPE string.

PRIVATE SECTION.

METHODS: init_name.

DATA: name TYPE string.

ENDCLASS.

CLASS lcl_airplane IMPLEMENTATION.

METHOD init_name.

name = ‘No Name‘.

ENDMETHOD.

METHOD set_name.

IF im_name IS INITIAL.

  • Calling init_name

...

ELSE. name = im_name. ENDIF.

ENDMETHOD.

ENDCLASS.

Public methods

Can be called from

outside the class

Private methods

Can only be called

within the class

Methods, like attributes, must be assigned to a visibility area. This determines whether the methods

can be called from outside the class or only from within the class.

Instance Methods and Static Methods

Instance methods

Can use both static and instance components in the

implementation part

Can be called using the instance name

Static methods

Can only use static components in the implementation part

Can be called using the class name

Static methods are defined on the class level. They are similar to instance methods, but with the

restriction that they can only use static components (such as static attributes) in the implementation

part. This means that static methods do not need instances and can therefore be called from

anywhere. They are defined using the CLASS-METHODS statement, and they are bound by the same

syntax and parameter rules as instance methods.

The term “class method” is common, but the official term in ABAP Objects (as in C++, Java) is

“static method”. This course uses the term “static method”.

Instance and Static Methods: Example

CLASS lcl_airplane DEFINITION.

PUBLIC SECTION.

METHODS: set_name importing

im_name TYPE string.

PRIVATE SECTION.

METHODS: init_name.

DATA: name TYPE string.

ENDCLASS.

CLASS lcl_airplane IMPLEMENTATION.

METHOD init_name.

name = ‘No Name‘.

ENDMETHOD.

METHOD set_name.

IF im_name IS INITIAL.

  • Calling init_name

...

ELSE. name = im_name. ENDIF.

ENDMETHOD.

ENDCLASS.

Instance and Static Methods: Example

CLASS lcl_airplane DEFINITION.

PUBLIC SECTION.

METHODS: set_name IMPORTING im_name TYPE string.

CLASS-METHODS: get_count RETURNING VALUE(re_count) TYPE I.

PRIVATE SECTION.

DATA: name TYPE string.

CLASS-DATA: count TYPE I.

ENDCLASS.

CLASS lcl_airplane IMPLEMENTATION.

...

METHOD get_count.

re_count = count.

ENDMETHOD

ENDCLASS

reward points to all helpful answers

Read only

Former Member
0 Likes
528

Hi,

Please read this...

https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abapObjectsGetting+Started&

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.allsaplinks.com/

http://www.sap-img.com/

http://www.sapgenie.com/

http://help.sap.com

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/

Helpful 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, ABY

Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
528

Hi,

Look this Wiki page:

<a href="https://wiki.sdn.sap.com/wiki/display/Snippets/ABAPObjects-CreatingyourFirstLocal+Class">ABAP Objects - Creating your First Local Class</a>

Regards.

Marcelo Ramos