SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Refresh dynpro at selection screen



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri Feb 13, 2009 1:25 pm    Post subject: Refresh dynpro at selection screen Reply with quote

Code:
REPORT z_refresh_test.
*---------------------------------------------------------------------*
*       CLASS lcl_gui_timer DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_gui_timer DEFINITION INHERITING FROM cl_gui_control.

  PUBLIC SECTION.
    CONSTANTS:  eventid_finished TYPE i VALUE 1 .
    CLASS-DATA: interval TYPE i VALUE '0'.
    EVENTS:     finished .
    METHODS:     cancel EXCEPTIONS  error,
                 constructor IMPORTING
                     lifetime TYPE i OPTIONAL
                     value(shellstyle) TYPE i OPTIONAL
                     value(parent) TYPE REF TO cl_gui_container OPTIONAL
                 EXCEPTIONS
                     error,
                 run
                 EXCEPTIONS
                     error,
             dispatch REDEFINITION.

ENDCLASS.
*---------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS: on_finished  FOR EVENT finished OF lcl_gui_timer.
ENDCLASS.

DATA: gui_timer TYPE REF TO lcl_gui_timer.
DATA: event_handler TYPE REF TO lcl_event_handler.
DATA: timeout_interval TYPE i VALUE '3'.

PARAMETERS: p_datum TYPE sy-datum,
            p_uzeit TYPE sy-uzeit.

AT SELECTION-SCREEN OUTPUT.

  p_datum = sy-datum.
  p_uzeit = sy-uzeit.

  CREATE OBJECT gui_timer.
  SET HANDLER event_handler->on_finished FOR gui_timer.
  gui_timer->interval = timeout_interval.
  CALL METHOD gui_timer->run.

*---------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
  METHOD on_finished.
* Start Timer again
    gui_timer->interval = timeout_interval.
    CALL METHOD gui_timer->run.
* cause PAI
    CALL METHOD cl_gui_cfw=>set_new_ok_code
             EXPORTING
                 new_code = 'REFR'.

  ENDMETHOD.
ENDCLASS.
*---------------------------------------------------------------------*
*       CLASS lcl_gui_timer IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS lcl_gui_timer IMPLEMENTATION.

  METHOD constructor.

    TYPE-POOLS: sfes.

    DATA clsid(80).

    DATA event_tab TYPE cntl_simple_events.
    DATA event_tab_line TYPE cntl_simple_event.

    IF clsid IS INITIAL.
      DATA: return,
            guitype TYPE i.

      guitype = 0.
      CALL FUNCTION 'GUI_HAS_OBJECTS'
           EXPORTING
                object_model = sfes_obj_activex
           IMPORTING
                return       = return
           EXCEPTIONS
                OTHERS       = 1.
      IF sy-subrc NE 0.
        RAISE error.
      ENDIF.

      IF return = 'X'.
        guitype = 1.
      ENDIF.
      IF guitype = 0.
        CALL FUNCTION 'GUI_HAS_OBJECTS'
             EXPORTING
                  object_model = sfes_obj_javabeans
             IMPORTING
                  return       = return
             EXCEPTIONS
                  OTHERS       = 1.
        IF sy-subrc NE 0.
          RAISE error.
        ENDIF.

        IF return = 'X'.
          guitype = 2.
        ENDIF.
      ENDIF.

      CASE guitype.
        WHEN 1.
          clsid = 'Sapgui.InfoCtrl.1'.
        WHEN 2.
          clsid = 'com.sap.components.controls.sapImage.SapImage'.
      ENDCASE.
    ENDIF.

    CALL METHOD super->constructor
      EXPORTING
        clsid = clsid
        shellstyle = 0
        parent = cl_gui_container=>default_screen
        autoalign = space
         EXCEPTIONS OTHERS = 1.
    IF sy-subrc NE 0.
      RAISE error.
    ENDIF.

    CALL METHOD cl_gui_cfw=>subscribe
      EXPORTING
         shellid = h_control-shellid
         ref = me
         EXCEPTIONS OTHERS = 1.
    IF sy-subrc NE 0.
      RAISE error.
    ENDIF.

* Register the events
    event_tab_line-eventid = lcl_gui_timer=>eventid_finished.
    APPEND event_tab_line TO event_tab.

    CALL METHOD set_registered_events
      EXPORTING
        events = event_tab.

  ENDMETHOD.

  METHOD cancel.

    CALL METHOD call_method
        EXPORTING
                  method  = 'SetTimer'
                  p_count = 1
                  p1      = -1
                  queue_only = 'X'
         EXCEPTIONS OTHERS = 1.
    IF sy-subrc NE 0.
      RAISE error.
    ENDIF.

  ENDMETHOD.

  METHOD run.

    CALL METHOD call_method
        EXPORTING
                  method = 'SetTimer'
                  p_count = 1
                  p1     = interval
                  queue_only = 'X'
         EXCEPTIONS OTHERS = 1.
    IF sy-subrc NE 0.
      RAISE error.
    ENDIF.

  ENDMETHOD.

  METHOD dispatch .

    CASE eventid.
      WHEN eventid_finished.
        RAISE EVENT finished.
    ENDCASE.

  ENDMETHOD.

ENDCLASS.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.