Application Development 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: 

class builder

Former Member
0 Kudos

Hello everyone,

in class builder (SE24) there are the folders Friends & Aliases. Can any one explain what they are for ??

Thanks in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi

good

Use

Generally users of a class may only access the public components of that class. Sometimes, however, you might want to create a closer link between classes. The concept of friends could be of use here.

In this case a class can permit explicitly named users (friends) to access its protected and private components.

Prerequisites

All the users declared to be friends (classes and interfaces) were already created.

Procedure

Select the defining class and change to the Class Editor.

Choose Friends.

Go to change mode.

Under Friends, enter the classes or interfaces for which you want to permit access to the protected and private components of the defining class.

If you specify an interface for Friends, this means that all the classes that implement this interface have access to the protected and private components.

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

If there are alias names (title element Aliases) for interface components, these are output in the method display instead of the long name.

thanks

mrutyun

6 REPLIES 6

Former Member
0 Kudos

hi

good

Use

Generally users of a class may only access the public components of that class. Sometimes, however, you might want to create a closer link between classes. The concept of friends could be of use here.

In this case a class can permit explicitly named users (friends) to access its protected and private components.

Prerequisites

All the users declared to be friends (classes and interfaces) were already created.

Procedure

Select the defining class and change to the Class Editor.

Choose Friends.

Go to change mode.

Under Friends, enter the classes or interfaces for which you want to permit access to the protected and private components of the defining class.

If you specify an interface for Friends, this means that all the classes that implement this interface have access to the protected and private components.

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

If there are alias names (title element Aliases) for interface components, these are output in the method display instead of the long name.

thanks

mrutyun

Former Member
0 Kudos

Hi,

A friend is a relationship between a class and its users.

With a friends relationship a class gives the explicitly named users access to its PROTECTED and PRIVATE components.

Regards,

Ravi

Note : please mark the helpful answers

Former Member
0 Kudos

You can assign all the components of the interfaces alias names as an abbreviation for the full name. To do so, click on Aliases and enter the alias name. In addition to the name, you can also define the visibility (PUBLIC, PROTECTED, PRIVATE) and thus restrict the use of alias names.

http://help.sap.com/saphelp_nw04/helpdata/en/ef/d94b78ebf811d295b100a0c94260a5/frameset.htm

Generally users of a class may only access the public components of that class. Sometimes, however, you might want to create a closer link between classes. The concept of friends could be of use here.

In this case a class can permit explicitly named users (friends) to access its protected and private components.

http://help.sap.com/saphelp_nw04/helpdata/en/ef/d94b78ebf811d295b100a0c94260a5/frameset.htm

Former Member
0 Kudos

Hi Jorge,

In SE24, Friends tab signifies all the friend methods that can be defined for a class. Friend methods are those methods which is from another class , which can access the protected and private components of the class.

It acts as a "friend" to the class, because normally private members can be accessed by the methods of that class only.

Regards,

SP.

Former Member
0 Kudos

ALIASES

Basic form

ALIASES alias FOR intf~comp.

Effect

You can only use this statement in the declaration part of a class or in the definition of an interface in ABAP Objects. It defines an alias name alias, which is a synonym for a component intf~comp of an interface implemented using the INTERFACES statement.

An alias name is a short form of the full name of a component that you add to a class by implementing the interface to which it belongs. Alias names belong to the namespace of the components of the class, and must, like all other components, be assigned to a visibility section. The visibility of an alias name from outside the class depends on its own visibility section, and not that of the interface component to which it belongs.

Notes

You can use alias names in classes to ensure that class components that are replaced by components from interfaces can still be addressed using their old names. This ensures that the users of the class do not have to adjust the names.

The most important use of alias names is in compound interfaces. Within the definition of a compound interface, you cannot address the components of component interfaces - that are nested to a depth greater than one level - directly, but only using alias names.

Example

INTERFACE I1.

DATA A.

ENDINTERFACE.

INTERFACE I2.

INTERFACES I1.

ALIASES A1 FOR I1~A.

DATA A LIKE A1.

ENDINTERFACE.

CLASS C1 DEFINITION.

PUBLIC SECTION.

INTERFACES I2.

ALIASES: A1 FOR I2~A1,

A2 FOR I2~A.

PRIVATE SECTION.

DATA A LIKE A2.

ENDCLASS.

DATA: CREF TYPE REF TO C1,

IREF1 TYPE REF TO I1,

IREF2 TYPE REF TO I2.

CREATE OBJECT CREF.

IREF2 = CREF.

IREF1 = IREF2.

CREF->A1 = 'X'.

CREF->A2 = 'Y'.

WRITE: / IREF1->A, IREF2->A1,

/ IREF2->A.

Syntax Diagram

ALIASES

ALIASES alias~ident FOR ALIAS_COMPONENT

Friend

The specified object types (classes or interfaces) obj_type_1 ... obj_type_n are declared as friends of the current class. In this way, these object types and all the object types derived from these through inheritance, inclusion, and implementation are allowed to access PROTECTED and PRIVATE components, in addition to PUBLIC components. They can also create instances from the class, irrespective of the specifications in the CREATE addition. All classes and interfaces from the same program as well as global classes and interfaces from the class library can be specified as object types.

former_member188685
Active Contributor