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

Transpose internal table using dynamic table creation

0 Likes
561

I have an internal table with only one column it_table:

it_table:

sales_org

distribution_channel

division

material

.

.

.

Now I want to transpose this table so that i can download the table in an excel with only one row:

sales_org     distribution_channel     division     material.......

Please help me to implement this?

1 REPLY 1
Read only

Former Member
0 Likes
436

Hi,

You can create a dynamic table using some code like this:

  TRY.

      FREE lo_st_type.

      lo_st_type = cl_abap_structdescr=>create( gt_cols ).

      IF lo_st_type IS NOT INITIAL.

        CREATE DATA lo_st_data TYPE HANDLE lo_st_type.

        UNASSIGN <fs_data_wa>.

        ASSIGN lo_st_data->* TO <fs_data_wa>.

        CREATE DATA lo_data LIKE STANDARD TABLE OF <fs_data_wa>.

        UNASSIGN <g_table>.

        ASSIGN lo_data->* TO <g_table>.

      ENDIF.

    CATCH cx_sy_table_creation.

  ENDTRY.

gt_cols is type abap_component_tab and should have as many lines as your table it_table.

After you create the dynamic table you have to fill it with the info in it_table.

Try it out and I will help you if needed.

Martin