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

Exporting table from methode

Former Member
0 Likes
1,367

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,242

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

5 REPLIES 5
Read only

Former Member
0 Likes
1,243

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

Read only

0 Likes
1,242

There is no Return Type "Table". Only Type: "Importing", "Exporting", "Changing" and "Returning" and as Typing Method only "Like", "Type" and "Type Ref To" ?

Read only

0 Likes
1,242

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

Read only

0 Likes
1,242

...

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?

Read only

0 Likes
1,242

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