最精简的写法是这样写的:
可以enhance成下面的样子,这样一旦出错我们能够知道准确的error message。
CALL METHOD l_http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
l_sysubrc = sy-subrc.
CALL METHOD l_http_client->get_last_error
IMPORTING
code = l_sysubrc
message = l_error_text.
ENDIF.
CALL METHOD l_http_client->response->get_status
IMPORTING
code = l_status
reason = l_reason.
比如下图这个例子,errorcode 407, message ICM_HTTP_SSL_ERROR,按照SAP官方文档的说法,是certificate import出了问题。