Skip to Content
0
Former Member
Oct 24, 2013 at 09:17 AM

Issue with File Upload download UI Element

438 Views

Dear Experts,

I am facing an issue with the file upload UI element.

When I try to upload the file, the file name taken is incorrect. It has 'Drive name' :\ 'fakepath' / 'filename' . 'Extension'

example:

When I click on the above tabel link to download or view the attachment it just displays the junk character in a new window. Tried uploading different file types but the same issue.

Below is the code for on action update.

METHOD onactionupload .

DATA lo_nd_n_upload TYPE REF TO if_wd_context_node.

DATA lo_el_n_upload TYPE REF TO if_wd_context_element.

DATA ls_n_upload TYPE wd_this->element_n_upload.

DATA lo_nd_n_file_download TYPE REF TO if_wd_context_node.

DATA lt_n_file_download TYPE wd_this->elements_n_download.

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->element_context.

DATA ls_file_upload TYPE zhrloan_files.

* navigate from <CONTEXT> to <N_FILE_DOWNLOAD> via lead selection

lo_nd_n_file_download = wd_context->get_child_node( name = wd_this->wdctx_n_download ).

* navigate from <CONTEXT> to <N_UPLOAD> via lead selection

lo_nd_n_upload = wd_context->get_child_node( name = wd_this->wdctx_n_upload ).

* get element via lead selection

lo_el_n_upload = lo_nd_n_upload->get_element( ).

* @TODO handle not set lead selection

IF lo_el_n_upload IS NOT INITIAL.

* get all declared attributes

lo_el_n_upload->get_static_attributes(

IMPORTING

static_attributes = ls_n_upload ).

* ls_n_upload will contain the File name file type and file contents *

DATA lo_nd_it_empdata TYPE REF TO if_wd_context_node.

DATA lo_el_it_empdata TYPE REF TO if_wd_context_element.

DATA ls_it_empdata TYPE wd_this->element_it_empdata.

DATA lv_pernr TYPE wd_this->element_it_empdata-pernr.

DATA lv_loan_type TYPE zloan_type.

* navigate from <CONTEXT> to <IT_EMPDATA> via lead selection

lo_nd_it_empdata = wd_context->get_child_node( name = wd_this->wdctx_it_empdata ).

lo_el_it_empdata = lo_nd_it_empdata->get_element( ).

* get single attribute

lo_el_it_empdata->get_attribute(

EXPORTING

name = `PERNR`

IMPORTING

value = lv_pernr ).

lo_el_context = wd_context->get_element( ).

lo_el_context->get_attribute(

EXPORTING

name = `L_TYPE`

IMPORTING

value = lv_l_type ).

ls_n_upload-file_size = xstrlen( ls_n_upload-file_contents ).

ls_file_upload-l_type = lv_l_type.

ls_file_upload-pernr = lv_pernr.

ls_file_upload-file_name = ls_n_upload-file_name.

ls_file_upload-file_type = ls_n_upload-file_type.

ls_file_upload-file_size = ls_n_upload-file_size.

ls_file_upload-file_contents = ls_n_upload-file_contents.

INSERT ztable_files FROM ls_file_upload.

IF sy-subrc = 0.

SELECT file_name

file_type

file_size

file_contents

FROM ztable_files

INTO TABLE lt_n_file_download

WHERE loan_type = lv_l_type AND pernr = lv_pernr.

lo_nd_n_file_download->bind_table( new_items = lt_n_file_download set_initial_elements = abap_true ).

ENDIF.

ENDIF.

ENDMETHOD.

Please somebody guide me with this issue.

Thanks,

Harish

Attachments

image.JPG (22.1 kB)