‎2013 Dec 06 5:58 AM
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?
‎2013 Dec 06 6:14 AM
‎2013 Dec 06 6:08 AM
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
‎2013 Dec 06 6:14 AM
‎2013 Dec 06 7:06 AM
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?
‎2013 Dec 06 8:20 AM
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!
‎2013 Dec 06 6:17 AM
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
‎2013 Dec 06 6:37 AM
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.
‎2013 Dec 06 6:55 AM
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