Skip to Content
0
Nov 14, 2018 at 09:21 AM

HTTP POST REQUEST got no respond return code

94 Views

Hi Experts,

We've got some issues about HTTP POST.

We call external URI for payment, something like PayPal, Paychex ...

We use function HTTP_POST to send POST data, and actually it successful for most time.

But sometimes, after we send out data to URI, program would not catch any feedback, which means the process will uphold for long long time to wait and wait and wait ... for feedback, and this background job will not error out until we canceled it manually.

ICM services (HTTP / HTTPS) have value 60 for 'keep alive' and 'proc timeout', but not works seemly.

Are there any parameters we need to configure? Or some code to handle this situation?

this part of our code would like below:

DATA P_DEST LIKE RFCDES-RFCDEST.
P_DEST = 'SAPHTTPA'.

CALL FUNCTION 'HTTP_POST'
EXPORTING
ABSOLUTE_URI = P_URI
RFC_DESTINATION = P_DEST
BLANKSTOCRLF = 'Y'
IMPORTING
STATUS_CODE = LV_STATUS_CODE
STATUS_TEXT = LV_STATUS_TEXT
RESPONSE_ENTITY_BODY_LENGTH = LV_LEN
TABLES
REQUEST_ENTITY_BODY = LT_REQ_BODY
RESPONSE_ENTITY_BODY = LT_RES_BODY
RESPONSE_HEADERS = LT_RES_HEAD
REQUEST_HEADERS = LT_REQ_HEAD
EXCEPTIONS
CONNECT_FAILED = 1
TIMEOUT = 2
INTERNAL_ERROR = 3
TCPIP_ERROR = 4
SYSTEM_FAILURE = 5
COMMUNICATION_FAILURE = 6
OTHERS = 7.

*** Connection error
IF LV_STATUS_CODE NE '200'.
CASE SY-SUBRC .
WHEN 1.
ERR = 'CONNECT_FAILED.'.
WHEN 2.
ERR = 'TIMEOUT'.
WHEN 3.
ERR = 'INTERNAL_ERROR'.
WHEN 4.
ERR = 'TCPIP_ERROR'.
WHEN 5.
ERR = 'SYSTEM_FAILURE'.
WHEN 6.
ERR = 'COMMUNICATION_FAILURE'.
WHEN 7.
ERR = 'OTHERS'.
WHEN OTHERS.
CONCATENATE 'Unknown:' LV_STATUS_CODE LV_STATUS_TEXT INTO ERR SEPARATED BY SPACE.
ENDCASE.

PERFORM UPDATE_LOG USING ''
LV_STATUS_CODE
LV_STATUS_TEXT
ERR
P_FULL_URI .
PERFORM POPULATE_MAIL_MESSAGE.
CONTINUE.
ENDIF.

*DATA JSON_RESPONSE TYPE STRING.
READ TABLE LT_RES_BODY INDEX 1.
JSON_RESPONSE = LT_RES_BODY.

REPLACE '"code"' WITH 'code' INTO JSON_RESPONSE.
REPLACE '"data"' WITH 'data' INTO JSON_RESPONSE.
REPLACE '"failure_reason"' WITH 'failure_reason' INTO JSON_RESPONSE.
REPLACE '"status"' WITH 'status' INTO JSON_RESPONSE.
REPLACE '"message"' WITH 'message' INTO JSON_RESPONSE.

LR_JSON_DESERIALIZER->DESERIALIZE( EXPORTING JSON = JSON_RESPONSE IMPORTING ABAP = JSON_OUT ).

IF JSON_OUT-CODE EQ '0000' OR JSON_OUT-CODE EQ '4020'. " 0000 = success, 4020 = The payment_id already exist
PERFORM UPDATE_LOG USING 'X' "SUBMIT = 'X'
JSON_OUT-CODE "RETCODE
JSON_OUT-MESSAGE "MESSAGE
''
P_FULL_URI.
ELSE.
PERFORM UPDATE_LOG USING ''
JSON_OUT-CODE "RETCODE
JSON_OUT-MESSAGE "MESSAGE
''
P_FULL_URI.
PERFORM POPULATE_MAIL_MESSAGE.
ENDIF.