Start of Content Area

Background documentation Parallel Requests  Locate the document in its SAP Library structure

Caution

The ABAP code shown here is simplified sample code. It is not meant as a template for real coding.

Use

You can send requests to various servers in parallel and to wait for all the responses simultaneously. The method LISTEN is then used to find out which request is currently being responded to.

This procedure is useful if several requests have been assigned to different servers with widely differing response times.

Activities

You can also add to the program by inserting the following lines. In additional parameters, specify that you want to use the LISTEN method and the number of requests that you want to send.

parameters: listen type c default space,

            times  type i default '1',

 

Now the system waits for the responses to the requests. The responses are received in the order in which the server sends them.

*Receive via listen (#times parallel requests)

do times times.

  if not listen is initial.

    call method client->listen

      receiving  client = cclient

      exceptions http_communication_failure  = 1

                 http_no_open_connection     = 2

                 others                      = 3.

  if sy-subrc <> 0.

    call method client->get_last_error

      importing code    = subrc

                message = dummy.

    write: / listen’,

           / 'code: ', subrc, 'message: ', dummy.

    exit.

  endif.

 

The incoming responses are re-assigned to the requests.

* Assigning the responses to the requests

* If there are more requests, process all responses

    client = cclient.

    call method client->receive

exceptions http_communication_failure  = 1

           http_invalid_state          = 2

           http_processing_failed      = 3

           others                      = 4.

  if sy-subrc <> 0.

    call method client->get_last_error

       importing code    = subrc

                 message = dummy.

    write: / 'communication_error( receive )',

           / 'code: ', subrc, 'message: ', dummy.

    exit.

  endif.

...

enddo.

 

You can then specify how often a request should be dropped (parameter times). You can see in the output the order in which the responses were received. This does not have to be the order in which the requests were sent.

 

 

End of Content Area