2013 Aug 25 8:00 AM
Hi,
I've been tring to display a word document inside a custom controller.
I've tried : cl_gui_html_viewer
CHANGING po_html_viewer TYPE REF TO cl_gui_html_viewer.
po_html_viewer->show_url(
EXPORTING
url = lv_url " URL
in_place = abap_true
EXCEPTIONS
cntl_error = 1
cnht_error_not_allowed = 2
cnht_error_parameter = 3
dp_error_general = 4
OTHERS = 5
).
and document viwer :
FORM build_doc_viewer USING po_splitter TYPE REF TO cl_gui_splitter_container
CHANGING po_doc_viewer TYPE REF TO i_oi_document_viewer.
DATA : lo_tmp_container TYPE REF TO cl_gui_container.
lo_tmp_container = po_splitter->get_container( row = 1 column = 1 ).
CALL METHOD c_oi_container_control_creator=>get_document_viewer
IMPORTING
viewer = po_doc_viewer.
CALL METHOD po_doc_viewer->init_viewer
EXPORTING
parent = lo_tmp_container.
CALL METHOD po_doc_viewer->view_document_from_url
EXPORTING
document_url = 'C:\USERS\ZIV\DOCUMENTS\SAP\TEST.DOCX'
show_inplace = 'X'.
ENDFORM. " BUILD_DOC_VIEWER
In both cases the document is displayed in a popup of a word application and not "in place" (inside a controller) as I wanted.
What am I doing worng ? Is there another solution ?
Thanks
Ziv.
2013 Aug 27 1:17 PM
I've tried another way but still the file wont open
could it be that the file path format is not correct ?
Please have a look at me code :
DATA : lo_doc_proxy TYPE REF TO i_oi_document_proxy,
lo_error TYPE REF TO i_oi_error,
ls_retcode TYPE soi_ret_string.
DATA : lv_error_msg TYPE string.
CREATE OBJECT custom_container
EXPORTING
* parent = parent " Parent container
container_name = 'CONTAINER_NAME' " Name of the Screen CustCtrl Name to Link Container To
* style = style " Windows Style Attributes Applied to this Container
* lifetime = LIFETIME_DEFAULT " Lifetime
* repid = repid " Screen to Which this Container is Linked
* dynnr = dynnr " Report To Which this Container is Linked
* no_autodef_progid_dynnr = no_autodef_progid_dynnr " Don't Autodefined Progid and Dynnr?
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
.
c_oi_container_control_creator=>get_container_control( IMPORTING control = ole retcode = ls_retcode ).
c_oi_errors=>raise_message( 'E' ).
ole->init_control(
EXPORTING r3_application_name = 'Doc'
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = custom_container
register_on_close_event = 'X'
register_on_custom_event = 'X'
IMPORTING retcode = ls_retcode
).
c_oi_errors=>raise_message( 'E' ).
ole->get_document_proxy(
EXPORTING document_type = 'Word.Document.12'
document_format = 'OLE'
IMPORTING document_proxy = lo_doc_proxy
retcode = ls_retcode
).
IF ls_retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
lo_doc_proxy->open_document(
EXPORTING document_url = 'file:///C:/Users/ziv_catz/Documents/SAP/test.docx'
open_inplace = 'X'
open_readonly = 'X'
IMPORTING retcode = ls_retcode
).
IF ls_retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
2013 Aug 26 1:19 AM
Hi,
Check the below wiki. Might be helpful in your case.
http://wiki.sdn.sap.com/wiki/display/Snippets/Use+BDS+to+Store+Files+Like+Excel+JPG+through+ABAP
Cheers,
Arindam
2013 Aug 26 5:34 AM
Hi ,
Check out the SAP standard Program
"SAPRDEMODOCUMENTCONTAINER2".
This program will give the output you desired.
Regards,
Sivaganesh
2013 Aug 27 1:10 PM
Thank's that was very helpful.
Howevery this program doesn't display a document stored on my coputer,
And that's exctly my problem. I can't get a local doument to show "in place".
Ziv.
2013 Aug 27 1:17 PM
I've tried another way but still the file wont open
could it be that the file path format is not correct ?
Please have a look at me code :
DATA : lo_doc_proxy TYPE REF TO i_oi_document_proxy,
lo_error TYPE REF TO i_oi_error,
ls_retcode TYPE soi_ret_string.
DATA : lv_error_msg TYPE string.
CREATE OBJECT custom_container
EXPORTING
* parent = parent " Parent container
container_name = 'CONTAINER_NAME' " Name of the Screen CustCtrl Name to Link Container To
* style = style " Windows Style Attributes Applied to this Container
* lifetime = LIFETIME_DEFAULT " Lifetime
* repid = repid " Screen to Which this Container is Linked
* dynnr = dynnr " Report To Which this Container is Linked
* no_autodef_progid_dynnr = no_autodef_progid_dynnr " Don't Autodefined Progid and Dynnr?
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
.
c_oi_container_control_creator=>get_container_control( IMPORTING control = ole retcode = ls_retcode ).
c_oi_errors=>raise_message( 'E' ).
ole->init_control(
EXPORTING r3_application_name = 'Doc'
inplace_enabled = 'X'
inplace_scroll_documents = 'X'
parent = custom_container
register_on_close_event = 'X'
register_on_custom_event = 'X'
IMPORTING retcode = ls_retcode
).
c_oi_errors=>raise_message( 'E' ).
ole->get_document_proxy(
EXPORTING document_type = 'Word.Document.12'
document_format = 'OLE'
IMPORTING document_proxy = lo_doc_proxy
retcode = ls_retcode
).
IF ls_retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
lo_doc_proxy->open_document(
EXPORTING document_url = 'file:///C:/Users/ziv_catz/Documents/SAP/test.docx'
open_inplace = 'X'
open_readonly = 'X'
IMPORTING retcode = ls_retcode
).
IF ls_retcode NE c_oi_errors=>ret_ok.
EXIT.
ENDIF.
2013 Aug 28 8:42 AM
The problem was with the document_url.
Here is the correct form : file://C:\Users\ziv\Documents\SAP\test_doc.doc
Here are some of my failed attempts : file:///C:\Users\ziv\Documents\SAP\test_doc.doc
file:///C😕Users/ziv/Documents/SAP/test_doc.doc
2014 Jul 29 8:15 PM
By standard, when an extension is not maintained in SDOKMIME (standard extensions) nor in SDOKMIME_C, it uses MIME Type application/octet-stream, which opens the document as an attachment.
To solve this, you should fill view SDOKMIME_C according to the XLS attachment in this note:
1237688 - New Mime Types for Microsoft Office 2007 in KPro and ARL
IMPORTANT! This will only change the behavior for new documents. Existing documents already have a MIME Type attached in table SA01PHF. You can change the behavior for specific documents manually by selecting the PHIO_IDs from the document header from table SA01PHIO and use them as input field for table SA01PHF.
Alternatively, you can repair all documents by running report SOLMAN_UPDATE_PHIO_MIMETYPE. In case this report is not in your system yet, you can download it from this note:
1750162 - PHIOs are not found by Full Text Search Engine(TREX)
Good luck!
Will