To upload an excel file using WebDynpro Application.

來源:互聯網
上載者:User

標籤:

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.

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

To upload an excel file using WebDynpro Application.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.