Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Triggerring Standard Interface Event

Former Member
0 Likes
849

Hi Gurus,

We are using the interface I_OI_DOCUMENT_PROXY.Our exact requirement is to capture a MS Word Document data into a internal table whenever the MS Word document is changed and closed.

We felt that the event ON_CLOSE_DOCUMENT in the interface I_OI_DOCUMENT_PROXY could be used (please correct us if this is wrong)..We have registered the event for that method (which needs to get triggered on MS-Word Document close) via

SET HANDLER (Actually this a module pool program wherein this SET HANDLER is used in PBO)..and via method we tried to RAISE that EVENT ON_CLOSE_DOCUMENT.

Here, everything is working fine except the event ON_CLOSE_DOCUMENT is not getting triggered and hence we are not getting the desired result...

Waiting for your replies...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
715

Hi Jagannathan,

Have you created a control for OLE using the interface I_OI_OLE_CONTAINER_CONTROL if yes, please confirm on initializing this control using method INIT_CONTROL if you have set the parameter REGISTER_ON_CLOSE_EVENT.

Regards,

Chen

4 REPLIES 4
Read only

Former Member
0 Likes
716

Hi Jagannathan,

Have you created a control for OLE using the interface I_OI_OLE_CONTAINER_CONTROL if yes, please confirm on initializing this control using method INIT_CONTROL if you have set the parameter REGISTER_ON_CLOSE_EVENT.

Regards,

Chen

Read only

0 Likes
715

Hi Chen,

We have tried using INIT_CONTROL.....But still we could not get the desired result .........

Please guide us in which part we are going wrong....

Our screen contains a custom Container called 'CONTAINER'.

CLASS C_EVENT_HANDLER DEFINITION.

PUBLIC SECTION.

INTERFACES I_OI_DOCUMENT_PROXY.

CLASS-METHODS: CLOSE_EVENT_HANDLER

FOR EVENT ON_CLOSE_DOCUMENT OF I_OI_DOCUMENT_PROXY

IMPORTING DOCUMENT_PROXY HAS_CHANGED.

  • METHODS: HANDLE.

ENDCLASS. "c_event_handler DEFINITION

CLASS C_EVENT_HANDLER IMPLEMENTATION.

METHOD CLOSE_EVENT_HANDLER.

DATA: ANSWER.

  • MESSAGE 'Success' TYPE 'S'.

IF HAS_CHANGED EQ 1.

PERFORM SAVE_DOCUMENT TABLES DATA_TABLE

USING 'X' 'X'

CHANGING DATA_SIZE DOCUMENT_PROXY RETCODE.

ENDIF.

ENDMETHOD. "close_event_handler

  • METHOD HANDLE.

*

  • RAISE EVENT I_OI_DOCUMENT_PROXY~ON_CLOSE_DOCUMENT

  • EXPORTING DOCUMENT_PROXY = DOCUMENT

  • HAS_CHANGED = HAS_CHANGED.

*

  • ENDMETHOD. "CLOSE_EVENT_HANDLER

ENDCLASS. "c_event_handler IMPLEMENTATION

And in PBO, We have used

CALL FUNCTION 'CONTROL_INIT'

EXCEPTIONS

CONTROL_INIT_ERROR = 1

OTHERS = 2.

CALL METHOD C_OI_OLE_CONTROL_CREATOR=>GET_OLE_CONTAINER_CONTROL

IMPORTING

CONTROL = CONTROL

RETCODE = RETCODE.

CALL METHOD C_OI_ERRORS=>SHOW_MESSAGE

EXPORTING

TYPE = 'E'.

CALL METHOD CONTROL->INIT_CONTROL

EXPORTING

R3_APPLICATION_NAME = 'R/3 Basis'

REGISTER_ON_CLOSE_EVENT = 'X'

  • REGISTER_ON_CUSTOM_EVENT = ' '

PARENT = CONT

IMPORTING

RETCODE = RETCODE

EXCEPTIONS

JAVABEANNOTSUPPORTED = 1

OTHERS = 2.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

And in PAI, we tried creating a MS Document on which we are going to type the data and capture that.

SET HANDLER C_EVENT_HANDLER=>CLOSE_EVENT_HANDLER FOR DOCUMENT.

CALL METHOD DOCUMENT->CREATE_DOCUMENT

IMPORTING

RETCODE = RETCODE.

CALL METHOD C_OI_ERRORS=>SHOW_MESSAGE

