07-04-2006 9:09 AM
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.
07-04-2006 9: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
07-04-2006 9: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
07-04-2006 9:18 AM
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.
07-04-2006 9:52 AM
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
07-04-2006 9:17 AM
07-04-2006 9: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
07-04-2006 9:27 AM
Refer the function module CLRS_GENERATE_OUTTAB to understand creating internal tables dynamically.
-Kiran
*Please reward utile answers
07-04-2006 10: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.
12-03-2007 9: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