Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8581

Re: Execute a RFC function module within the threshold time limit

$
0
0

Hi Shareen,

 

Sounds like you need the main FM to call the second one asynchronously starting a new task. See the help for CALL FUNCTION ... STARTING NEW TASK.

 

Here's some sample code. Here my timeout was in seconds but you could adapt the WAIT statement to handle a shorter timeout.

 

FUNCTION ...

 

  ADD 1 TO gv_task_no.

  lv_timeout = 1.

 

* Call the maybe slow function.

  CALL FUNCTION 'ZMAYBE_SLOW'

        STARTING NEW TASK gv_task_no

        PERFORMING fm_response ON END OF TASK

        EXCEPTIONS

          communication failure = 1

          system_failure        = 2.

 

*   Waiting for the fm to complete.

    DO lv_timeout TIMES.

      IF gv_completed = 'X'.

        EXIT.

      ENDIF.

      WAIT UNTIL gv_completed = 'X' UP TO 1 SECONDS.

    ENDDO.

 

ENDFUNCTION.

 

*----------------------------------------------------------------------*

 

FORM fm_response USING taskname TYPE any.

 

  RECEIVE RESULTS FROM FUNCTION 'ZMAYBE_SLOW'

    IMPORTING

      es_result             = gs_result

    EXCEPTIONS

      communication failure = 1

      system_failure        = 2.

 

  IF sy-subrc = 1.

    gv_message = 'Sy-subrc 1 - Communication failure'.

  ELSEIF sy-subrc = 2.

    gv_message = 'Sy-subrc 2 - System failure'.

  ENDIF.

 

  gv_completed = 'X'.


ENDFORM.

 

 

Best regards,

 

Paul


Viewing all articles
Browse latest Browse all 8581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>