EXPORTING

TYPE = 'E'.

Waiting for your replies...

Read only

0 Likes
715

Hi Jagannath,

Could you please post the complete code, as i do not see the ref for variable CONT etc in the code you have pasted above,

also below is a demo program which shows how to enable the on_save event, see if the below code gives you any direction...else please paste the complete code.



TYPE-POOLS: sbdst.

INCLUDE officeintegrationinclude.

TYPES: BEGIN OF doc_attr,
          doc_name(40), document_id(64),
       END OF doc_attr.

TYPES: doc_tab TYPE TABLE OF doc_attr.

DATA: fcode LIKE sy-ucomm.

START-OF-SELECTION.
  SET SCREEN 9000.

  DATA: lcl_control     TYPE REF TO i_oi_ole_container_control.
  DATA: lcl_container   TYPE REF TO cl_gui_custom_container.

  DATA: l_rc          TYPE t_oi_ret_string,
        l_doc_type    TYPE soi_document_type
                      VALUE soi_doctype_word_document,
        l_doc_frmt    TYPE soi_document_type.


*---------------------------------------------------------------------*
*       CLASS c_msword_doc DEFINITION
*---------------------------------------------------------------------*
CLASS c_msword_doc DEFINITION.

  PUBLIC SECTION.
    DATA: lcl_proxy        TYPE REF TO i_oi_document_proxy.
    DATA: l_att_doc_type   TYPE soi_document_type.
    DATA: l_att_data_table TYPE sbdst_content,
          l_att_data_size  TYPE i.

    METHODS: constructor
              IMPORTING control TYPE REF TO i_oi_ole_container_control
                        document_type TYPE soi_document_type.

    METHODS: create_document
                  IMPORTING open_inplace  TYPE c DEFAULT ' '
                  EXPORTING retcode TYPE t_oi_ret_string.

    METHODS: close_document
                  IMPORTING do_save     TYPE c DEFAULT ' '
                  RETURNING value(retcode) TYPE t_oi_ret_string.
* For on close Event
    METHODS: on_close_document
              FOR EVENT on_close_document OF i_oi_document_proxy
              IMPORTING document_proxy has_changed.

  PRIVATE SECTION.
    DATA: l_att_control  TYPE REF TO i_oi_ole_container_control.
ENDCLASS.                    "c_msword_doc DEFINITION

DATA: l_fcode          TYPE fcode.
DATA: l_doc            TYPE REF TO c_msword_doc.

*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  PBO
*&---------------------------------------------------------------------*
MODULE status_9000 OUTPUT.

  SET PF-STATUS 'PFSTAT'. " Set the PFSTAT for the create button

  l_rc = c_oi_errors=>ret_ok.

  IF lcl_control IS INITIAL.

* Get an instance of the controller
    CALL METHOD c_oi_ole_control_creator=>get_ole_container_control
      IMPORTING
        control = lcl_control
        retcode = l_rc.
    CALL METHOD c_oi_errors=>show_message
      EXPORTING
        type = 'E'.

* Get an instance of the container
    CREATE OBJECT lcl_container
      EXPORTING
        container_name = 'CONTAINER'.

* Initialize the container using the controller
    CALL METHOD lcl_control->init_control
      EXPORTING
        r3_application_name      = 'Demo'                   "#EC NOTEXT
        inplace_enabled          = 'X'
        inplace_scroll_documents = 'X'
        parent                   = lcl_container
        register_on_close_event  = 'X'
      IMPORTING
        retcode                  = l_rc.
    CALL METHOD c_oi_errors=>show_message
      EXPORTING
        type = 'E'.

* Create the document
    CREATE OBJECT l_doc
      EXPORTING
        control       = lcl_control
        document_type = l_doc_type.

  ENDIF.

ENDMODULE.                             " STATUS_9000  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_9000 PAI
*&---------------------------------------------------------------------*
MODULE user_command_9000 INPUT.

  l_fcode = fcode.
  CLEAR fcode.

  CALL METHOD cl_gui_cfw=>dispatch.

  IF l_fcode EQ 'CREATE'.
    IF NOT lcl_control IS INITIAL.
      l_doc->l_att_data_size = 0.
      CLEAR l_doc->l_att_data_table.
      CALL METHOD l_doc->create_document.
      CALL METHOD c_oi_errors=>show_message
        EXPORTING
          type = 'E'.
    ENDIF.
  ENDIF.

  IF l_fcode EQ 'EXIT'.                       "Zurück
    IF NOT l_doc IS INITIAL.
      CALL METHOD l_doc->close_document.
      FREE l_doc.
    ENDIF.

    IF NOT lcl_control IS INITIAL.
      CALL METHOD lcl_control->destroy_control
        IMPORTING
          retcode = l_rc.
      FREE lcl_control.
    ENDIF.

    LEAVE TO SCREEN 0.
  ENDIF.
