ABAP: How to create a dynamic internal table and work area
FIELD-SYMBOLS:<fs_table> TYPE STANDARD TABLE, <fs_table_wa> TYPE ANY. DATA: table_ref TYPE REF TO data, wa_ref TYPE REF TO data. DATA: l_structure TYPE dd02l-tabname value 'VBAP'. CREATE DATA table_ref TYPE STANDARD TABLE OF (l_structure). ASSIGN table_ref->* TO <fs_table>. CREATE DATA wa_ref LIKE LINE OF <fs_table>. ASSIGN wa_ref->* TO <fs_table_wa>.
Now you have the table <fs_table> and the work area for it <fs_table_wa>.
If you like this post, you may as well like these too:
- ABAP Programs: Filling an internal table from a database table REPORT ZSOURCE1203.* Work area for a database tableTABLES CUSTOMERS.* Defining an internal table with header lineDATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100 WITH HEADER LINE.* Filling the internal table (previous content...
- ABAP Programs: Using a dynamic table name REPORT ZSOURCE1110.* Variables for later useDATA: TABLENAME(10), COUNT_ROWS TYPE I.* Setting the table name dynamicallyMOVE ‘CUSTOMERS’ TO TABLENAME.* Selecting dataSELECT COUNT( * ) FROM (TABLENAME) INTO COUNT_ROWS.WRITE: TABLENAME, COUNT_ROWS. ~...
- ABAP Programs: Dynamic read table command REPORT ZSOURCE2303. * Parameters for reading a single line, can be modified by the end user PARAMETERS: KEY1(10) DEFAULT ‘NAME’, VALUE1(25), KEY2 LIKE KEY1 DEFAULT [...]...
- ABAP Programs:Dynamic Open SQL Commands: table name REPORT ZSOURCE2305. PARAMETERS TABLENAME(10) DEFAULT 'CUSTOMERS'. DATA COUNT_ROWS TYPE I. SELECT COUNT( * ) FROM (TABLENAME) INTO COUNT_ROWS. WRITE: TABLENAME, COUNT_ROWS. DATA WHERE_TAB(80) OCCURS 10 WITH HEADER LINE. APPEND 'name...
- ABAP Programs: A simple internal table REPORT ZSOURCE1201.* Work area for a database tableTABLES CUSTOMERS.* Defining an internal tableDATA ALL_CUSTOMERS LIKE CUSTOMERS OCCURS 100.* Reading all entries of the database table into the internal tableSELECT *...
















Hi,
Sorry but it is a very crappy method. SAP use generated form to declare data, so you are limited by the stack size for the number of call of this method. (approx. 20 times for my current sap system)
It's better to use create data with a declared ddic structure (when possible)
This instruction :
)
generate subroutine pool lt_source[] name l_name
message l_message line l_line word l_word.
is used by the function "ALV_TABLE_CREATE" which is called by the method cl_alv_table_create=>create_dynamic_table (or perhaps called by a function called by the method
And in sap documentation you can read :
Up to 36 temporary subroutine pools can currently be managed for each roll area. (not 20 as i said previously)
So, this method is not usable in case of recurrent call. That's why a create data with ddic structure is betten, when possible.
Nice, thanks for your inputs. Updated the code
[...] here: ABAP: How to create a dynamic internal table and work area Leave a [...]
I can not imagine finding this information right on time, thank you.
Ever heard of ABAP Runtime Type Services classes that are available since 6.40? There are Object-Oriented APIs for dynamic creation and instantiation of strtuctures, internal tables and so on. For more info you can have a look at:
http://help.sap.com/abapdocu_70/en/ABENCREATE_DAT...
Best Regards and a Happy New Year:)