Skip to Content
author's profile photo Former Member
Former Member

Dynamic internal table- column to row conversion

Hello all,

Inside a program i generate a dynamic internal table and

This table has one single column. But I need to convert the rows as columns.

Eg:

dynamic internal table ITAB has content

-


Forbes

Times

Reuters

Warner

stern

-


I would like to have a ITAB2 like this

-


Forbes Times Reuters Warner Stern

-


Please note this is a Dynamic internal table!!!!

I need some approach for my problem. Thanks a lot in advance.

Karthik.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2006 at 08:20 AM

    Hello,

    My suggestion is built one more fieldcatalog table with the fields u specified in the Itab1.

    Then from that fíeld catalog table create one more dynamic itab2.

    If my suggestion is helpful for u dön't forget to reward points.

    Regards,

    Vasanth

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 04, 2006 at 08:16 AM

    Hello,

    Is your requirement an interal table or a field string?

    If you need an internal table please give an example for appending second line/record.

    Best Regards, Murugesh AS

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 04, 2006 at 08:17 AM

    hi ,

    complete field-attributes and

    use fm LVC_TABLE_CREATE

    A.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2006 at 08:27 AM

    Refer the function module CLRS_GENERATE_OUTTAB to understand creating internal tables dynamically.

    -Kiran

    *Please reward utile answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 04, 2006 at 09:22 AM

    Hi karthik,

    1.

    For this purpose,

    in my program,

    <b> there is an INDEPENDENT FORM</b>

    whose inputs are

    <b> LIST OF FIELDS, (just as u require)</b>

    and from those, it consructs dynamic table.

    2. Here is the program.

    the dynamic table name will be

    <DYNTABLE>.

    3. U can use this program (FORM in this program)

    to generate any kind of internal table

    by specifying list of fields.

    4.

    REPORT abc.

    *----


    COMPULSORY

    FIELD-SYMBOLS: <dyntable> TYPE ANY TABLE.

    FIELD-SYMBOLS: <dynline> TYPE ANY.

    DATA: lt TYPE lvc_t_fcat.

    DATA: ls TYPE lvc_s_fcat.

    FIELD-SYMBOLS: <fld> TYPE ANY.

    DATA : fldname(50) TYPE c.

    DATA : ddfields LIKE ddfield OCCURS 0 WITH HEADER LINE.

    *----


    START-OF-SELECTION.

    *----


    field list

    ddfields-fieldname = 'BUKRS'.

    APPEND DDFIELDS.

    ddfields-fieldname = 'MATNR'.

    APPEND DDFIELDS.

    *----


    PERFORM mydyntable .

    *----


    see <DYNTABLE> in debug mode.

    BREAK-POINT.

    *----


    • INDEPENDENT FORM

    *----


    FORM mydyntable .

    *----


    Create Dyn Table From FC

    FIELD-SYMBOLS: <fs_data> TYPE REF TO data.

    FIELD-SYMBOLS: <fs_1>.

    FIELD-SYMBOLS: <fs_2> TYPE ANY TABLE.

    DATA: lt_data TYPE REF TO data.

    data : lt TYPE lvc_t_fcat .

    *----


    CONSTRUCT FIELD LIST

    LOOP AT ddfields.

    ls-fieldname = ddfields-fieldname.

    APPEND ls TO lt.

    ENDLOOP.

    ASSIGN lt_data TO <fs_data>.

    CALL METHOD cl_alv_table_create=>create_dynamic_table

    EXPORTING

    it_fieldcatalog = lt

    IMPORTING

    ep_table = <fs_data>

    EXCEPTIONS

    generate_subpool_dir_full = 1

    OTHERS = 2.

    IF sy-subrc <> 0.

    ENDIF.

    *----


    Assign Dyn Table To Field Sumbol

    ASSIGN <fs_data>->* TO <fs_1>.

    ASSIGN <fs_1> TO <fs_2>.

    ASSIGN <fs_1> TO <dyntable>.

    ENDFORM. "MYDYNTABLE

    regards,

    amit m.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 09:04 PM

    Hi i had the same problem when downloading data using GUI_DOWNLOAD.

    i used the below solution.

    data: lt_data type table of string.

    data: wa_data type string.

    data: lv_tab type c value cl_abap_char_utilities=>horizontal_tab.

    call function 'GET_COMPONENT_LIST'

    exporting

    program = your program name

    fieldname = your internal table

    tables

    components = li_components.

    loop at li_components.

    concatenate wa_data lwa_fldname-compname lv_tab into wa_data.

    endloop.

    append wa_data to lt_data.

    then call GUI_DOWNLOAD

    Hope this helps

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.