‎2010 Apr 21 9:26 AM
Hi experts,
how can I handle it to exporting a table from a structure from a methode?
At the moment I export the structure in the methode but I need to export a table.
At the moment:
Parameter Type Typing Methode Associated Type
param_1 Exporting Type structure
I need something like that:
Parameter Type Typing Methode Associated Type
param_1 Exporting Type Table of structure
... but that is not possible
‎2010 Apr 21 10:32 AM
Hi,
just define a table-type for your structure in the datadictionary and use it in your method.
Otherwise you could use the return type "table" and create a dynamic table based on your
structure in the method.
Greetings,
dsp
‎2010 Apr 21 10:32 AM
Hi,
just define a table-type for your structure in the datadictionary and use it in your method.
Otherwise you could use the return type "table" and create a dynamic table based on your
structure in the method.
Greetings,
dsp
‎2010 Apr 21 11:39 AM
There is no Return Type "Table". Only Type: "Importing", "Exporting", "Changing" and "Returning" and as Typing Method only "Like", "Type" and "Type Ref To" ?
‎2010 Apr 21 11:43 AM
DSP is right.
All you need is:
- go to ABAP Dictionary and create table type using structure you have as its line type
- then in your method use exporting parameter, give type as typeing method and table_type you just created as the type itself
You should then be able to export object which is typed as a table, having a line typed as the structure you need.
Regards
Marcin
‎2010 Apr 21 11:46 AM
...
Otherwise you could use the return type "table" and create a dynamic table based on your
structure in the method.
....
How Can I handle this suggestion in detail?
‎2010 Apr 21 11:56 AM
I think he meant something like this
CLASS lcl_test DEFINITION.
PUBLIC SECTION.
CLASS-METHODS: get_tab EXPORTING gen_table TYPE table.
ENDCLASS.
CLASS lcl_test IMPLEMENTATION.
METHOD get_tab.
SELECT * FROM sflight INTO TABLE gen_table UP TO 10 ROWS.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA: it_sflight TYPE TABLE OF sflight.
lcl_test=>get_tab( IMPORTING gen_table = it_sflight ).
"here IT_SFLIGHT holds what you want
Of course you could make it more generic, meaning query dynamic DB table inside get_tab and create dynamic table outside the method call to get returned data to that table. But basically it shows the idea.
Regards
Marcin