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

ABAP Asynchronous RFC I - Self refreshing ABAP List



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Sep 13, 2008 7:15 pm    Post subject: ABAP Asynchronous RFC I - Self refreshing ABAP List Reply with quote

Author: Holger Pakirnus

Simple example of asynchronous RFC used here to refresh a list automatically.
Do NOT forget to mark the Function as RFC enabled (FM attributes).

Code:
REPORT  zdgf_hp_test_710 NO STANDARD PAGE HEADING.
* DEMO asynchronous RFC I
*      self refreshing list
*      define FUNCTION at the and seperately - check REMOTE at attrib.
* GLOBAL DATA      *****************************************************
 DATA: max_tasks TYPE i.
 DATA: free_tasks TYPE i.
 DATA: gl_done TYPE xfeld.
* SELECTION-SCREEN (PARAMETERS/SELECT OPTIONS) *************************
 PARAMETERS: time TYPE i DEFAULT 1.
************************************************************************
 INITIALIZATION.
 START-OF-SELECTION.
   PERFORM rfc_info_get.
 END-OF-SELECTION.
   SET PF-STATUS 'MAIN'. "define own including FCODE 'REFR'
   PERFORM write_list.
   PERFORM auto_refresh.
 AT USER-COMMAND.
   CHECK sy-ucomm = 'REFR'.
*   SET PF-STATUS 'MAIN' EXCLUDING 'REFR'.
   sy-lsind = 0.
   PERFORM rfc_info_get.
   PERFORM write_list.
   PERFORM auto_refresh.
************************************************************************
*&--------------------------------------------------------------------*
*&      Form  auto_refresh
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
 FORM auto_refresh.
   CLEAR gl_done.
   CALL FUNCTION 'Z_DGF_WAIT_N'
     STARTING NEW TASK 'TIM'
     DESTINATION 'WORKFLOW_LOCAL_010'
     PERFORMING handler ON END OF TASK
     EXPORTING
       i_waittime            = time
     EXCEPTIONS
       communication_failure = 1.
   IF sy-subrc NE 0.
     EXIT.
   ENDIF.
*    WAIT UNTIL NOT gl_done IS INITIAL.
 ENDFORM.                               " AUTO_REFRESH

*&--------------------------------------------------------------------*
*&      Form  handler
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->VALUE(P_TAStextE)
*---------------------------------------------------------------------*
 FORM handler USING    value(p_taskname).
   RECEIVE RESULTS FROM FUNCTION 'Z_DGF_WAIT_N'
       IMPORTING  e_done = gl_done
       EXCEPTIONS
          communication_failure = 1     "MESSAGE msg
          system_failure        = 2.    "MESSAGE msg.
   IF sy-subrc NE 0.
     LEAVE PROGRAM.
   ENDIF.
   CHECK gl_done EQ 'X'.
   SET USER-COMMAND 'REFR'.
 ENDFORM.                               " HANDLER
*&---------------------------------------------------------------------*
*&      Form  rfc_info_get
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
 FORM rfc_info_get .
   CALL FUNCTION 'SPBT_INITIALIZE'
* EXPORTING
*   GROUP_NAME                           = ' '
    IMPORTING
      max_pbt_wps                          = max_tasks
      free_pbt_wps                         = free_tasks
    EXCEPTIONS
      invalid_group_name                   = 1
      internal_error                       = 2
      pbt_env_already_initialized          = 3
      currently_no_resources_avail         = 4
      no_pbt_resources_found               = 5
      cant_init_different_pbt_groups       = 6
      OTHERS                               = 7.
   CASE sy-subrc.
     WHEN 0. "ok
     WHEN 3.
       CALL FUNCTION 'SPBT_GET_CURR_RESOURCE_INFO'
         IMPORTING
           max_pbt_wps                 = max_tasks
           free_pbt_wps                = free_tasks
         EXCEPTIONS
           internal_error              = 1
           pbt_env_not_initialized_yet = 2
           OTHERS                      = 3.
       IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
       ENDIF.
     WHEN OTHERS.
       MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
   ENDCASE.
 ENDFORM.                    " rfc_info_get
*&---------------------------------------------------------------------*
*&      Form  write_list
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
 FORM write_list .
   WRITE:  'max. tasks:', max_tasks  LEFT-JUSTIFIED.
   WRITE: /'avl. tasks:', free_tasks LEFT-JUSTIFIED.
   WRITE: /'time      :', sy-uzeit.
 ENDFORM.                    " write_list
*FUNCTION z_dgf_wait_n.
**"---------------------------------
**-------------------------------------
**"*"Lokale Schnittstelle:
**"  IMPORTING
**"     VALUE(I_WAITTIME) TYPE  I DEFAULT 10
**"  EXPORTING
**"     VALUE(E_DONE) TYPE  BOOLEAN
**"---------------------------------
**-------------------------------------
*  TABLES indx.
*  IF i_waittime GE 3600.                                    "1h
*    i_waittime = 1.
*  ENDIF.
*  IF i_waittime LE 1.
*    i_waittime = 1.
*  ENDIF.
*
*  WAIT UP TO i_waittime SECONDS.
*  e_done = 'X'.
*
*ENDFUNCTION.
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 -> Interfaces | Интерфейсы 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.