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: 

Is there a table type ATTRIBUTE that can be defined in an ABAP object?

Former Member
0 Kudos

Hi. Within SE24 on the Attributes tab, is there a way to define an attribute of type TABLE? If you put in STANDARD TABLE as the reference type, it does not allow a generic table type.

What I want to do is pass in a standard table type to my constructor, and then assign it to a private table attribute in the object.

I do not want to assign the table to a local variable of the constructor. I want to store the table in a private object attribute. I don't mind if the attribute type is a specific table type (such as KNA1), I just want to be able to assign the constructor's table parameter to some type of private object attribute.

Thanks.

Brendan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Brendan,

I think what you need to do is to create a TABLE TYPE in SE11 Data dictionary and then create the attribute by refrerring to the TABLE TYPE. There is no other go.

Regards,

Ravi

Note : Please mark the helpful answers

13 REPLIES 13

Former Member
0 Kudos

Brendan,

I think what you need to do is to create a TABLE TYPE in SE11 Data dictionary and then create the attribute by refrerring to the TABLE TYPE. There is no other go.

Regards,

Ravi

Note : Please mark the helpful answers

naimesh_patel
Active Contributor
0 Kudos

Hi,

You have to create Table type in SE11 to achieve this.

Regards,

Naimesh

Former Member
0 Kudos

Hi,

There are two ways of doing this...

1. As suggested by others, create a table type in SE11 and refer the table type in the attributes tab.

2. Create a type-pool(which contains the required table type definition) and attach the type-pool to the class in the Properties Tab (Check TYPE Group/Object Type Section in the Properties Tab). THen you can refer the table type defined in the Type pool to create an attribute.

Regards,

Vara

Former Member
0 Kudos

Thank you. I tried clicking on the modeled checkbox, but it still does not allow a generic type.

0 Kudos

You should not check the Modelled Checkbox. If you check that Checkbox then you cannot use the attribute for the real time purpose.

The status specifies the development status of an object type, component, or relationship.

The possible statuses are modeled or realized. Only object types and components with status realized can have executable code.

If the field is selected, the component has the status modeled, or more precisely only modeled.

Regards,

Vara

0 Kudos

Hi, Vara. Is modeled equivalent to an abstract class

designation?

Thanks.

0 Kudos

Hi Brendan,

No they are not same. A modelled class or method or an attribute will not have any realtime appliaction. Say for example you want to provide a method or Attribute which may be used in future or expected to be used in future, then you declare that method as Modelled. YOu can execute such a method or access such an attribute.

Abstract Class is an executable class...but it will have some methods with no implementation. The implementation of such methods will upto the user who is accessing that class.A class defined as ABSTRACT cannot be instantiated, that is, you cannot use CREATE OBJECT with reference to the class. Instead, you can only address the class using its static components or its subclasses. The major purpose of an abstract class is to serve as a template for subclasses.

If a class contains abstract methods, that is, method declarations with the ABSTRACT addition, the whole class must also be abstract (that is, have the ABSTRACT addition), since a class may not be instantiated if it has unimplemented methods. Equally, if a subclass does not implement all of the abstract methods of its superclasses, it must itself declare them abstract.

Regards,

Vara

0 Kudos

Thank you, Vara. I will reward points, but if I may, can I just ask you one more question...

I understand abstract classes and OO concepts, but my difficulty always arises when I try to translate the OO

concepts into definitions using the SAP class builder ;).

We are on 4.5B. How do I specify an abstract class in SE24? The only thing I see is the modeled check box, and that's why I thought that modeled was the SAP equivalent to abstract in java... The only options I have available in SE24 are class or interface, but I do not see how to specify an ABSTRACT class in SE24 in my version.

There are many times when I do not want to have a class implement an interface, but instead, I want the class to be abstract so that I can factor common behavior into the base class.

Thanks!

Brendan

0 Kudos

Brendan,

Usually you can declare the class as Abstract in the Properties tab of the Class builder. Check the Instantiation of the Class - you will be provided with four options Public, Private, Protected and Abstract. If you there is no Abstract option, then you cannot declare the class as Abstract.

Actually I have not worked on 4.5B, I am not very sure whether SAP included ABSTRACT type for a class in 4.5 or not. I am sorry for that.

Regards,

Vara

0 Kudos

Hmmm... I'm not sure either. I do not have a Properties tab in the class builder of 4.5B. I only have Admin, Interfaces, Attributes, Methods, Events, and Types.

I was thinking that there might be something on the Types tab, but nothing seems obvious there... Also on my Admin tab there is a Category drop down box with a "Shared" designation available.

See what I mean about translating the OO equivalence into SE24?

Thanks!

0 Kudos

Brenden,

are you able to create a local Abstract Class ?

I mean can you create a local class with Abstract addition ?

If you can create the local class, then there should be some procedure to create in SE24 also.

Regards,

Vara

0 Kudos

Vara,

Thanks for the suggestion. I created a local class, tried to specify absract, and that appears to be invalid in 4.5B. I took out the abstract keyword and it passes the syntax check.

Guess I have to wait until we upgrade. I will award points.

Thanks again.

Former Member
0 Kudos

Try this,

Go into SE24, go to the attribures tab, type in the name of the attribute, the level (e.g. Instance), the visibiliy (e.g. Private), click on the arrow. This takes you into the Private Section (if you put Private as the Visibility).

You should see the variable defined add the type information after the variable.

e.g. it_kna1 TYPE standard table of kna1 initial size 0 .

HTH

Walter