Thursday, August 28, 2014
When we were working on Performance Appraisal, Customer asked whether Auto Save is possible as the Appraisal document has lot of things to enter. After entering certain things, if user leaves and goes away, system gives time out error. When we explore, we found UI element TimedTrigger element which can used for the purpose.
UI element TimedTrigger automatically and periodically triggers an event with a specified delay.

Sample program

  • Create one Web Dynpro component(ZTST_TIMED_TRIGGER).
  • Go to view
    • Context. Create one node IT_EMP_DATA and attributes in the nodes as shown.
    • Place transparent Container and place input fields and bind with attributes of node IT_EMP_DATA.

    • Place button for SAVE and create action event SAVE_DATA.

    • Code under SAVE_DATA
    • METHOD ONACTIONSAVE_DATA .
      
       WD_THIS->SAVE( ).
      
      ENDMETHOD.
      

      METHOD SAVE .
        DATA LO_ND_IT_EMP_DATA TYPE REF TO IF_WD_CONTEXT_NODE.
      
        DATA LO_EL_IT_EMP_DATA TYPE REF TO IF_WD_CONTEXT_ELEMENT.
        DATA LS_IT_EMP_DATA TYPE WD_THIS->ELEMENT_IT_EMP_DATA.
      
      * navigate from <CONTEXT> to <IT_EMP_DATA> via lead selection
        LO_ND_IT_EMP_DATA = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_IT_EMP_DATA ).
      * get element via lead selection
        LO_EL_IT_EMP_DATA = LO_ND_IT_EMP_DATA->GET_ELEMENT( ).
      * get all declared attributes
        LO_EL_IT_EMP_DATA->GET_STATIC_ATTRIBUTES(
          IMPORTING
            STATIC_ATTRIBUTES = LS_IT_EMP_DATA ).
      
        MODIFY ZTST_TIME FROM LS_IT_EMP_DATA.
        IF SY-SUBRC EQ 0.
      * get message manager
          DATA LO_API_CONTROLLER     TYPE REF TO IF_WD_CONTROLLER.
          DATA LO_MESSAGE_MANAGER    TYPE REF TO IF_WD_MESSAGE_MANAGER.
      
          LO_API_CONTROLLER ?= WD_THIS->WD_GET_API( ).
      
          LO_MESSAGE_MANAGER = LO_API_CONTROLLER->GET_MESSAGE_MANAGER( ).
      
      * report message
          LO_MESSAGE_MANAGER->REPORT_SUCCESS(
              MESSAGE_TEXT              = 'Data has been save'
      *    PARAMS                    = PARAMS
      *    MSG_USER_DATA             = MSG_USER_DATA
      *    IS_PERMANENT              = ABAP_FALSE
      *    SCOPE_PERMANENT_MSG       = CO_MSG_SCOPE_CONTROLLER
      *    VIEW                      = VIEW
      *    SHOW_AS_POPUP             = SHOW_AS_POPUP
      *    CONTROLLER_PERMANENT_MSG  = CONTROLLER_PERMANENT_MSG
      *    MSG_INDEX                 = MSG_INDEX
      *    CANCEL_NAVIGATION         = CANCEL_NAVIGATION
      *    ENABLE_MESSAGE_NAVIGATION = ENABLE_MESSAGE_NAVIGATION
      *    COMPONENT                 = COMPONENT
          ).
      
        ENDIF.
      
      ENDMETHOD.
      
    • Place TimedTrigger element.

    •  (1) Set delay here. IF we set Delay 30 means system will trigger action(2) after 30 seconds

  • Create Web Dynpro Application
  • Run Application and enter data but do not save.
  • TimedTrigger triggers event SAVE_DATA after Delay we set to 30 seconds.

3 comments:

Your useful comments, suggestions are appreciated.Your comments are moderated.

Followers

Contact Form

Name

Email *

Message *

Web Dynpro ABAP Book

An SAP Consultant

Follow US


Want to Contribute ?

If you are interested in writing about the new stuff you learn everyday while working, please write to the.sap.consultants@gmail.com.

Click on Contribution for more details.