Uploading excel file using WebDynpro for ABAP

...Previous 

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.

 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image