cancel
Showing results for 
Search instead for 
Did you mean: 

File download WD4A

Former Member
0 Kudos

I would like to download an internal table from WD4A to Excel.

I am aware of the method cl_wd_runtime_services=>attach_file_to_response but I am only able to download one line of my internal table.

I have no idea how to attach the whole internal table to the method.

Is there anybody out there who could provide me the source of give me assistance in any other way?

Greetings,

Henry

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Found the solution to my problem. Would like to thank everyone who offered help.

CONSTANTS:

crlf TYPE string VALUE cl_abap_char_utilities=>cr_lf,

tab TYPE string VALUE cl_abap_char_utilities=>horizontal_tab.

DATA:

conv_out TYPE REF TO cl_abap_conv_out_ce,

content TYPE xstring.

conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).

DATA : lv_xstring TYPE xstring.

DATA : lv_text TYPE string.

CONCATENATE 'Artikel' tab

'Aantal' tab

'Omschrijving' tab

crlf

INTO lv_text.

LOOP AT lt_parts INTO ls_parts.

CONCATENATE lv_text

ls_parts-matnr tab

ls_parts-kwmeng tab

ls_parts-maktx tab

crlf

INTO lv_text.

ENDLOOP.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = lv_text

IMPORTING

buffer = lv_xstring

EXCEPTIONS

failed = 1

OTHERS = 2.

DATA: lv_filename TYPE string.

CONCATENATE 'Beheren_'

'partslocator_'

sy-datum

'_'

sy-uzeit

'.xls'

INTO lv_filename.

cl_wd_runtime_services=>attach_file_to_response(

i_filename = lv_filename

i_content = lv_xstring

i_mime_type = 'application/msexcel'

i_in_new_window = abap_true

i_inplace = abap_false ).

Former Member
0 Kudos

Hi Sachi,

As far as I can tell ALL data is filled in one column/cell.

I would like to download an ALV to Excel so every cell contains its appropriate value.

No luck so far....

Henry

thomas_szcs
Active Contributor
0 Kudos

Hi Henry,

You need to convert the internal table to excel format first and put the result into an xstring. You could use the ability of excel to work with text files or its possibility to define a file in xml format.

Best regards,

Thomas

Former Member
0 Kudos

Hi Thomas.

Have you got the source to do this magic? Have tried it in every possible way (known to me) but still no luck):-.

Henry

thomas_szcs
Active Contributor
0 Kudos

Hi Henry,

By searching in google using the term "excel xml format specification", the third link in the list leads to the spec. Please find it below:

<a href="http://msdn2.microsoft.com/en-us/ms406049.aspx">http://msdn2.microsoft.com/en-us/ms406049.aspx</a>

Best regards,

Thomas

Former Member
0 Kudos

Hi Henry,

Please find below the code snippet that might help you.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

FILENAME = 'C:\From_WD.CSV'

FILETYPE = 'ASC'

MODE = 'A'

TABLES

data_tab = lt_personal

.

The only issue is that this FM accepts data ina particular format. So if your internal table Lt_Data is something like:

Name Age Sex

Anoop 24 Male

Avi 24 Male

then you will need to create an internal table Lt_personal which will have data in this format:

Name,Age,Sex

Anoop,24,Male

Avi,24,Male

You will get the data in the format of Lt_Data.

Hope this helps.

Regards,

Anoop

former_member758419
Active Participant
0 Kudos

Hi Henry,

U can probably use the way specified in the FileDownload view of the WDR_TEST_EVENTS example component. There u need to create a string attribute under under a node and provide a supply function to that node, in which u convert ur internal table to string format, then string into xstring format by using the convert() method and bind the resulting xstring to the context attribute, which in turn is bounded to the DATA property of the filedownload UI element.

By this way u can download the entire internal table values..

Regards,

Sachi