Application Development 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: 

Dynamic internal table- column to row conversion

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

8 REPLIES 8

former_member214131
Active Contributor
0 Kudos

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

0 Kudos

Vanakkam Murugesh,

I need to take the output and write it in a text file.

MY requirement would be a internal table.

so that i can use GUI_DOWNLOAD and write it in a text file.

rgds

Karthik.

0 Kudos

Namaskara,

Have you checked the following weblog:

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

Hope this would help you.

Best Regards, Murugesh AS

andreas_mann3
Active Contributor
0 Kudos

hi ,

complete field-attributes and

use fm LVC_TABLE_CREATE

A.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

-Kiran

*Please reward utile answers

Former Member
0 Kudos

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.

Former Member
0 Kudos

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