最近在測試
發現可以從ABAP呼叫外部網址傳回部分資訊
主要有兩個方法,第二個方法可以抓回傳值比方JSON
1.CALL FUNCTION 'HTTP_POST'
CALL FUNCTION 'HTTP_POST'
EXPORTING
ABSOLUTE_URI = Uri
REQUEST_ENTITY_BODY_LENGTH = 300
BLANKSTOCRLF = 'X'
TABLES
REQUEST_ENTITY_BODY = t_request_body
RESPONSE_ENTITY_BODY = t_response_body
RESPONSE_HEADERS = t_response_header
REQUEST_HEADERS = t_request_header
EXCEPTIONS
CONNECT_FAILED = 1
TIMEOUT = 2
INTERNAL_ERROR = 3
TCPIP_ERROR = 4
SYSTEM_FAILURE = 5
COMMUNICATION_FAILURE = 6
OTHERS = 7.
2.cl_http_client=>create_by_url
iv_url 為傳入的網址
call method cl_http_client=>create_by_url
exporting
url = iv_url
importing
client = lo_client
exceptions
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
if sy-subrc ne 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
into cv_error_msg.
return.
endif.
lo_client->send( ).
lo_client->receive( exceptions others = 1 ).