Show TOC

Function documentationCompression Techniques Locate this document in the navigation structure

 

If you want to send large quantities of data, we recommend that you compress it first to keep the transports as small as possible.

Example

The example below shows how you might use data compression.

Syntax Syntax

  1. DATA: html_body TYPE string.
  2. IF compress NE space.
  3.      CALL METHOD server->response->set_header_field(
  4.           name  = 'Content-Type'                            
  5.           value = 'text/html' ).
  6. *
  7. * is compression supported and does client support gzip
  8. * compression technique
  9. *
  10.     CALL METHOD server->set_compression
  11.       EXPORTING
  12.         options          = if_http_server=>co_compress_in_all_cases
  13.       EXCEPTIONS
  14.         compression_not_possible = 1
  15.         OTHERS                   = 2.
  16.     IF sy-subrc <> 0.
  17.       CONCATENATE
  18.              '<html>'
  19.               '<body>'
  20.               'Compress nicht möglich '(001) '</br>'
  21.               '</body>'
  22.             '</html>'
  23.       INTO html_body.
  24.     ELSE.
  25.       CONCATENATE '<html>'
  26.                '<body>'
  27.                'Compress erfolgreich '(001) '</br>'
  28.                '</body>'
  29.              '</html>'
  30.        INTO html_body.
  31.     ENDIF.
  32. *
  33. * if compression could be activated the body will be transferred
  34. * as gzip compressed body
  35. *
  36.     CALL METHOD server->response->set_cdata( data = html_body ).
  37.   ENDIF.
  38.  
End of the code.

More Information

You can follow this example in transaction SICF, in Example_1 under the path default_host/sap/bc/icf/demo/.