on 05-20-2008 10:03 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.