Skip to Content
Former Member
Feb 26, 2013 at 07:31 AM

Rectifying the garbage value problem, while uploading excel in web Dynpro application -


Gejo john , LnT Infotech , 26 Feb 2012.

Most of the time it is required to upload some excel data into web dynpro application to show it in Table Ui element.

For example a simple example can be :

Upload a excel with two column (Name and age), into the web dynpro application and should be displayed ti user in a tabular format.


The requirement seems to be simple , but while doing it most of the time, ddeveloper gets garbage values in the final as output instead of the data he/she has entered into the excel.

Reason :

Each web dynpro application has its own excel format, which is specific to the respective application only.

Now when you try to upload the excel into the web dynpro application , some time it may happen that both of these format (web dynpro application format and the format of excel which needs to be uploaded) may differ.

In such situation the developer may get garbage values in the final output instead of the actual data.

Some time it may also possible that the developer is getting the proper results , but when the development is moved to next system , it is getting failed .

this is because in format in the first systems matches with the excel format of the application , on the other hand it is not matching in the second case as the system is different so it may be possible that in this system the excel format is different.

Solution :

The easiest and the reliable solution is to first download a blank excel template from the web dynpro application , and then ask the user to fill the downloaded excel and then upload the same format back to the application.

So in this way , we can be sure that the functionality will be working fine , irrespective of the system.

Download Excel template :

Excel template can be download to the system by using the below sample code .

DATA xtext TYPE xstring.

* path to the word file
i_filename = 'WDP.xls'
* String Variable
* i_content = xtext
* File Type
i_mime_type = 'EXCEL' ).

this will download a blank excel on the system , if you want to put some header data in the first line , like (Name and age ), you can make use of the string variable -_content.

Once the excel is downloaded , it has to be uploaded back to the web dynpro application

Upload Excel to application :

BEGIN OF str_itab,
name(10) TYPE c,
age(10) TYPE c,
END OF str_itab.

t_table1 TYPE STANDARD TABLE OF str_itab,
lo_nd_sflight TYPE REF TO if_wd_context_node,
lo_el_sflight TYPE REF TO if_wd_context_element,
l_string TYPE string,
fs_table TYPE str_itab,
l_xstring TYPE xstring,
fields TYPE string_table,
lv_field TYPE string.

*get single attribute
name = `FILE_NAME`
value = l_xstring ).

in_xstring = l_xstring
out_string = l_string.

SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE i_data.

* Bind With table Element.
LOOP AT i_data INTO l_string.
SPLIT l_string AT cl_abap_char_utilities=>horizontal_tab INTO TABLE fields. READ TABLE fields INTO lv_field INDEX 1.
fs_table-name = lv_field. READ TABLE fields INTO lv_field INDEX 2.
fs_table-age = lv_field. APPEND fs_table TO t_table1.

lo_nd_sflight = wd_context->get_child_node( 'EXCEL_DATA' ).
lo_nd_sflight->bind_table( t_table1 ).

Hope the document was useful to you,


Gejo john


upload excel.png (4.7 kB)
Untitled.png (8.6 kB)