码迷,mamicode.com
首页 > 移动开发 > 详细

To upload an excel file using WebDynpro Application.

时间:2015-08-04 21:09:21      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

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.

标签:

原文地址:http://blog.csdn.net/champaignwolf/article/details/47281289

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!