【轉載】SAP 通過http協議 介面做銀企直連
使用HTTP協議的都可以參考,如快遞介面等。
注意如果連線不成功,可能是因為系統沒有配置DNS,不能上網導致不能連線成功。
參考:https://archive.sap.com/discussions/thread/535031
TYPES:BEGIN OF tp_title,
funnam TYPE char20,
dattyp TYPE c,
lgnnam TYPE char20,
END OF tp_title.
TYPES: BEGIN OF tp_payqx,
buscod TYPE c,
busmod TYPE c,
modals TYPE c,
END OF tp_payqx.
TYPES: BEGIN OF tp_paydtx,
yurref TYPE c,
eptdat TYPE c,
epttim TYPE c,
dbtacc TYPE c,
dbtbbk TYPE c,
c_dbtbbk TYPE c,
trsamt TYPE c,
ccynbr TYPE c,
c_ccynbr TYPE c,
stlchn TYPE c,
c_stlchn TYPE c,
nusage TYPE c,
busnar TYPE c,
crtacc TYPE c,
crtnam TYPE c,
brdnbr TYPE c,
crtbnk TYPE c,
ctycod TYPE c,
crtpvc TYPE c,
crtcty TYPE c,
crtdtr TYPE c,
ntfch1 TYPE c,
ntfch2 TYPE c,
crtsqn TYPE c,
END OF tp_paydtx.
TYPES: BEGIN OF tp_body,
funnam TYPE char20,
dattyp TYPE c,
lgnnam TYPE char20,
buscod TYPE c,
busmod TYPE c,
modals TYPE c,
yurref TYPE c,
eptdat TYPE c,
epttim TYPE c,
dbtacc TYPE c,
dbtbbk TYPE c,
c_dbtbbk TYPE c,
trsamt TYPE c,
ccynbr TYPE c,
c_ccynbr TYPE c,
stlchn TYPE c,
c_stlchn TYPE c,
nusage TYPE c,
busnar TYPE c,
crtacc TYPE c,
crtnam TYPE c,
brdnbr TYPE c,
crtbnk TYPE c,
ctycod TYPE c,
crtpvc TYPE c,
crtcty TYPE c,
crtdtr TYPE c,
ntfch1 TYPE c,
ntfch2 TYPE c,
crtsqn TYPE c,
END OF tp_body.
TYPES: BEGIN OF xml_line,
data(256) TYPE x,
END OF xml_line.
DATA:
it_dbcon TYPE dbcon OCCURS 0,
wa_dbcon TYPE dbcon.
DATA: http_client TYPE REF TO if_http_client,
lv_xstring TYPE xstring,
lv_string TYPE string,
v_string TYPE string,
return_str TYPE string.
DATA: proxy_host TYPE string VALUE '172.27.70.66' ,
proxy_port TYPE string VALUE '8080',
proxy_user TYPE string ,
proxy_pass TYPE string .
DATA: len TYPE i.
CONSTANTS:
* C_T01 TYPE STRING VALUE
* '<?xml version = "1.0" encoding = "GB2312"?>',
* C_T02 TYPE STRING VALUE
* '<bocb2e version="100" security="true" lang="chs">',
c_t01 TYPE string VALUE
'<?xml version="1.0" encoding = "GBK"?>',
c_t03 TYPE string VALUE '</bocb2e>'.
LOOP AT zttr_eppk INTO zttr_eppk.
CONCATENATE c_t01
'<CMBSDKPGK>'
'<INFO>'
'<FUNNAM>' 'Payment' '</FUNNAM>'
'<DATTYP>' '2' '</DATTYP>'
'<LGNNAM>' 'ZL01' '</LGNNAM>'
'</INFO>'
'<SDKPAYRQX>'
'<BUSCOD>' 'N02031' '</BUSCOD>'
'<BUSMOD>' '00001' '</BUSMOD>'
'</SDKPAYRQX>'
'<SDKPAYDTX>'
'<YURREF>' zttr_eppk-yurref '</YURREF>'
'<EPTDAT>' zttr_eppk-eptdat '</EPTDAT>'
'<EPTTIM>' zttr_eppk-epttim '</EPTTIM>'
'<DBTACC>' zttr_eppk-dbtacc '</DBTACC>'
'<C_DBTBBK>' zttr_eppk-c_dbtbbk '</C_DBTBBK>'
* '<TRSAMT>' zttr_eppk-trsamt '</TRSAMT>'
'<C_CCYNBR>' zttr_eppk-ccynbr '</C_CCYNBR>'
'<C_STLCHN>' zttr_eppk-c_ccynbr '</C_STLCHN>'
'<NUSAGE>' zttr_eppk-nusage '</NUSAGE>'
'<CRTACC>' zttr_eppk-crtacc '</CRTACC>'
'<CRTNAM>' zttr_eppk-crtnam '</CRTNAM>'
'<CRTBNK>' zttr_eppk-crtbnk '</CRTBNK>'
'<CRTPVC>' zttr_eppk-crtpvc '</CRTPVC>'
'<CRTCTY>' zttr_eppk-crtcty '</CRTCTY>'
'<CRTSQN>' zttr_eppk-oprlgn '</CRTSQN>'
'</SDKPAYDTX>'
'</CMBSDKPGK>'
INTO v_string.
ENDLOOP.
*----------------------------------------------------------------------*
* Deal with layout format to xml *
*----------------------------------------------------------------------*
SELECT *
INTO CORRESPONDING FIELDS OF TABLE it_dbcon
FROM dbcon
WHERE con_name = connect.
IF sy-subrc = 0.
READ TABLE it_dbcon INTO wa_dbcon WITH KEY con_name = connect.
IF sy-subrc <> 0.
MESSAGE 'ERROR ' TYPE 'E'.
ENDIF.
ENDIF.
CALL METHOD cl_http_client=>create
EXPORTING
host = '172.0.0.1'
service = '8080'
proxy_host = '172.0.0.1'
proxy_service = '8080'
scheme = '1'
* ssl_id =
* sap_username =
* sap_client =
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
len = STRLEN( v_string ).
http_client->propertytype_logon_popup = http_client->co_enabled .
CALL METHOD http_client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
CALL METHOD http_client->request->set_cdata
EXPORTING
data = v_string
offset = 0
length = len.
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
CLEAR return_str.
return_str = http_client->response->get_cdata( ).
CONDENSE return_str NO-GAPS.
CALL METHOD http_client->close.
相關文章
- HTTP通訊協議HTTP協議
- 網路通訊協議-HTTP協議詳解!協議HTTP
- HTTP協議的通訊框架HTTP協議框架
- 網路通訊協議自動轉換之thrift到http協議HTTP
- [轉]HTTP協議 2018-10-04HTTP協議
- Raft協議:通過TermId大的通過Raft協議
- 頁面連結跳轉--指定協議,半協議,無協議協議
- ElasticSearch 通過nginx做HTTP驗證ElasticsearchNginxHTTP
- Profibus協議轉profinet協議閘道器模組連線電磁閥通訊案例協議
- http協議HTTP協議
- HTTP 協議HTTP協議
- 工行銀企直連簽名報文亂碼
- 最全網路協議(轉載)協議
- Modbus協議轉Profibus協議閘道器模組連PLC與鐳射發射器通訊協議
- 02 前端HTTP協議(圖解HTTP) 之 簡單的HTTP協議前端HTTP協議圖解
- HTTP 協議類HTTP協議
- HTTP協議概述HTTP協議
- 理解http協議HTTP協議
- http協議分析HTTP協議
- HTTP協議(2)HTTP協議
- 小解http協議HTTP協議
- QT使用 http 協議通訊的實現示例QTHTTP協議
- 客戶端和伺服器透過http協議基於》》tcp協議,經過三次握手進行socket連線客戶端伺服器HTTP協議TCP
- 巴圖制自動化Profinet協議轉Modbus協議模組連線PLC和電錶通訊協議
- Python 之requests封裝通用http協議介面請求Python封裝HTTP協議
- 通過故事引申網路協議TCP協議TCP
- HTTP協議之:HTTP/1.1和HTTP/2HTTP協議
- 【轉載】SAP中用json資料格式呼叫http介面傳送簡訊郵件案例JSONHTTP
- HTTP協議基礎HTTP協議
- HTTP協議詳解HTTP協議
- RPC和 HTTP協議RPCHTTP協議
- 瞭解HTTP協議HTTP協議
- HTTP和HTTPS協議HTTP協議
- HTTP 協議圖解HTTP協議圖解
- HTTP2 協議HTTP協議
- 簡述HTTP協議HTTP協議
- Http協議簡介HTTP協議
- 淺談HTTP協議HTTP協議