‎2009 May 25 2:17 PM
Hi All,
I am having data in one internal table like this..
MANDT
CARRID
CONNID
FLDATE
PRICE
CURRENCY
Now I need to download these into an excel file like ..
| MANDT | CARRID | CONNID | FLDATE | PRICE | CURRENCY |
Please suggest me how I can do this..
Please note that the fields I mentioned in the first internal table will be changing dynamically based on the user input.
The number of fields will be changing and field names will be changing, their data types will be changing..
thanks,
Ravee..
Edited by: ravee on May 25, 2009 6:48 PM
‎2009 May 26 12:56 PM
Hi Ravee,
For creating dynamic internal table, you can refer to following piece of code:
DATA gv_ref TYPE REF TO data.
DATA gv_area TYPE REF TO data.
FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE,
<fs_update> TYPE STANDARD TABLE,
<fs_data> TYPE ANY.
CREATE DATA gv_ref TYPE STANDARD TABLE OF (p_table).
CREATE DATA gv_area LIKE gv_ref.
ASSIGN gv_ref->* TO <fs_table>.
ASSIGN gv_ref->* TO <fs_update>.
ASSIGN gv_area->* TO <fs_data>.
Now, these field-symbols you can use as your internal tables and work areas.
P_TABLE is variable containg any database table name.
Let me know if it helps.
Gouri.
‎2009 May 25 2:22 PM
HI,
Check this way..
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_fullpath
filetype = 'DAT'
* DAT_MODE = 'X'
TABLES
data_tab = <FT_FINAL> ">> Dynamic Internal table for Data
fieldnames = <FT_FIELDNAME> " >> Dynamic Internal table for field headers
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
‎2009 May 25 2:33 PM
Hello Avinash,
I think my way of explaining my requirement is wrong...
I know that we can download the data using gui_download, or the same method gui_downlaod in cl_gui_frontend_services. As I am using excel file I can also use SAP_CONVERT_TO_XLS_FORMAT...
But the problem here is I have to transpose the data I have in the internal table first.That is the part where I need ur suggestion...
To explain you more clearly...
First I need to convert the following format ...
MANDT
CARRID
CONNID
FLDATE
PRICE
CURRENCY
to
| MANDT | CARRID | CONNID | FLDATE | PRICE | CURRENCY |...dedicating single column for each field..with header also
I tried using the method create_dynamic_table in the class cl_alv_table_create which can create dynamic internal table...but it will not give me the component names..but creates a table of those fields..
Thanks,
Ravee
‎2009 May 25 2:38 PM
Hi,
Check this Link..http://docs.google.com/Doc?id=dfv2hmgs_5d6bcxqgp&hl=en
‎2009 May 26 12:56 PM
Hi Ravee,
For creating dynamic internal table, you can refer to following piece of code:
DATA gv_ref TYPE REF TO data.
DATA gv_area TYPE REF TO data.
FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE,
<fs_update> TYPE STANDARD TABLE,
<fs_data> TYPE ANY.
CREATE DATA gv_ref TYPE STANDARD TABLE OF (p_table).
CREATE DATA gv_area LIKE gv_ref.
ASSIGN gv_ref->* TO <fs_table>.
ASSIGN gv_ref->* TO <fs_update>.
ASSIGN gv_area->* TO <fs_data>.
Now, these field-symbols you can use as your internal tables and work areas.
P_TABLE is variable containg any database table name.
Let me know if it helps.
Gouri.