Show TOC

Background documentationParallel Processing Requests Locate this document in the navigation structure

 

Caution Caution

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

End of the caution.
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.

Syntax Syntax

  1. parameters: listen type c default space,
  2.             times  type i default '1',
End of the code.

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

Syntax Syntax

  1. *Receive via listen (#times parallel requests)
  2. do times times.
  3.   if not listen is initial.
  4.     call method client->listen
  5.       receiving  client = cclient
  6.       exceptions http_communication_failure  = 1
  7.                  http_no_open_connection     = 2
  8.                  others                      = 3.
  9.   if sy-subrc <> 0.
  10.     call method client->get_last_error
  11.       importing code    = subrc
  12.                 message = dummy.
  13.     write: / listen’,
  14.            / 'code: ', subrc, 'message: ', dummy.
  15.     exit.
  16.   endif.
End of the code.

The incoming responses are re-assigned to the requests.

Syntax Syntax

  1. * Assigning the responses to the requests
  2. * If there are more requests, process all responses
  3.     client = cclient.
  4.     call method client->receive
  5. exceptions http_communication_failure  = 1
  6.            http_invalid_state          = 2
  7.            http_processing_failed      = 3
  8.            others                      = 4.
  9.   if sy-subrc <> 0.
  10.     call method client->get_last_error
  11.        importing code    = subrc
  12.                  message = dummy.
  13.     write: / 'communication_error( receive )',
  14.            / 'code: ', subrc, 'message: ', dummy.
  15.     exit.
  16.   endif.
  17. ...
  18. enddo.
End of the code.

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.