on 05-26-2008 3:08 PM
hi,
Can we use Gui_upload method to upload a file from server location and show it .
I am uploading a file using the file upload ui element . Now i want to display the uploaded file from the location where it is saved.
Can some one help how to achieved this??
Regards,
Madhu.
hi madhu...
you cannot use gui_upload.
use file upload ui elelment and on the on action write the following code:
begin of wa, " structure of the node/file
mandt type mandt,
matnr type matnr,
end of wa,
itab like table of wa,
rows type standard table of string , " will hold the entire contents
wa_rows(300) type c .
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_contents LIKE ls_context-contents.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* get single attribute
lo_el_context->get_attribute(
EXPORTING
name = `CONTENTS`
IMPORTING
value = lv_contents ).
DATA : loc_conv TYPE REF TO cl_abap_conv_in_ce,
var_string TYPE string, " holds the string value of the file
inst type ref to CL_SWF_UTL_CONVERT_XSTRING,
inst1 type ref to cl_abap_conv_in_ce.
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
input = lv_contents
encoding = 'UTF-8'
replacement = '?'
ignore_cerr = abap_true
RECEIVING
conv = loc_conv.
CALL METHOD loc_conv->read
IMPORTING
data = var_string.
SPLIT var_string AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE ROWS.
LOOP AT ROWS INTO WA_ROWS .
split wa_rows at ',' into wa-mandt wa-matnr.
append wa to itab.
ENDLOOP.
DATA lo_nd_table TYPE REF TO if_wd_context_node.
DATA lo_el_table TYPE REF TO if_wd_context_element.
DATA ls_table TYPE wd_this->element_table.
* navigate from <CONTEXT> to <TABLE> via lead selection
lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
* get element via lead selection
lo_el_table = lo_nd_table->get_element( ).
lo_nd_table->bind_table( itab ).
use a .csv file
---regards,
alex b justin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
GUI_UPLOAD won't work for WebDynpro application.
Once you upload the file with your UI Element then Data conente will be stored in the File_content attribute which you binded to UI element. Just check the following code which may help you to come our of your problem.
Here i just upload the file, get the logical path name and place the file into that folder. I hope you are also facing the same situation. If not explain little bit more.
DATA lo_nd_import TYPE REF TO if_wd_context_node.
DATA lo_el_import TYPE REF TO if_wd_context_element.
DATA ls_import TYPE wd_this->element_import.
DATA lv_file_content LIKE ls_import-file_content.
DATA lv_filename TYPE string.
DATA lv_mimetype TYPE string.
FIELD-SYMBOLS: <string> TYPE ANY.
lo_nd_import = wd_context->get_child_node( name = wd_this->wdctx_import ).
lo_el_import = lo_nd_import->get_element( ).
lo_el_import->get_attribute( EXPORTING name = `FILE_CONTENT`
IMPORTING value = lv_file_content ).
lo_el_import->get_attribute( EXPORTING name = `FILE_NAME`
IMPORTING value = lv_filename ).
lo_el_import->get_attribute( EXPORTING name = `MIME_TYPE`
IMPORTING value = lv_mimetype ).
Convert Xstring to String
DATA: lt_string TYPE string_table,
lt_string2 TYPE string_table,
lv_lines TYPE i,
lv_string TYPE string.
CALL METHOD cl_rsrd_utilities=>convert_xstring_to_string
EXPORTING
i_xstring = lv_file_content
RECEIVING
r_string = lv_string.
SPLIT lv_string AT cl_abap_char_utilities=>newline
INTO TABLE lt_string.
DATA: lv_flag TYPE c,
lv_format TYPE filename-fileformat,
lv_file TYPE filename-fileextern,
lv_log_file TYPE filename-fileintern VALUE 'PDS_IMPORTFILE'.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
CLIENT = SY-MANDT
logical_filename = lv_log_file
OPERATING_SYSTEM = SY-OPSYS
parameter_1 = sy-sysid
PARAMETER_2 = '.xml'
PARAMETER_3 = ' '
USE_PRESENTATION_SERVER = ' '
WITH_FILE_EXTENSION = 'X'
USE_BUFFER = ' '
ELEMINATE_BLANKS = 'X'
IMPORTING
emergency_flag = lv_flag
file_format = lv_format
file_name = lv_file
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
OPEN DATASET lv_file FOR OUTPUT IN BINARY MODE .
IF sy-subrc EQ 0.
TRANSFER xmlstr TO lv_file.
CLOSE DATASET lv_file.
else.
wd_assist->add_message( EXPORTING msgty = 'E'
msgno = '031' ).
wd_comp_controller->display_messages( ).
ENDIF.
Warm Regards,
Vijay
Edited by: Gangisetty Vijaya Bhaskarudu on May 26, 2008 4:38 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.