cancel
Showing results for 
Search instead for 
Did you mean: 

File upload

Former Member
0 Kudos

Hi,

Is there any way to upload file using below class and method resp.

CL_WD_FILE_UPLOAD

NEW_FILE_UPLOAD

Any idea or code samples???

Thx

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi John,

Are you looking for Dynamic Programming?

Not means you can use below code to upload the file using file upload UI element.

Create one attribute with type XSTRING. then you can convert it to type string. see the below code :

data : loc_conv type ref to cl_abap_conv_in_ce,
            var_string type string.


*        Convert XString to String
call method cl_abap_conv_in_ce=>create
exporting
input = item_filecontent
encoding = 'UTF-8'
replacement = '?'
ignore_cerr = abap_true
receiving
conv = loc_conv.

*Read the file contents

try.
call method loc_conv->read
importing
data = var_string.
catch cx_sy_conversion_codepage.

*Should ignore errors in code conversions
catch cx_sy_codepage_converter_init.



*Should ignore errors in code conversions
catch cx_parameter_invalid_type.
catch cx_parameter_invalid_range.
endtry.

*SPLIT var_string AT crlf INTO TABLE it_string_tab

  data:
    node_file_contents                  type ref to if_wd_context_node,
    elem_file_contents                  type ref to if_wd_context_element,
    stru_file_contents                  type if_fileupload=>element_file_contents ,
    itab like table of  stru_file_contents.

* navigate from <CONTEXT> to <FILE_CONTENTS> via lead selection
  node_file_contents = wd_context->get_child_node( name = if_fileupload=>wdctx_file_contents ).

* get element via lead selection
  elem_file_contents = node_file_contents->get_element(  ).

stru_file_contents-value = var_string.

append stru_file_contents to itab.

*SPLIT var_string AT stru_file_contents-VALUE INTO TABLE itAB.

node_file_contents->bind_table( itab ).

call method cl_wd_runtime_services=>attach_file_to_response
  exporting
    i_filename      =  item_filename
    i_content       = item_filecontent
    i_mime_type     = 'txt'
    i_in_new_window = abap_true.

Thanks.

Former Member
0 Kudos

All,

u have gave me some answers.

The code is useful to read a CSV file.

I'm looking for a way to upload excel file and read the content.

Former Member
0 Kudos

Hi John,

Instead of Directly upload the Excel file, You can save the Excel file as "Tab delimited" format. So that easily you can upload your Excel files into your webdynpro application.

Thanks.

Former Member
0 Kudos

Viji,

I worked on CSV file upload.

But my requirement is to upload excel and text file.

u can share ur ideas to help me out.

Former Member
0 Kudos

Hi,

There is a UI element avaiable in webdynrpo for file upload, you can use this element to upload the file directly and store it in your context.

Check out Thomas Jung's Answer :

Edited by: Shruthi R on May 22, 2008 6:15 AM

Former Member
0 Kudos

Shruti,

I too agree with u. But i would like to upload excel file.

Former Member
0 Kudos

Hi,

Ok I have an idea. Have an input element and an button. Allow the user to select the path in the input element. On Click of button, upload the excel file using the class

CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD.

Shruthi

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi John,

Check this link,

For file upload:

Regards,

Muneesh Gitta.