Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

WDA for uploading Data from  Excel sheet.:

Component: zwd_tree11.
Views:  SEC


 
Component Controller Structure:

An attribute of type Xstring to hold the source of the Excel.

View Layout:

 
View Methods:
1.    OnActionGO.

Coding in the GO action.

method onactiongo .

    data:
      node_up                             type ref to if_wd_context_node,
      elem_up                             type ref to if_wd_context_element,
      stru_up                             type if_sec=>element_up ,
      item_file                           like stru_up-file.
*   navigate from <CONTEXT> to <UP> via lead selection
    node_up = wd_context->get_child_node( name = if_sec=>wdctx_up ).

*   get element via lead selection
    elem_up = node_up->get_element(  ).

*   get single attribute
    elem_up->get_attribute(
      exporting
        name =  `FILE`
      importing
        value = item_file ).

data s_cont type string.
data convt type ref to cl_abap_conv_in_ce.

convt = cl_abap_conv_in_ce=>create( input = item_file ).

convt->read( importing data = s_cont ).

types: begin of ty_tab,
       num type string,
       name type  string,
       name1 type  string,
       name2 type  string,
       end of ty_tab.

data: fields type string_table.
data: lv_field type string.
data: s_table type string_table.

data: itab type table of ty_tab.
data: str_itab type ty_tab.

*splits string based on new line
split s_cont at cl_abap_char_utilities=>cr_lf into table s_table.

field-symbols: <wa_table> like line of s_table.
loop at s_table assigning <wa_table>.
*  splits string on basis of tabs
split <wa_table> at cl_abap_char_utilities=>horizontal_tab into table fields.
read table fields into lv_field index 1.
str_itab-num = lv_field.
read table fields into lv_field index 2.
str_itab-name = lv_field.
read table fields into lv_field index 3.
str_itab-name1 = lv_field.
read table fields into lv_field index 4.
str_itab-name2 = lv_field.
append str_itab to itab.

endloop.

  data:
    node_content                        type ref to if_wd_context_node,
    elem_content                        type ref to if_wd_context_element,
    stru_content                        type if_sec=>element_content .
* navigate from <CONTEXT> to <CONTENT> via lead selection
  node_content = wd_context->get_child_node( name = if_sec=>wdctx_content ).

* get element via lead selection
  elem_content = node_content->get_element(  ).

call method node_content->bind_table
  exporting
    new_items            = itab
*    SET_INITIAL_ELEMENTS = ABAP_TRUE
*    INDEX                =
    .

endmethod.

This is the coding with which data can be uploaded from a tab delimited Excel file to the WDA screen.

  • No labels

1 Comment

  1. Guest

    This code is working fine for CSV files and text files but which is not possible for excel files.

    character set conversion is not possible at this line convt->read( importing data = s_cont ).

    Regards ,
    Rajpal