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

table type in DATA definition

raffinkira
Participant
0 Likes
926

Usually, I use TYPES to define structure and use DATA xxx type standard table of  a certain type defined before.

But when I optimize some old programs, the previous programmer wrote sth like:

DATA: BEGIN OF tab_g_item OCCURS 0,

     maktx   LIKE  makt-maktx,       "

     fkimg   LIKE  vbrp-fkimg,           "

END OF tab_g_item.

So what kind of table ' tab_g_item' is? Is it a standard table? what if I want to make it a sorted table?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
890

if you  use OCCURS 0 WITH HEADER LINE then tab_g_item is an internal table.

OCCURS is obsolete command.

It defines an internal table with memory allocated to store a specified number of rows of the internal table in the main memory.

For more information

7 REPLIES 7
Read only

former_member188827
Active Contributor
0 Likes
890

Yes, it is standard table. In order to define sorted table, first define type using TYPES and then declare internal table using data statement.

Regards

Read only

Former Member
0 Likes
891

if you  use OCCURS 0 WITH HEADER LINE then tab_g_item is an internal table.

OCCURS is obsolete command.

It defines an internal table with memory allocated to store a specified number of rows of the internal table in the main memory.

For more information

Read only

0 Likes
890

so if tab_A is  a table.

DATA tab_B like table of tab_A.

DATA tab_B like tab_A occurs 0.

both of the above two definition are correct, but the second is not preferred, right?

Read only

matt
Active Contributor
0 Likes
890

Occurs is obsolete and should not be used in new programs. If you are maintaining old programs, then it is a good idea to refactor without occurs.

I'm now locking this thread, since it is answered, to prevent more people adding the same information you've already received!

Read only

Former Member
0 Likes
890

Hi

the usage of occurs clause is now obsolete. It is a standard table only. Occurs clause is mainly used for specifying the amount of memory to be used. Occurs 0 will allow to use 8 KB pages of memory at a time .

With Regards

Suneesh Thampi

Read only

rekha_manjunath2
Participant
0 Likes
890

if the tab_g_item needs to be an internal table and a work area then it can be declared as with header line.

Occurs 0 just allots space of 8kb to internal table.

Read only

Ajit_K_Panda
Product and Topic Expert
Product and Topic Expert
0 Likes
890

Hi Ming,

Yes it is a standard table. To create a sorted table, you can write as below:

TYPES: BEGIN OF tab_g_item ,

     maktx   LIKE  makt-maktx,       "

     fkimg   LIKE  vbrp-fkimg,           "

END OF tab_g_item.

DATA: lt_g_item   type sorted table of tab_g_item.

Regards,

Ajit