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 .
* 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 .
ls_context-carrid = lv_field.
READ TABLE lt_field INTO lv_field INDEX .
ls_context-connid = lv_field.
READ TABLE lt_field INTO lv_field INDEX .
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.