cancel
Showing results for 
Search instead for 
Did you mean: 

Upload Excel

Former Member
0 Kudos

Dear Experts,

I tried the example given in the saptechnical -> tutorials-> webdynpro abap -> Uploading excel file using WebDynpro for ABAP.

During the execution of the program, i specified the path and when i clicked on the button : it was going on running(processing) continously but did not display the contents of excel in the table yet.

can anyone pls tell me how to correct it.

Kind Regards

Sajid

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Sajid,

Is your issue resolved? If yes then please do the needful & close this thread.

Regards,

Uday

shaik_sajid
Active Contributor
0 Kudos

Dear All,

Its still not working,after specifying the path when i click on button it is processing endlessly.....I have kept a breakpoint in the the button's method,its not even going to the breakpoint....When i comment the code of buttons method and put a break point its going correctly...code of buttons method is....

data :item_file type xstringval,

elem_file TYPE REF TO if_wd_context_element,

convt type ref to cl_abap_conv_in_ce,

s_cont type string,

s_table type string_table,

ls_data type wd_this->element_data_tab,

lt_data type wd_this->elements_data_tab.

field-symbols: <fs> like line of s_table.

elem_file = wd_context->get_element( ).

elem_file->get_attribute( EXPORTING name = `DATASOURCE` IMPORTING value = item_file ).

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

convt->read( importing data = s_cont ).

split s_cont at cl_abap_char_utilities=>cr_lf into table s_table.

loop at s_table assigning <fs>.

split <fs> at cl_abap_char_utilities=>horizontal_tab into : ls_data-name ls_data-age.

append ls_data to lt_data.

clear ls_data.

endloop.

DATA lo_nd_kna1 TYPE REF TO if_wd_context_node.

lo_nd_kna1 = wd_context->get_child_node( name = wd_this->wdctx_data_tab ).

lo_nd_kna1->bind_table( lt_data ).

Regards

Sajid

uday_gubbala2
Active Contributor
0 Kudos

Hi Sajid,

Am not sure as to where you are going wrong coz I copied & pasted the exactly same code into my component & its working perfectly. Am sorry about my earlier thread. Even in the other thread suggested by Anand you cant directly upload an excel document. You would have to convert it into an tab delimited text file & then try upload it using the FileUpload ui element.Both these codes are working perfectly fine for me. Just recheck with the bindings & all as how specified in the source saptechnical website coz I followed the same and its fine.

Regards,

Uday

Coding 1:

method ONACTIONON_UPLOAD .
  data :item_file type xstringval,
  elem_file TYPE REF TO if_wd_context_element,
  convt type ref to cl_abap_conv_in_ce,
  s_cont type string,
  s_table type string_table,
  ls_data type wd_this->element_data_tab,
  lt_data type wd_this->elements_data_tab.
  field-symbols: <fs> like line of s_table.

  elem_file = wd_context->get_element( ).

  elem_file->get_attribute( EXPORTING name = `DATASOURCE` IMPORTING value = item_file ).

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

  convt->read( importing data = s_cont ).

  split s_cont at cl_abap_char_utilities=>cr_lf into table s_table.

  loop at s_table assigning <fs>.

    split <fs> at cl_abap_char_utilities=>horizontal_tab into : ls_data-name ls_data-age.

    append ls_data to lt_data.

    clear ls_data.

  endloop.

  DATA lo_nd_kna1 TYPE REF TO if_wd_context_node.

  lo_nd_kna1 = wd_context->get_child_node( name = wd_this->wdctx_data_tab ).

  lo_nd_kna1->bind_table( lt_data ).
endmethod.

uday_gubbala2
Active Contributor
0 Kudos

Coding 2:

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.

Answers (3)

Answers (3)

uday_gubbala2
Active Contributor
0 Kudos

Hi Sajid,

As how pointed out by Anand you need to make a few changes to that program to be able to uplaod an excel file. Try to upload a simple tab delimited text file using the same code which you had developed. You would be able to see the data picked from the text file & filled on to your table successfully. You can then proceed further to try incorporate the logic for an excel file as how pointed out by Prashant. (in the thread pasted by Anand)

Regards,

Uday

Former Member
0 Kudos

Hi,

go thru this link

thnks

I045333
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

You can see examples in the Webdynpro component :WDR_TEST_EVENTS.

It has file upload options

Cheers,

Gayathri