Skip to Content
avatar image
Former Member

http_client->receive - Internal Server Error in SAP ABAP

Hi Everyone,

I have created one function module which executes the third party web page and get response.

Below is the code.

FUNCTION zmm_url_http_get_post.
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(P_URL) TYPE  STRING OPTIONAL
*"  EXPORTING
*"     VALUE(P_RESPONSE) TYPE  STRING
*"  TABLES
*"      T_LOG STRUCTURE  VIFE OPTIONAL
*"  EXCEPTIONS
*"      ERROR_MESSAGE
*"----------------------------------------------------------------------
  DATA : lv_value TYPE string.
  DATA : http_client TYPE REF TO if_http_client 
  DATA : lv_url TYPE string.
  DATA : return TYPE char2048
  DATA : lv_err_string TYPE string,
         lv_ret_code   TYPE sy-subrc.
* Build Url
  lv_url = p_url.
* Create Client
  CALL METHOD cl_http_client=>create_by_url
    EXPORTING
      url    = lv_url
    IMPORTING
      client = http_client.
* Send
  CALL METHOD http_client->send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2.
* Receive
  CALL METHOD http_client->receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3.
  IF sy-subrc NE 0.
    http_client->response->get_status(
      IMPORTING
        code   = lv_ret_code
        reason = lv_err_string
           ).
    MESSAGE lv_err_string TYPE 'I'.
    t_log-msgty = 'E'.
    t_log-msgtx = lv_err_string.
    APPEND t_log.
  ENDIF.
* Now we have the response , parse , display
* do what you like
  return = http_client->response->get_cdata( ).
  p_response = return.
  IF t_log-msgty NE 'E'.
    t_log-msgty = 'S'.
    t_log-msgtx = 'Success'.
    APPEND t_log.
  ENDIF.
ENDFUNCTION.

i have created Background job to execute this code on daily basis. Background is executing successfully , but the problem i am facing is some times status is success some times status is cancelled , the log is Internal Server Error or Job cancelled after system exception ERROR_MESSAGE.

when i execute the same url in web browser response is coming , do i need to do some configuration is SAP to increase Max execution time?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers