cancel
Showing results for 
Search instead for 
Did you mean: 

Web Dynpro OfficeControl - IF_IOS_DOCUMENT saveDocument does not update the context

Former Member
0 Kudos

So the requirement is the following:

when the user clicks on a custom made button (not the Save button in the toolbar of the office application), the document shold be saved and then the whole pop-up containing the word application should be closed.

Unfortunatelly the save doesn't seem to work, as the context containing the document data (xstring) does not get updated with any changes that the user has made on the document.

The save is done  using the saveDocument method of the IF_IOS_DOCUMENT.

Is there any way to automatically update the context after the button is clicked?

I have been researching this for 3 days now and would really appreciate help with this issue.

Thanks in advance!

Armin

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi, Armin, did you find a solution for this problem?

Former Member
0 Kudos

Hello,

See if below code helps -

I get the document from mime repository. Coding is done in Modify method, I add some text in the document. Press save, on_action save method handler, i called the put method. Nothing special. It works fine.

wd_this->document->if_ios_document~savedocument( errorinformation =  error_savedocument_stru ).

  

method wddomodifyview.
data:
    refexp                             type ref to cx_ios_exception,
    co_error_info_getfields_stru       type wdr_ext_attribute_pointer,
    office                             type ref to cl_wd_view_element,
    mime_repository                    type ref to if_mr_api,
    content                            type xstring,
    url                                type string,
    lr_component                       type ref to if_wd_component,
    lr_component_info                  type ref to if_wd_rr_component,
    ls_comp_name                       type string.

  lr_component ?= wd_comp_controller->wd_get_api( ).
  lr_component_info = lr_component->get_component_info( ).
  ls_comp_name = lr_component_info->get_name( ).

  if first_time = abap_true.

    call method cl_wdr_utilities=>get_mime_path
      exporting
        i_component_name = ls_comp_name
        i_mime_source    = 'WDJ2WDA.doc'
*      i_is_rtl         = ABAP_FALSE
      receiving
        r_mime_path      = url
        .
    wd_this->url = url.
    mime_repository = cl_mime_repository_api=>get_api( ).

    wd_this->MIME_REPOSITORY = mime_repository.

    call method mime_repository->get
      exporting
        i_url     = url
      importing
        e_content = content.

    wd_context->set_attribute( name = 'DATAS' value = content ).


* get the office control
    office ?= view->get_element( 'GENERIC_OFFICE' ).
    wd_this->factory ?= office->_method_handler.

    try.
        wd_this->factory->get_wordprocessing_proxy(
           importing proxy = wd_this->document  ).

* open the document
        wd_this->document->if_ios_document~opendocument( ).
* Run the macro
        wd_this->document->if_ios_applicationproperties~runmacro( exporting name = 'VerdanaType'
                                                              errorinformation = co_error_info_getfields_stru ).


      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.

  endif.
endmethod.


method ONACTIONONEVENTSAVE .

     DATA lo_el_context TYPE REF TO if_wd_context_element.
     DATA ls_context TYPE wd_this->element_context.
     DATA lv_datas TYPE wd_this->element_context-datas.

*    get element via lead selection
     lo_el_context = wd_context->get_element( ).
*    @TODO handle not set lead selection
     IF lo_el_context IS INITIAL.
     ENDIF.

*    get single attribute
     lo_el_context->get_attribute(
       EXPORTING
         name =  `DATAS`
       IMPORTING
         value = lv_datas ).

    wd_this->mime_repository->put(
      exporting
        i_url     = wd_this->url
        i_content = lv_datas ).

endmethod.

best regards,

swanand

Former Member
0 Kudos

Hi Swanand,

first of all thank you for the reply.

Your answer however does not solve my problem. You have put in the reading of the context in the "ONACTIONONEVENTSAVE" which I presume is an event that is triggered when the user clicks on the Save button in the toolbar of the office application (the little discett).

When the "little discett" is clicked the context is automatically updated with any changes that have occured in the document. What I need to do tho is get the "updated" context (meaning the document containing the changes that the user has made) in an event that was triggered by user clicking on an custom made button e.g. "ONCLICKSAVE".

Do you have any idea how to do this?

/A 

Former Member
0 Kudos

is there a macro that one could run to initiate the document save?

In the SAP documentation for the Office Control they say that document save can also be done using the method

WDOfficeControlMethods.saveDocument(IWDController refToTheController,  String strControlId .

Is there some macro that could be called to trigger the calling of this method?

/A