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

Reg: Class Method and Attributes

Former Member
0 Likes
1,034

Hi,

I am using a class "CL_TEST". In that I have one private instance method called "MAKE_NODES". This method has 2 parameters:

NODES Changing Type CHG_NODES

NVALS Changing Type NET_NVALS

am calling this method inside another public instance method of same class as follows:

call method make_nodes

changing

nodes = nodes_tab "Instance Private attribute

nvals = nvals_tab. "Instance private attribute

It is throwing some error.

I have the following doubts.

1)Nodes and Nvals parameters can hold only one record?

2) If I use "CHANGING" as Type, it means nodes and nvals can be used in the calling method. Am I right?

3) I want to get 2 internal tables as output by this method. How can I do that?

2 REPLIES 2
Read only

Former Member
0 Likes
658

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.

cheers,

Hema.

Read only

uwe_schieferstein
Active Contributor
0 Likes
658

Hello Kalai

I assume there is a problem with the data types either of the attributes or the method parameters.

I further assume that your private method should use NVALS_TAB as input to create NODES_TAB as output. In this case you should define the method signature as following:


METHOD my_public_method.


  CALL METHOD me->make_nodes
    EXPORTING
      nvals = nvals_tab
    RETURNING
      nodes = nodes_tab.

" NOTE: nvals and nvals_tab must be of the same table type. Same is true for nodes & nodes_tab
" If your release > 4.6c then you can use the function method call:

  nodes_tab = me->make_nodes( nvals_tab ). " Java-like coding

ENDMETHOD.

Regards

Uwe