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

CREATING METHODS AND CLASS

Former Member
0 Likes
5,962

Hi All....

Can anyone give me the step by step instructions for creating a 'method' and a 'class'...

i'l be very grateful and obviously will reward.

Santhosh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,158

hi,

You can download this PDF ABAP Objects.

http://www.esnips.com/doc/6d16a298-9227-4d32-acf1-e91164c89daf/3-ABAP-Objects(P283)

Hope this helps you.

Edited by: Runal Singh on Jan 23, 2008 5:39 PM

4 REPLIES 4
Read only

Former Member
0 Likes
2,158

hi,

The Class Builder allows you to create and maintain global ABAP classes and interfaces. Both of these object types, like global data types, are defined in the ABAP Repository, thus composing a central class library. Together, they form a central class library and are visible throughout the system. You can display existing classes and interfaces in the class library using the Class Browser.

Features

Use the Class Builder to:

· Display an overview (in the Class Browser) of global object types and their relationships.

· Maintain existing global classes or interfaces.

· Create new global classes and interfaces.

· Implement inheritance between global classes

· Create compound interfaces

· Create and specify the attributes, methods, and events of global classes and interfaces.

· Define internal types in classes.

· Implement methods.

· Redefine methods

· Maintain local auxiliary classes.

· Test classes or interfaces in a simulated runtime environment.

To create a new class from the initial screen of the ABAP Workbench:

Enter the name of the new class according to the naming conventions under Object type.

Choose Create.

The Create Class dialog box appears with the name of the class:

Enter the following details for the subclass definition:

- Class

Name of the new class.

Create Inheritance

When you choose this function, the Inherits from dialog box appears. You can define the inheritance relationship here by specifying the name of the superclass.

You can define the superclass as any class from the class library that is not defined as final.

- Description

A short text describing the new class.

- Inst. Creation

In general, classes are marked with the Public option. This means that each user can create instances of the particular class (with CREATE OBJECT).

The Protected option defines that only inherited classes or the relevant class itself can create instances of this class.

If you choose the Private option, only the relevant class itself can create its instances (only using its own method).

You can define an abstract class with the Abstract option. You cannot create an instance for this class. An abstract class can be used as template for your subclasses. You can only access this class with your static attributes or with your subclasses.

- Class type

You define the basic type and use of the class here. Copy the entry Normal ABAP class. You can also choose Exception class or Persistent class. You can find more information about these special classes under:

Defining Exception Classes

Defining Persistent Classes

- Final

You define a final class with the Final option. This class completes the inheritance hierarchy since a final class may not create any further subclasses.

If an abstract class is also defined as final. This is advisable if you only want to access the static components of this class.

- Modeled only

If you select this option, the class is not included in the class pool. You will not be able to address it at runtime or test it.

Choose Save.

The Create Object Catalog Entry dialog box is displayed.

Enter the Package.

Choose Save.

Hope this is helpful, Do reward.

Read only

Former Member
0 Likes
2,158

hi,

T-code for class builder is se24

Methods describe how an object behaves. You implement them using functions defined within classes. They are operations that change the attributes of a class or interface. There are instance- and static methods. Instance methods refer to a certain class instance, whereas static methods are common to all the class instances. Static methods can only address static attributes.

The special methods include constructors and class constructors. Constructors (class constructors) need not be created explicitly if they are not to be implemented.

Prerequisites

You must already have created the class or interface. It is useful if you have already created the attributes of the class, since you can branch directly from a method definition in the Class Builder to its implementation.

Procedure

To create methods for classes and interfaces:

Change to the Class Editor.

Choose Methods.

To create a method, make the following entries:

- Methods

Define a unique name with which the method is identified.

Type

Specifies the type as an instance method or a static method (not instance-specific).

- Visibility

Define the visibility of methods for the user of the class. Public assigns the method to the public area of the class and the method can be called by every user of the class. If you make the method protected, it is visible to and can be used by the class itself and any of its subclasses. If the method is private, it is only visible in and available to the class itself. Private methods do not form part of the external point of contact between the class and its users.

- Modeled only

If the flag is set, no entry will be made in the class pool. You cannot access the components at runtime.

- Description

Short description of the method.

Repeat the above steps for any further methods.

Hope this is helpful, Do reward.

Read only

Former Member
0 Likes
2,159

hi,

You can download this PDF ABAP Objects.

http://www.esnips.com/doc/6d16a298-9227-4d32-acf1-e91164c89daf/3-ABAP-Objects(P283)

Hope this helps you.

Edited by: Runal Singh on Jan 23, 2008 5:39 PM

Read only

Former Member
0 Likes
2,158

Thank you...