Skip to Content
author's profile photo Former Member
Former Member

TABLE in a class

I am new to ABAP, however I'd prefer to use ABAP objects if possible. Do I understand that a class cannot contain the TABLES keyword!!! If so what strategy do I use such that a class or instanciated object may own it's own data. In other words the class would query the database and the resultset would be exposed through an interface. I looked at persistence, but I don't think that would always be appropriate. What is the "best practice" in this case?

Message was edited by: EvilWonka

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Nov 16, 2004 at 07:45 PM

    Hi Michael,

    In regular Abap, TABLES declarations is use to store the data you read from a database. For example:

    TABLES: PA0001.

    SELECT * from PA0001 where pernr = '1'.


    In this code, the results of the reading of table PA0001 will be store in structure PA0001.

    In Abap object, you have to store your values into a defined variable/structure. So in object you should do something like this:

    data: lv_pa0001 type pa0001.

    select * into lv_pa0001 from pa0001 where pernr = '1'.


    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Horst Keller

      > PS: Yes you can add objects (i.e. references to

      > objects) to internal tables:


      > <b>DATA oref TYPE REF TI class.

      > DATA reftab TYPE TABLE OF REF TO class.

      > CREATE OBJECT oref TYPE class.

      > INSERT oref INTO TABLE reftab.</b>

      I seen that as:

      <b>DATA lr_foobar TYPE REF TO CL_FOOBAR.

      DATA lt_foobars LIKE TABLE OF lr_foobar.

      CREATE OBJECT lr_foobar.

      APPEND lr_foobar to lt_foobars.</b>

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.