2

In the following code:

TABLES: lqua.
CLASS TEST DEFINITION.
PRIVATE SECTION.
  TYPES: BEGIN OF tt_data,
          lgpla TYPE lqua-lgpla,
          matnr TYPE lqua-matnr,
         END OF tt_data.
ENDCLASS.

How could I get rid of the TABLES statement? As far as I understand, it is best-practice to avoid the TABLES statement, and it is forbidden in classes. When I omit it, the definition of tt_data throws a syntax error because lqua-lgpla is unknown.

Kevin Holtkamp
  • 479
  • 4
  • 17
  • If you remove the line `TABLES: lqua`, your code remains valid and works unchanged. Maybe your question is more what is `TABLES` for? Or maybe your code is inside a class pool (you don't say), hence a syntax error. – Sandra Rossi May 20 '22 at 13:44
  • Does this answer your question? [SAP passing data from application to screen. How does 'TABLES' work?](https://stackoverflow.com/questions/7218284/sap-passing-data-from-application-to-screen-how-does-tables-work) – Suncatcher May 20 '22 at 14:51

1 Answers1

2

This does compile without any error.

REPORT zzpj_so.

CLASS test DEFINITION.
  PRIVATE SECTION.
    TYPES: BEGIN OF tt_data,
             lgpla TYPE lqua-lgpla,
             matnr TYPE lqua-matnr,
           END OF tt_data.
ENDCLASS.

What does not is for example this piece of code.

REPORT zzpj_so.

CLASS test DEFINITION.
  PRIVATE SECTION.
    TYPES: BEGIN OF tt_data,
             lgpla LIKE lqua-lgpla,
             matnr LIKE lqua-matnr,
           END OF tt_data.
ENDCLASS.
Jagger
  • 10,350
  • 9
  • 51
  • 93
  • 1
    I feel so stupid now, I fixed it myself while typing the question. On the other hand, congratz to now over 10k reputation! – Kevin Holtkamp May 20 '22 at 08:00
  • 1
    You probably mixed up `LIKE` and `TYPE` or read about it somewhere. `LIKE` and `STRUCTURE` are not allowed in OO-Context when defining types of structure fields. – Jagger May 20 '22 at 08:03
  • @KevinHoltkamp Don't hesitate to not post the question or delete it if you don't find it useful for future visitors. If you find a solution, you should post an answer, it will help future visitors. – Sandra Rossi May 20 '22 at 13:41
  • 1
    @SandraRossi I thought maybe I leave it up incase someone else uses `LIKE` instead of `TYPE`, but in itself the question might not be very useful. What do you think? – Kevin Holtkamp May 23 '22 at 10:07