标签:pst exception tab 格式转换 main cal utc 创建 get
步骤:创建企业服务代理类—SM59配置—LPCONFIG配置逻辑端口—接口调用方法类
1.1创建企业服务代理类:
1.1.1
1.1.2
1.1.3
1.2 SM59配置 最后保存即可
1.3 LPCONFIG配置逻辑端口
1.4接口调用方法类
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(INPUTCOLLECTION) TYPE ZMIP_OSB_MIP_MIP_HQ_IMPORT_CA1
*" OPTIONAL
*" EXPORTING
*" VALUE(E_TYPE) TYPE CHAR2
*" VALUE(E_MSG) TYPE CHAR255
*" VALUE(OUTPUTPARAMETERS) TYPE ZMIP_OSB_MIP_MIP_HQ_IMPORT_CAN
*"----------------------------------------------------------------------
DATA:ESB_MIP_CO_OSB TYPE REF TO ZMIP_CO_OSB_MIP_MIP_HQ_IMPORT,
OBJ_EXCEPTION TYPE REF TO CX_AI_SYSTEM_FAULT,
L_OUTPUT TYPE ZMIP_OSB_MIP_MIP_HQ_IMPORT_CAN,
L_INPUT TYPE ZMIP_OSB_MIP_MIP_HQ_IMPORT_CA1.
DATA: ERRORTEXT TYPE STRING.
*INPUTCOLLECTION-PAYLOAD-INPUTCOLLECTION-INPUTCOLLECTION_ITEMs
****Set the input parameter into the Request of the SOAP Object
****Create the Proxy and Clall it.
CREATE OBJECT ESB_MIP_CO_OSB.
TRY.
CALL METHOD ESB_MIP_CO_OSB->PROCESS
EXPORTING
INPUT = INPUTCOLLECTION
IMPORTING
OUTPUT = OUTPUTPARAMETERS.
CATCH CX_AI_SYSTEM_FAULT INTO OBJ_EXCEPTION .
CALL METHOD OBJ_EXCEPTION->GET_TEXT
RECEIVING
RESULT = ERRORTEXT.
E_TYPE = ‘E‘.
E_MSG = ERRORTEXT.
EXIT.
ENDTRY.
2.被调用
步骤:创建RFC函数—创建该函数的企业服务生产URL(WSDL)—SOAMANAGER配置
2.1
被调用代码(json格式转换):
FUNCTION ZFM_ESB_LIFNR_MAINTAIN_OL.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(MSGHEADER) TYPE ZSESB_MSGHEADER OPTIONAL
*" VALUE(INPUTCOLLECTION) TYPE ZINPUTCOLLECTION OPTIONAL
*" EXPORTING
*" VALUE(OUTPUTPARAMETERS) TYPE ZSESB_OUT_OL
*"----------------------------------------------------------------------
DATA: ZINPUTCOLLECTION TYPE ZESB_INPUT_JSON_MAINTAIN,
ZOUTPUTPARAMETERS TYPE ZSESB_OUT_LIFNR_MAINTAIN,
LS_INPUT TYPE ZSLIFNR,
LS_INPUTJSON TYPE STRING,
LS_OUTPUTJSON TYPE STRING,
ERRORTEXT TYPE STRING.
DATA: JSON_SER TYPE REF TO CL_TREX_JSON_SERIALIZER,
JSON_DES TYPE REF TO CL_TREX_JSON_DESERIALIZER.
DATA CX_TREX TYPE REF TO CX_TREX_SERIALIZATION.
DATA: OBJ_EXCEPTION TYPE REF TO CX_AI_SYSTEM_FAULT.
* ls_inputjson = msgheader-input_json.
* DATA:ZINPUTCOLLECTION TYPE
* DATA:LT_ITEM TYPE ZTINPUTCOLLECTION .
DATA:LW_ITEM TYPE ZSINPUTCOLLECTION .
LW_ITEM = INPUTCOLLECTION-INPUTCOLLECTION_ITEM.
* READ TABLE LT_ITEM INTO LW_ITEM INDEX 1.
LS_INPUTJSON = LW_ITEM-INPUT_JSON.
TRANSLATE LS_INPUTJSON TO UPPER CASE.
REPLACE ALL OCCURRENCES OF ‘"LIFNR"‘ IN LS_INPUTJSON WITH ‘lifnr‘.
REPLACE ALL OCCURRENCES OF ‘"BUKRS"‘ IN LS_INPUTJSON WITH ‘bukrs‘.
REPLACE ALL OCCURRENCES OF ‘"EKORG"‘ IN LS_INPUTJSON WITH ‘ekorg‘.
REPLACE ALL OCCURRENCES OF ‘"KTOKK"‘ IN LS_INPUTJSON WITH ‘ktokk‘.
REPLACE ALL OCCURRENCES OF ‘"AKONT"‘ IN LS_INPUTJSON WITH ‘akont‘.
REPLACE ALL OCCURRENCES OF ‘"TITLE"‘ IN LS_INPUTJSON WITH ‘title‘.
REPLACE ALL OCCURRENCES OF ‘"NAME1"‘ IN LS_INPUTJSON WITH ‘name1‘.
REPLACE ALL OCCURRENCES OF ‘"NAME2"‘ IN LS_INPUTJSON WITH ‘name2‘.
REPLACE ALL OCCURRENCES OF ‘"SORTL"‘ IN LS_INPUTJSON WITH ‘sortl‘.
REPLACE ALL OCCURRENCES OF ‘"STRAS"‘ IN LS_INPUTJSON WITH ‘stras‘.
REPLACE ALL OCCURRENCES OF ‘"PSTLZ"‘ IN LS_INPUTJSON WITH ‘pstlz‘.
REPLACE ALL OCCURRENCES OF ‘"ORT01"‘ IN LS_INPUTJSON WITH ‘ort01‘.
REPLACE ALL OCCURRENCES OF ‘"LAND1"‘ IN LS_INPUTJSON WITH ‘land1‘.
REPLACE ALL OCCURRENCES OF ‘"REGIO"‘ IN LS_INPUTJSON WITH ‘regio‘.
REPLACE ALL OCCURRENCES OF ‘"TELX1"‘ IN LS_INPUTJSON WITH ‘telx1‘.
REPLACE ALL OCCURRENCES OF ‘"TELF3"‘ IN LS_INPUTJSON WITH ‘telf3‘.
REPLACE ALL OCCURRENCES OF ‘"TELFX"‘ IN LS_INPUTJSON WITH ‘telfx‘.
REPLACE ALL OCCURRENCES OF ‘"LANGU"‘ IN LS_INPUTJSON WITH ‘langu‘.
REPLACE ALL OCCURRENCES OF ‘"KUNNR"‘ IN LS_INPUTJSON WITH ‘kinnr‘.
REPLACE ALL OCCURRENCES OF ‘"BEGRU"‘ IN LS_INPUTJSON WITH ‘begru‘.
REPLACE ALL OCCURRENCES OF ‘"STCD3"‘ IN LS_INPUTJSON WITH ‘stcd3‘.
REPLACE ALL OCCURRENCES OF ‘"STCD5"‘ IN LS_INPUTJSON WITH ‘stcd5‘.
REPLACE ALL OCCURRENCES OF ‘"BANKS"‘ IN LS_INPUTJSON WITH ‘banks‘.
REPLACE ALL OCCURRENCES OF ‘"BANKL"‘ IN LS_INPUTJSON WITH ‘bankl‘.
REPLACE ALL OCCURRENCES OF ‘"BANKA"‘ IN LS_INPUTJSON WITH ‘banka‘.
REPLACE ALL OCCURRENCES OF ‘"BANKN"‘ IN LS_INPUTJSON WITH ‘bankn‘.
REPLACE ALL OCCURRENCES OF ‘"KOINH"‘ IN LS_INPUTJSON WITH ‘koinh‘.
REPLACE ALL OCCURRENCES OF ‘"BVTYP"‘ IN LS_INPUTJSON WITH ‘bvtyp‘.
REPLACE ALL OCCURRENCES OF ‘"BKREF"‘ IN LS_INPUTJSON WITH ‘bkref‘.
REPLACE ALL OCCURRENCES OF ‘"ZUAWA"‘ IN LS_INPUTJSON WITH ‘zuawa‘.
REPLACE ALL OCCURRENCES OF ‘"ZTERM"‘ IN LS_INPUTJSON WITH ‘zterm‘.
REPLACE ALL OCCURRENCES OF ‘"REPRF"‘ IN LS_INPUTJSON WITH ‘reprf‘.
REPLACE ALL OCCURRENCES OF ‘"ZWELS"‘ IN LS_INPUTJSON WITH ‘zwels‘.
REPLACE ALL OCCURRENCES OF ‘"WAERS"‘ IN LS_INPUTJSON WITH ‘waers‘.
REPLACE ALL OCCURRENCES OF ‘"WEBRE"‘ IN LS_INPUTJSON WITH ‘webre‘.
REPLACE ALL OCCURRENCES OF ‘"PROVZ"‘ IN LS_INPUTJSON WITH ‘provz‘.
REPLACE ALL OCCURRENCES OF ‘"ORT02"‘ IN LS_INPUTJSON WITH ‘ort02‘.
REPLACE ALL OCCURRENCES OF ‘"BRSCH"‘ IN LS_INPUTJSON WITH ‘brsch‘.
REPLACE ALL OCCURRENCES OF ‘"[‘ IN LS_INPUTJSON WITH ‘[‘.
REPLACE ALL OCCURRENCES OF ‘]"‘ IN LS_INPUTJSON WITH ‘]‘.
TRY .
"传入参数JSON=> 转换为结构
CREATE OBJECT JSON_DES.
CALL METHOD JSON_DES->DESERIALIZE
EXPORTING
JSON = LS_INPUTJSON
IMPORTING
ABAP = LS_INPUT.
ZINPUTCOLLECTION-INPUT_JSON = LS_INPUT.
CALL FUNCTION ‘ZFM_ESB_LIFNR_MAINTAIN‘
EXPORTING
MSGHEADER = MSGHEADER
INPUTCOLLECTION = ZINPUTCOLLECTION
IMPORTING
OUTPUTPARAMETERS = ZOUTPUTPARAMETERS.
* CATCH cx_trex_serialization INTO cx_trex.
CATCH CX_AI_SYSTEM_FAULT INTO OBJ_EXCEPTION.
CALL METHOD OBJ_EXCEPTION->GET_TEXT
RECEIVING
RESULT = ERRORTEXT.
ZOUTPUTPARAMETERS-OUTPUT_JSON-E_TYPE = ‘E‘.
ZOUTPUTPARAMETERS-OUTPUT_JSON-E_MESSAGE = ERRORTEXT.
EXIT.
ENDTRY.
"解析返回参数
TRY .
* ***内表->JSON
CREATE OBJECT JSON_SER
EXPORTING
DATA = ZOUTPUTPARAMETERS-OUTPUT_JSON.
CALL METHOD JSON_SER->SERIALIZE.
CALL METHOD JSON_SER->GET_DATA
RECEIVING
RVAL = LS_OUTPUTJSON.
MOVE: ZOUTPUTPARAMETERS-ESB_FLAG TO OUTPUTPARAMETERS-ESB_FLAG,
ZOUTPUTPARAMETERS-ESB_RETURN_CODE TO OUTPUTPARAMETERS-ESB_RETURN_CODE,
ZOUTPUTPARAMETERS-ESB_RETURN_MESSAGE TO OUTPUTPARAMETERS-ESB_RETURN_MESSAGE,
ZOUTPUTPARAMETERS-BIZ_SERVICE_FLAG TO OUTPUTPARAMETERS-BIZ_SERVICE_FLAG,
ZOUTPUTPARAMETERS-BIZ_RETURN_CODE TO OUTPUTPARAMETERS-BIZ_RETURN_CODE,
ZOUTPUTPARAMETERS-BIZ_RETURN_MESSAGE TO OUTPUTPARAMETERS-BIZ_RETURN_MESSAGE,
ZOUTPUTPARAMETERS-INSTANCE_ID TO OUTPUTPARAMETERS-INSTANCE_ID.
REPLACE ALL OCCURRENCES OF ‘e_lifnr‘ IN LS_OUTPUTJSON WITH ‘"e_lifnr"‘.
REPLACE ALL OCCURRENCES OF ‘e_bankl‘ IN LS_OUTPUTJSON WITH ‘"e_bankl"‘.
REPLACE ALL OCCURRENCES OF ‘e_type‘ IN LS_OUTPUTJSON WITH ‘"e_type"‘.
REPLACE ALL OCCURRENCES OF ‘e_message‘ IN LS_OUTPUTJSON WITH ‘"e_message"‘.
* REPLACE ALL OCCURRENCES OF ‘[‘ IN LS_OUTPUTJSON WITH ‘"[‘.
* REPLACE ALL OCCURRENCES OF ‘]‘ IN LS_OUTPUTJSON WITH ‘]"‘.
OUTPUTPARAMETERS-OUTPUT_JSON = LS_OUTPUTJSON.
TRANSLATE OUTPUTPARAMETERS-OUTPUT_JSON TO UPPER CASE.
CATCH CX_TREX_SERIALIZATION INTO CX_TREX.
CALL METHOD CX_TREX->GET_TEXT
RECEIVING
RESULT = ERRORTEXT.
ZOUTPUTPARAMETERS-OUTPUT_JSON-E_TYPE = ‘E‘.
ZOUTPUTPARAMETERS-OUTPUT_JSON-E_MESSAGE = ERRORTEXT.
EXIT.
ENDTRY.
ENDFUNCTION.
标签:pst exception tab 格式转换 main cal utc 创建 get
原文地址:https://www.cnblogs.com/jimi520/p/12125632.html