2014 Jul 28 11:01 PM
Hi experts,
i'm wondering if its posible to declare a X table from a parameter the user send...
PARAMETERS: type_table TYPE STRING.
DATA: temp_table TYPE type_table.
################################
Execute program
type_table: T001
so temp_table would be T001 type.
Regards
2014 Jul 29 5:19 AM
Have a look at this snippet. It creates a data reference of table type specified by user, and then uses a select query to populate 10 records of that database table to data reference via field symbol.
PARAMETERS tabname TYPE dd02l-tabname OBLIGATORY DEFAULT 'MARA'.
DATA dref TYPE REF TO data.
CREATE DATA dref TYPE STANDARD TABLE OF (tabname).
FIELD-SYMBOLS <fs> TYPE ANY TABLE.
ASSIGN dref->* TO <fs>.
SELECT * FROM (tabname) INTO TABLE <fs> up to 10 rows.
Have a look at this snippet. It creates a data reference of table type specified by user, and then uses a select query to populate 10 records of that database table to data reference via field symbol.
PARAMETERS tabname TYPE dd02l-tabname OBLIGATORY DEFAULT 'MARA'.
DATA dref TYPE REF TO data.
CREATE DATA dref TYPE STANDARD TABLE OF (tabname).
FIELD-SYMBOLS <fs> TYPE ANY TABLE.
ASSIGN dref->* TO <fs>.
SELECT * FROM (tabname) INTO TABLE <fs> up to 10 rows.
2014 Jul 28 11:17 PM
Hello Alonso,
You can create dynamic internal tables. Review this link:
Dynamic Internal table - ABAP Development - SCN Wiki
I hope you help.
2014 Jul 29 4:55 AM
Hi,
See also RTTS - Runtime Type Services .
RTTC - Run Time Type Creation .
http://wiki.scn.sap.com/wiki/pages/viewpage.action?pageId=42965
Regards.
Some code:
2014 Jul 29 5:07 AM
2014 Jul 29 5:14 AM
2014 Jul 29 5:19 AM
Have a look at this snippet. It creates a data reference of table type specified by user, and then uses a select query to populate 10 records of that database table to data reference via field symbol.
PARAMETERS tabname TYPE dd02l-tabname OBLIGATORY DEFAULT 'MARA'.
DATA dref TYPE REF TO data.
CREATE DATA dref TYPE STANDARD TABLE OF (tabname).
FIELD-SYMBOLS <fs> TYPE ANY TABLE.
ASSIGN dref->* TO <fs>.
SELECT * FROM (tabname) INTO TABLE <fs> up to 10 rows.
2014 Jul 29 6:53 AM
2014 Jul 30 4:27 PM
That was correct!!!
PARAMETERS: tipo_tab TYPE STRING.
SYMBOLS: <temp_table> TYPE STANDARD TABLE.
DATA struct TYPE REF TO DATA.
CREATE DATA struct TYPE STANDARD TABLE OF (tipo_tab).
ASSIGN struct->* TO <temp_table>.
<removed by moderator>
Message was edited by: Manish Kumar
2014 Jul 29 6:00 AM
2014 Jul 29 7:19 AM
Hi Alonso,
to create a table with an unknown type, you need a field-symbol instead of a "normal" internal table. You define it as
FIELD-SYMBOLS <table> TYPE table.
Then you need your parameter for the type of the table. Define it as
DATA type_table TYPE ddobjname.
Then you need an Object for your data. You define it as
DATA dref_t TYPE REF TO data.
Now you can use
TRY.
CREATE DATA dref_t TYPE TABLE OF (type_table).
ASSIGN dref_t->* TO <table>.
CATCH cx_sy_create_data_error.
* Do some error handling
ENDTRY.
Now you can use <table> as internal table of the type given in the parameter type_table.
If you want some information about the structure of the table, you can use the function module DDIF_FIELDINFO_GET.
Regards
Claudia
2014 Jul 29 9:10 AM
Hi Alonso,
You can do it easily using the following steps:
PARAMETERS : p_table(10) TYPE C.
DATA: w_tabname TYPE w_tabname,
w_dref TYPE REF TO data.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
w_tabname = p_table.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
Thanks and Regards,
Ashish
2014 Jul 30 4:30 PM
thank you all!!!
PARAMETERS: tipo_tab TYPE STRING.
SYMBOLS: <temp_table> TYPE STANDARD TABLE.
DATA struct TYPE REF TO DATA.
CREATE DATA struct TYPE STANDARD TABLE OF (tipo_tab).
ASSIGN struct->* TO <temp_table>.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |