Register Login

Uploading Excel files using WebDynpro

Updated May 18, 2018

SAP ABAP Web Dynpro Excel Table 

Uploading Excel files using WebDynpro for ABAP

Scenario: To upload an excel file using WebDynpro Application.

Procedure:

1. Go to transaction SE80.
2. Select “WebDynpro Comp./Intf” from the list.
3. Create a new WebDynpro component by the name ZEXCEL_UPLOAD.

4. Double-click on the View. Select Context Tab.
5. Create an attribute as shown below.

6. Create a node as shown below:

7. Create attributes for the DATA_TAB node like below.

 

8. Double click on View. We would be designing the screen of our application with the following
elements:
1. File Upload
2. Button
3. Table
Insert Element FILE_UPLOAD for Uploading File.

 

 

9. Insert Element Button.Set its Text property as UPLOAD.

Create a new action for button.

10. Insert an Element TABLE and do binding by right clicking on it and select Create Binding.

By pressing Enter button Binding will be done.
11. Set Column’s header property as below.

Same way set header property for the Age column too.
12. Select element File upload and set its DATA property as shown below:

 

13. Now select View’s method list

Double click on ONACTION_UPLOAD method. Write a code as given below.
METHOD onactionon_upload .
TYPES :
BEGIN OF str_itab,
name(10) TYPE c,
age(10) TYPE c,
END OF str_itab.
DATA : t_table1 TYPE STANDARD TABLE OF str_itab,
i_data TYPE STANDARD TABLE OF string,
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.
DATA : t_table TYPE if_main=>elements_data_tab,
data_table TYPE if_main=>elements_data_tab.
* get single attribute
wd_context->get_attribute(
EXPORTING
name = `DATASOURCE`
IMPORTING
value = l_xstring ).
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = l_xstring
IMPORTING
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.
ENDLOOP.
lo_nd_sflight = wd_context->get_child_node( 'DATA_TAB' ).
lo_nd_sflight->bind_table( t_table1 ).
ENDMETHOD.
14. Activate the Program and create an application by right clicking and save it.

 

15. Test Application.

Output:

Click on Browse.Select An EXCEL file with two Columns.

Click on UPLOAD Button.and Excel data will be displayed like below.


Comments

  • 18 Sep 2012 10:03 am Guest
    does not work
  • 23 Oct 2013 9:35 am Guest
    got credential error.........

×