ENDMODULE.                             " USER_COMMAND_9000  INPUT

************************************************************************
*  CLASS c_msword_doc IMPLEMENTATION.
************************************************************************
CLASS c_msword_doc IMPLEMENTATION.
  METHOD: constructor.
    me->l_att_control = control.
    me->l_att_doc_type = document_type.
  ENDMETHOD.                    "constructor

  METHOD create_document.
    IF NOT lcl_proxy IS INITIAL.
      CALL METHOD me->close_document.
    ENDIF.
    CALL METHOD lcl_control->get_document_proxy
      EXPORTING
        document_type  = l_att_doc_type
      IMPORTING
        document_proxy = lcl_proxy
        retcode        = retcode.
    IF retcode NE c_oi_errors=>ret_ok.
      EXIT.
    ENDIF.

    CALL METHOD lcl_proxy->create_document
      EXPORTING
        create_view_data = 'X'
        open_inplace     = open_inplace
      IMPORTING
        retcode          = retcode.
    IF retcode NE c_oi_errors=>ret_ok.
      EXIT.
    ENDIF.

    SET HANDLER me->on_close_document FOR lcl_proxy.
  ENDMETHOD.                    "create_document

  METHOD close_document.

    DATA: is_closed TYPE i, has_changed TYPE i.
    DATA: doc_url(256).

    IF NOT lcl_proxy IS INITIAL.
      CALL METHOD lcl_proxy->is_destroyed
        IMPORTING
          ret_value = is_closed.

      IF is_closed IS INITIAL.
        CALL METHOD lcl_proxy->close_document
          EXPORTING
            do_save     = do_save
          IMPORTING
            has_changed = has_changed
            retcode     = retcode.
        IF retcode NE c_oi_errors=>ret_ok.
          EXIT.
        ENDIF.
      ENDIF.

      IF NOT has_changed IS INITIAL.
        CALL METHOD lcl_proxy->save_document_to_table
          IMPORTING
            retcode        = retcode
          CHANGING
            document_table = l_att_data_table
            document_size  = l_att_data_size.
        IF retcode NE c_oi_errors=>ret_ok.
          EXIT.
        ENDIF.
      ENDIF.

      CALL METHOD lcl_proxy->release_document
        IMPORTING
          retcode = retcode.

      SET HANDLER me->on_close_document FOR lcl_proxy ACTIVATION ' '.
    ELSE.
      retcode = c_oi_errors=>ret_document_not_open.
    ENDIF.
  ENDMETHOD.                    "close_document

  METHOD on_close_document.

    DATA: l_resp, l_save.

    IF has_changed EQ 1.
      CALL FUNCTION 'POPUP_TO_CONFIRM'
        EXPORTING
          titlebar              = 'MSWORD On Save Event Demo'
          text_question         = 'Do you wanna Save?'
          display_cancel_button = ' '
        IMPORTING
          answer                = l_resp.
      IF l_resp EQ '1'.
        l_save = 'X'.
      ELSE.
        l_save = ' '.
      ENDIF.
      CALL METHOD me->close_document
        EXPORTING
          do_save = l_save.
      CALL METHOD c_oi_errors=>show_message
        EXPORTING
          type = 'E'.
    ENDIF.
  ENDMETHOD.                    "on_close_document
ENDCLASS.                    "c_msword_doc IMPLEMENTATION

Regards,

Chen

Edited by: Chen K V on May 13, 2011 3:33 PM

Edited by: Chen K V on May 13, 2011 3:34 PM

Edited by: Chen K V on May 13, 2011 3:36 PM

Edited by: Chen K V on May 13, 2011 3:36 PM

Read only

0 Likes
715

Hi Chen,

We made changes in the same program....

We tried pasting the full code but it was not legible to read, thats why we pasted some part of the code....

Hey can you give us the mail id so that we can send the code...Atleast the code will be legible to go through....

Regards,

Jagan