on 02-13-2009 6:44 AM
Hi, experts,
There is WD-application with FileUpload element that is not working so that the rar file isn't uploaded into MIME Repository.
Action:
1. Create content attribute that type is xstring in the view context.
2. Create MIMETYPE, FILENAME attribute that type is string in the view context.
3. Bind the content attribute to the data property of the fileupload element in the layout.
4. Bind the filename to the filename property of the fileupload element in the layout.
5. Bind the mimetype to the mime type property of the fileupload element in the layout.
The following is code for the upload button in the view:
method ONACTIONFILEUPLOAD .
data: content type xstring.
DATA lo_nd_mimes TYPE REF TO if_wd_context_node.
DATA lo_el_mimes TYPE REF TO if_wd_context_element.
DATA ls_mimes TYPE wd_this->element_mimes.
DATA lv_mimetype LIKE ls_mimes-mimetype.
get the context
wd_context->get_attribute( exporting name = 'FILECONTENT' importing value = content ).
lo_nd_mimes = wd_context->get_child_node( name = wd_this->wdctx_mimes ).
lo_el_mimes = lo_nd_mimes->get_element( ).
set single attribute
lo_el_mimes->set_attribute(
EXPORTING
name = `MIMETYPE`
value = 'APPLICATION/octet-stream;charset=utf-16le' ).
lo_el_mimes->set_attribute(
EXPORTING
name = `FILENAME`
value = 'test.rar' ).
put the rar file to the repository .
data:
mime_repository type ref to if_mr_api,
mime_type type string,
url type string value '/sap/bc/webdynpro/sap/zz_00_test_019' ,
mime_repository = cl_mime_repository_api=>IF_MR_API~GET_API( ).
mime_repository->put(
EXPORTING
i_url = url
i_content = content
i_suppress_package_dialog = 'X'
EXCEPTIONS
parameter_missing = 1
error_occured = 2
cancelled = 3
permission_failure = 4
data_inconsistency = 5
new_loio_already_exists = 6
is_folder = 7
OTHERS = 8 ).
break-point.
endmethod.
So the questions are:
I don't find the rar file in the mime repository after I run the Webdynpro for ABAP application.
I am sure that the field where is put the rar file is right.
Do you give me some hint?
Thanks!
Best regards,
tao
Edited by: wang tao on Feb 13, 2009 8:12 AM
Hi Wang,
Regarding your file uploading problem, please check this code.
On a button action call this code to upload the file.
Please take care of the URL you going to pass.
The URL should be like this. i.e. You have to specific the dummy file name in the url as here in this example I am passing the Code.txt.
url TYPE string VALUE '/SAP/BC/WebDynpro/SAP/WDR_TEST_ADOBE_PDF_ONLY/CODE.TXT' .
METHOD onactiononclick .
DATA lo_nd_node TYPE REF TO if_wd_context_node.
DATA lo_el_node TYPE REF TO if_wd_context_element.
DATA ls_node TYPE wd_this->element_node.
navigate from <CONTEXT> to <NODE> via lead selection
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
get element via lead selection
lo_el_node = lo_nd_node->get_element( ).
get all declared attributes
lo_el_node->get_static_attributes(
IMPORTING
static_attributes = ls_node ).
lo_el_node->set_static_attributes(
EXPORTING
static_attributes = ls_node ).
DATA:
mime_repository TYPE REF TO if_mr_api,
mime_type TYPE string,
url TYPE string VALUE '/SAP/BC/WebDynpro/SAP/WDR_TEST_ADOBE_PDF_ONLY/CODE.TXT' .
mime_repository = cl_mime_repository_api=>if_mr_api~get_api( ).
CALL METHOD mime_repository->put
EXPORTING
i_url = url
i_content = ls_node-data
i_language = sy-langu
EXCEPTIONS
parameter_missing = 1
error_occured = 2
cancelled = 3
permission_failure = 4
data_inconsistency = 5
new_loio_already_exists = 6
is_folder = 7
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMETHOD. "onactiononclick
This will help you in solving your problem.
Regards
Manoj Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.