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

oops tables statement

Former Member
0 Likes
2,780

Hi All,

I'm working on OOPS and got a typical problem.I've created a class in class builder and created methods for the class.while coding for the method itried to ues the tables statement. like tables : abc,def.

but its giving the error

You cannot use the TABLES statement within a method.

How can i resolve this?

Rgds,

Prajith

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,299

Hi,

In ABAP object TABLES statement is not allowed. The statement TABLES does nothing but create a work ares. Intead use DATA statement to create work area explicitly.

See what SAP says about this:

***************************************

Creating table work areas with the TABLES statement 
is forbiddenin ABAP Objects. 

In ABAP Objects, an error message occurs on: 

TABLES dbtab. 

Correct syntax:
---------------

DATA wa TYPE dbtab. 

Reason:
-------

The semantics of the TABLES statement is ambiguous. 

Instead of table work areas, you should use explicit work 
areas

******************************************

Let me know if you have any question.

Regards,

RS

5 REPLIES 5
Read only

Former Member
0 Likes
1,300

Hi,

In ABAP object TABLES statement is not allowed. The statement TABLES does nothing but create a work ares. Intead use DATA statement to create work area explicitly.

See what SAP says about this:

***************************************

Creating table work areas with the TABLES statement 
is forbiddenin ABAP Objects. 

In ABAP Objects, an error message occurs on: 

TABLES dbtab. 

Correct syntax:
---------------

DATA wa TYPE dbtab. 

Reason:
-------

The semantics of the TABLES statement is ambiguous. 

Instead of table work areas, you should use explicit work 
areas

******************************************

Let me know if you have any question.

Regards,

RS

Read only

Former Member
0 Likes
1,299

Hi Prajith ,

I cannot understand why you want to use TABLES in a method , as my understanding is that we use tables generally to define elements in out selection screen.

So if would be great if you could tell why you want to use the tables statement in the method , as this will help us suggest some alternative

Regards

Arun

Read only

0 Likes
1,299

Hi Arun!

I have some similar problem like Prajith. The reason is (in my case) in a method I would like to add a new record to table <b>USR01</b>. If I don't define it with statement <b>TABLES</b> the system doesn't recognizes him and says <b>Field "USR01" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.</b>. So I think somewhere I have to define it with <b>TABLES: USR01</b>. But by this I get that errormessage like Prajith too.

Have you any idea dear Arun R?

Read only

0 Likes
1,299

Hi Janos,

Usage of tables statement is prohibited in object oriented abap.u can define a work area type table.

DATA WA_ITAB TYPE USR01.

now u can add new record to the workarea and then to the table.

Regards,

Prajith

Read only

0 Likes
1,299

Hi Prajith,

thanx to Your help, but I have resolved the problem by another way. I have just created a function element than I'm call that from the method. I'ts work perfectly now

Bye