进阶:案例三: Upload File using WebDynpro

1、节点创建,其中DATASOURCE存放uploadfile名称

2.layout布局

3、upload事件代码:

 

method ONACTIONUPLOAD .
  DATA: lo_Node type ref to If_Wd_Context_Node,
lo_Elem type ref to If_Wd_Context_Element,
lw_datasour type xstring,
lw_string type string,
lt_data type TABLE OF string,
lt_field type TABLE OF string,
lv_field TYPE string,
ls_context type wd_this->Element_sflight,
lt_context type wd_this->Elements_sflight .
* get the datasource Xstring
wd_context->get_attribute(
EXPORTING name = 'DATASOURCE'
  IMPORTING value = lw_datasour ).
* convert the XString ==> string
* CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
* EXPORTING
* IM_XSTRING = lw_datasour
* IM_ENCODING = 'UNICODE'
* IMPORTING
* EX_STRING = lw_string.
DATA: conv TYPE REF TO CL_ABAP_CONV_IN_CE.
CALL METHOD CL_ABAP_CONV_IN_CE=>CREATE
EXPORTING
  INPUT = lw_datasour
  ENCODING = 'UTF-8'
  REPLACEMENT = '?'
  IGNORE_CERR = ABAP_TRUE
  RECEIVING CONV = conv.
conv->READ( importing data = lw_string ).
* get the data of file
split lw_string at cl_abap_char_utilities=>newline into TABLE lt_data.
* delete the header
DELETE lt_data INDEX 1.
* get all the field name
LOOP AT lt_data into lw_string.
  SPLIT lw_string at cl_abap_char_utilities=>horizontal_tab into table lt_field.
***get all the 3 fields of one line
  READ TABLE lt_field INTO lv_field INDEX 1.
  ls_context-carrid = lv_field.
  READ TABLE lt_field INTO lv_field INDEX 2.
  ls_context-connid = lv_field.
  READ TABLE lt_field INTO lv_field INDEX 3.
  ls_context-text = lv_field.
  append ls_context to lt_context.
  ENDLOOP.
* bind table
lo_node = wd_context->get_child_node( 'SFLIGHT' ).
lo_node->bind_table( lt_context ).
endmethod.

 

转载于:https://www.cnblogs.com/caizjian/p/4365124.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值