on 01-14-2008 8:38 AM
Hello to all,
Please help with a procedure to open an existing MS Word file.
This file is available in the presentation server itself.
But the requiremnt is to start MS-Word first and then show the file in the word application.
Do let me know if anyones work on similar things.
Hi Abhishek
the way to display a word file save on your PC is as follows:
? Create a web Dynpro component having view DISP_DOC
? Embed the view in window and create a application of it.
? In layout of view DISP_DOC, create UIElements FileUpload (Name: GetFile), OfficeControl (name: Offc), unable its expert mode property and a button named OPEN and create a OnAction event for it named: OPEN.
? Create a context node FILE_DATA in view DISP_DOC having two attributes: FILE_UPD and FILE_DISP, both of type XSTRING.
? Bind the data property of FileUpload UIElement with context attribute FILE_UPD and Bind the data property of OfficeControl UIElement with context attribute FILE_DISP.
? On attributes tab of view, add two attributes:
? DOCUMENT type ref to IF_IOS_DOCUMENT
? FACTORY type ref to IF_IOS_FACTORY
On the method tab of view:
Add following code in WDDOMODIFYVIEW method:
data:
office type ref to cl_wd_view_element,
mime_repository type ref to if_mr_api,
content type xstring.
data refexp TYPE REF TO cx_ios_exception.
data: msgid TYPE SYST-MSGID,
msgnr TYPE SYST-MSGNO,
msgty TYPE SYST-MSGTY.
get message manager
data: l_current_controller type ref to if_wd_controller,
l_message_manager type ref to if_wd_message_manager.
get the office control
office ?= view->get_element( 'OFFC' ).
ASSERT ID SIOS_DEMO condition office IS BOUND.
get the IOS interface
wd_this->factory ?= office->_method_handler.
ASSERT ID SIOS_DEMO condition wd_this->factory IS BOUND.
try.
catch CX_IOS_DOCUMENT into refexp.
catch CX_IOS_COMMUNICATIONWRAPPER into refexp.
catch CX_IOS_FACTORY into refexp.
catch CX_IOS_ENVIRONMENT into refexp.
catch CX_IOS_EXCEPTION into refexp.
endtry.
if refexp is not initial.
refexp->GET_MESSAGE( IMPORTING
MTYPE = msgty
NUMBER = msgnr
MID = msgid ).
l_current_controller ?= wd_This->Wd_Get_Api( ).
CALL METHOD l_current_controller->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = l_message_manager
.
report message
CALL METHOD l_message_manager->REPORT_T100_MESSAGE
EXPORTING
MSGID = msgid
MSGNO = msgnr
MSGTY = msgty.
endif.
Add the following code in ONACTIONOPEN (OnAction event method, associated with open button):
get message manager
DATA: l_current_controller TYPE REF TO if_wd_controller,
l_message_manager TYPE REF TO if_wd_message_manager.
l_current_controller ?= wd_this->wd_get_api( ).
CALL METHOD l_current_controller->get_message_manager
RECEIVING
message_manager = l_message_manager
.
data: refexp TYPE REF TO cx_ios_exception,
msgid TYPE SYST-MSGID,
msgnr TYPE SYST-MSGNO,
msgty TYPE SYST-MSGTY.
try.
IF wd_this->document IS INITIAL.
wd_this->factory->get_document_proxy( IMPORTING proxy = wd_this->document ).
ASSERT ID sios_demo CONDITION wd_this->document IS BOUND.
ENDIF.
document is set through datasource!
wd_this->document->opendocument( ).
catch CX_IOS_DOCUMENT into refexp.
catch CX_IOS_COMMUNICATIONWRAPPER into refexp.
catch CX_IOS_FACTORY into refexp.
catch CX_IOS_ENVIRONMENT into refexp.
catch CX_IOS_EXCEPTION into refexp.
endtry.
if refexp is not initial.
refexp->GET_MESSAGE( IMPORTING
MTYPE = msgty
NUMBER = msgnr
MID = msgid ).
report message
CALL METHOD l_message_manager->REPORT_T100_MESSAGE
EXPORTING
MSGID = msgid
MSGNO = msgnr
MSGTY = msgty.
endif.
DATA:
node_file_data TYPE REF TO if_wd_context_node,
elem_file_data TYPE REF TO if_wd_context_element,
stru_file_data TYPE if_disp_doc=>element_file_data .
navigate from <CONTEXT> to <FILE_DATA> via lead selection
node_file_data = wd_context->get_child_node( name = if_disp_doc=>wdctx_file_data ).
get element via lead selection
elem_file_data = node_file_data->get_element( ).
get all declared attributes
elem_file_data->get_static_attributes(
IMPORTING
static_attributes = stru_file_data ).
stru_file_data-file_disp = stru_file_data-file_upd.
get all declared attributes
elem_file_data->set_static_attributes(
EXPORTING
static_attributes = stru_file_data ).
On the method tab of view:
Add following code in WDDOMODIFYVIEW method:
data:
office type ref to cl_wd_view_element,
mime_repository type ref to if_mr_api,
content type xstring.
data refexp TYPE REF TO cx_ios_exception.
data: msgid TYPE SYST-MSGID,
msgnr TYPE SYST-MSGNO,
msgty TYPE SYST-MSGTY.
get message manager
data: l_current_controller type ref to if_wd_controller,
l_message_manager type ref to if_wd_message_manager.
get the office control
office ?= view->get_element( 'OFFC' ).
ASSERT ID SIOS_DEMO condition office IS BOUND.
get the IOS interface
wd_this->factory ?= office->_method_handler.
ASSERT ID SIOS_DEMO condition wd_this->factory IS BOUND.
try.
catch CX_IOS_DOCUMENT into refexp.
catch CX_IOS_COMMUNICATIONWRAPPER into refexp.
catch CX_IOS_FACTORY into refexp.
catch CX_IOS_ENVIRONMENT into refexp.
catch CX_IOS_EXCEPTION into refexp.
endtry.
if refexp is not initial.
refexp->GET_MESSAGE( IMPORTING
MTYPE = msgty
NUMBER = msgnr
MID = msgid ).
l_current_controller ?= wd_This->Wd_Get_Api( ).
CALL METHOD l_current_controller->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = l_message_manager
.
report message
CALL METHOD l_message_manager->REPORT_T100_MESSAGE
EXPORTING
MSGID = msgid
MSGNO = msgnr
MSGTY = msgty.
endif.
Add the following code in ONACTIONOPEN (OnAction event method, associated with open button):
get message manager
DATA: l_current_controller TYPE REF TO if_wd_controller,
l_message_manager TYPE REF TO if_wd_message_manager.
l_current_controller ?= wd_this->wd_get_api( ).
CALL METHOD l_current_controller->get_message_manager
RECEIVING
message_manager = l_message_manager
.
data: refexp TYPE REF TO cx_ios_exception,
msgid TYPE SYST-MSGID,
msgnr TYPE SYST-MSGNO,
msgty TYPE SYST-MSGTY.
try.
IF wd_this->document IS INITIAL.
wd_this->factory->get_document_proxy( IMPORTING proxy = wd_this->document ).
ASSERT ID sios_demo CONDITION wd_this->document IS BOUND.
ENDIF.
document is set through datasource!
wd_this->document->opendocument( ).
catch CX_IOS_DOCUMENT into refexp.
catch CX_IOS_COMMUNICATIONWRAPPER into refexp.
catch CX_IOS_FACTORY into refexp.
catch CX_IOS_ENVIRONMENT into refexp.
catch CX_IOS_EXCEPTION into refexp.
endtry.
if refexp is not initial.
refexp->GET_MESSAGE( IMPORTING
MTYPE = msgty
NUMBER = msgnr
MID = msgid ).
report message
CALL METHOD l_message_manager->REPORT_T100_MESSAGE
EXPORTING
MSGID = msgid
MSGNO = msgnr
MSGTY = msgty.
endif.
DATA:
node_file_data TYPE REF TO if_wd_context_node,
elem_file_data TYPE REF TO if_wd_context_element,
stru_file_data TYPE if_disp_doc=>element_file_data .
navigate from <CONTEXT> to <FILE_DATA> via lead selection
node_file_data = wd_context->get_child_node( name = if_disp_doc=>wdctx_file_data ).
get element via lead selection
elem_file_data = node_file_data->get_element( ).
get all declared attributes
elem_file_data->get_static_attributes(
IMPORTING
static_attributes = stru_file_data ).
stru_file_data-file_disp = stru_file_data-file_upd.
get all declared attributes
elem_file_data->set_static_attributes(
EXPORTING
static_attributes = stru_file_data ).
Test your application.
Thanks
Vishal kapoor
Edited by: vishal kapoor on Jan 15, 2008 4:21 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi vishal,
Have done exactly what you mentioned but dont see the MS Word documents in my local PC.
Just to confirm have pasted the code below.
Any settings we need to take care of ?
WDDOMODIFY :
method WDDOMODIFYVIEW .
data:
office type ref to cl_wd_view_element,
mime_repository type ref to if_mr_api,
content type xstring.
data refexp TYPE REF TO cx_ios_exception.
data: msgid TYPE SYST-MSGID,
msgnr TYPE SYST-MSGNO,
msgty TYPE SYST-MSGTY.
"get message manager
data: l_current_controller type ref to if_wd_controller,
l_message_manager type ref to if_wd_message_manager.
"get the office control
office ?= view->get_element( 'OFFICE_CONTROL' ).
ASSERT ID SIOS_DEMO condition office IS BOUND.
"get the IOS interface
wd_this->factory ?= office->_method_handler.
ASSERT ID SIOS_DEMO condition wd_this->factory IS BOUND.
try.
catch CX_IOS_DOCUMENT into refexp.
catch CX_IOS_COMMUNICATIONWRAPPER into refexp.
catch CX_IOS_FACTORY into refexp.
catch CX_IOS_ENVIRONMENT into refexp.
catch CX_IOS_EXCEPTION into refexp.
endtry.
if refexp is not initial.
refexp->GET_MESSAGE( IMPORTING
MTYPE = msgty
NUMBER = msgnr
MID = msgid ).
l_current_controller ?= wd_This->Wd_Get_Api( ).
CALL METHOD l_current_controller->GET_MESSAGE_MANAGER
RECEIVING
MESSAGE_MANAGER = l_message_manager
.
"report message
CALL METHOD l_message_manager->REPORT_T100_MESSAGE
EXPORTING
MSGID = msgid
MSGNO = msgnr
MSGTY = msgty.
endif.
endmethod.
ONACTIONDISPLAY
method ONACTIONDISPLAY .
DATA: l_current_controller TYPE REF TO if_wd_controller,
l_message_manager TYPE REF TO if_wd_message_manager.
l_current_controller ?= wd_this->wd_get_api( ).
CALL METHOD l_current_controller->get_message_manager
RECEIVING
message_manager = l_message_manager
.
data: refexp TYPE REF TO cx_ios_exception,
msgid TYPE SYST-MSGID,
msgnr TYPE SYST-MSGNO,
msgty TYPE SYST-MSGTY.
try.
IF wd_this->document IS INITIAL.
wd_this->factory->get_document_proxy( IMPORTING proxy = wd_this->document ).
ASSERT ID sios_demo CONDITION wd_this->document IS BOUND.
ENDIF.
"document is set through datasource!
wd_this->document->opendocument( ).
catch CX_IOS_DOCUMENT into refexp.
catch CX_IOS_COMMUNICATIONWRAPPER into refexp.
catch CX_IOS_FACTORY into refexp.
catch CX_IOS_ENVIRONMENT into refexp.
catch CX_IOS_EXCEPTION into refexp.
endtry.
if refexp is not initial.
refexp->GET_MESSAGE( IMPORTING
MTYPE = msgty
NUMBER = msgnr
MID = msgid ).
"report message
CALL METHOD l_message_manager->REPORT_T100_MESSAGE
EXPORTING
MSGID = msgid
MSGNO = msgnr
MSGTY = msgty.
endif.
*DATA:
*node_file_data TYPE REF TO if_wd_context_node,
*elem_file_data TYPE REF TO if_wd_context_element,
*stru_file_data TYPE if_disp_doc=>element_file_data .
*
*
*"navigate from <CONTEXT> to <FILE_DATA> via lead selection
*node_file_data = wd_context->get_child_node( name = if_disp_doc=>wdctx_file_data ).
*
*
*"get element via lead selection
*elem_file_data = node_file_data->get_element( ).
*
*
*"get all declared attributes
*elem_file_data->get_static_attributes(
*IMPORTING
*static_attributes = stru_file_data ).
*
*stru_file_data-file_disp = stru_file_data-file_upd.
*
*
*"get all declared attributes
*elem_file_data->set_static_attributes(
*EXPORTING
*static_attributes = stru_file_data ).
DATA lo_nd_file_data TYPE REF TO if_wd_context_node.
DATA lo_el_file_data TYPE REF TO if_wd_context_element.
DATA stru_file_data TYPE wd_this->element_file_data.
navigate from <CONTEXT> to <FILE_DATA> via lead selection
lo_nd_file_data = wd_context->get_child_node( name = wd_this->wdctx_file_data ).
get element via lead selection
lo_el_file_data = lo_nd_file_data->get_element( ).
get all declared attributes
lo_el_file_data->get_static_attributes(
IMPORTING
static_attributes = STRU_file_data ).
stru_file_data-file_disp = stru_file_data-file_upload.
lo_el_file_data->set_static_attributes(
EXPORTING
static_attributes = stru_file_data ).
endmethod.
User | Count |
---|---|
93 | |
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.