cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload issue coming junk data

Former Member
0 Kudos

Hello All

I have followed step by step below example to upload file and read content displayed in the Table.

But it is displaying the Junk data in the table ( I have tried with xlsx and xls files with two columns data (Column A and Column B))

http://saptechnical.com/Tutorials/WebDynproABAP/Upload/Page1.htm

Can any one tell why it's getting junk data. If any other exmaples are there please provide the links.

Note : When i am doing upload with txt file displaying correctly

When i am uploading with xls and xlsx files displaying Junk Data. i want to upload with xls files only

Thanks in Advance.

Sridhar

Accepted Solutions (1)

Accepted Solutions (1)

suman_kumar16
Participant
0 Kudos

Hi 

Former Member
0 Kudos

Hello Suman

Thanks for your reply.You are correct.

If i want to upload xls or xlsx file without changing any Format.

How can i achieve this please guide me.

Best Regards

Sridhar

former_member198064
Participant
0 Kudos

Hi Sir,

I am having urgent issue can you please help me out in this.

I tried the link http://an-sap-consultant.blogspot.in/2012/03/web-dynpro-abap-file-upload-excel.html

I tried the same procedure but i am not getting the data correctly in a table while uploading excel file it shows some other format.

method ONACTIONUPLOAD_FILE .

DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .

lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).

lo_componentcontroller->upload_file( ).

METHOD upload_file .

  DATA:

        lo_nd_file    TYPE REF TO if_wd_context_node,

        lo_nd_emp_det TYPE REF TO if_wd_context_node,

        lt_emp_det    TYPE wd_this->elements_emp_det,

        lo_el_file    TYPE REF TO if_wd_context_element.

  DATA:

        ls_file    TYPE wd_this->element_file,

        ls_emp_det TYPE wd_this->element_emp_det,

        lt_bin     TYPE TABLE OF sdokcntbin,

        lt_txt     TYPE TABLE OF sdokcntasc,

        ls_txt     LIKE LINE OF lt_txt,

        lv_outlen  TYPE i.

   navigate from <context> to <file> via lead selection

lo_nd_file = wd_context->get_child_node( name = wd_this->wdctx_file ). 

*   get element via lead selection

lo_el_file = lo_nd_file->get_element( ). 

*   get all declared attributes

lo_el_file->get_static_attributes( IMPORTING static_attributes = ls_file ).

"XSTRING to BINARY

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING buffer  = ls_file-file_contents

IMPORTING output_length = lv_outlen

TABLES binary_tab    = lt_bin.

"Binary to Text file

CALL FUNCTION 'SCMS_BINARY_TO_TEXT'

EXPORTING input_length = lv_outlen

TABLES binary_tab   = lt_bin

text_tab     = lt_txt.

LOOP AT lt_txt INTO ls_txt.

    SPLIT ls_txt AT cl_abap_char_utilities=>horizontal_tab INTO

                                                                    ls_emp_det-pernr

                                                                    ls_emp_det-nachn

                                                                    ls_emp_det-vorna

                                                                    ls_emp_det-gbdat

APPEND ls_emp_det TO lt_emp_det.

    CLEAR  ls_emp_det.

  ENDLOOP.

lo_nd_emp_det = wd_context->get_child_node( name = wd_this->wdctx_emp_det ).

lo_nd_emp_det->bind_table( new_items = lt_emp_det set_initial_elements = abap_true ).

I tried 2 method in sap technical http://saptechnical.com/Tutorials/WebDynproABAP/Upload/Page1.htm

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.

I tried this solution but i am not getting the data correctly in a table while uploading excel file.

I tried both examples i am getting the same as above.

And how to save the data in database after uploading the data should be saved in a database?.

Can you please help me out in this issue.

Thanks,

Venkatesh

suman_kumar16
Participant
0 Kudos

Hello  Sridhar S

you didn't give me that credit for the correct answer . you given to yourself .please look into it once more.

Answers (0)