首页 > 代码库 > 20170401 ABAP调用CIS webservice
20170401 ABAP调用CIS webservice
问题:
SAP abap
SRM java 调webservice 不通,
CIS java 这边的webservice 可以通,
WHY?
key:
请求头,
系统框架的问题,
LF:因为请求头的问题吧
CX:请求头有什么差别?
LF:r3发出来的请求,header里面很复杂 ;大概不符合srm的要求,
这个最开始是 波哥调某个系统的时候出现的,
我搞不清楚为啥会出现,而且其他sap开发人员做接口不会出现这个问题吗,之前一直想找到原因,但还是因为不够执著,且能力也有欠缺未能成功find reason ,
可能是某些系统框架的问题,
abap 《-》java 还是听便利的,从技术角度很多都可行,
FUNCTION ZMLSCP1_FR0008. *"---------------------------------------------------------------------- *"*"本地接口: *" IMPORTING *" VALUE(I_EBELN) TYPE EBELN OPTIONAL *" VALUE(I_MATNR) TYPE MATNR OPTIONAL *" EXPORTING *" VALUE(O_STATU) TYPE CHAR1 *" VALUE(O_MSG) TYPE CHAR255 *" TABLES *" OT_RESOURCE STRUCTURE ZSRM_RESOURCE *"---------------------------------------------------------------------- *&Flag 0-手动; 1-自动 DATA:L_TABIX TYPE SY-TABIX. DATA:LV_FLAG TYPE C. DATA:LV_CON TYPE STRING. DATA: ERROR TYPE REF TO CX_AI_SYSTEM_FAULT. DATA: PRXY TYPE REF TO ZCO_REQUEST_IMATNR_RESOURCE_SE."Proxy Name DATA: Z_IN TYPE ZREQUEST8. "request in DATA: Z_OUT TYPE ZRESPONSE8."request out DATA: O_CX TYPE REF TO CX_ROOT. DATA: O_ERROR TYPE REF TO CX_ST_ERROR. TYPES:BEGIN OF TY_RE, BACKUP1 TYPE STRING,"备用字段1 BACKUP2 TYPE STRING,"备用字段2 BACKUP3 TYPE STRING,"备用字段3 BACKUP4 TYPE STRING,"备用字段4 BACKUP5 TYPE STRING,"备用字段5 EBELN TYPE STRING,"采购订单号 EBELP TYPE STRING,"采购订单行项目号 LIFNRAMOUNT TYPE STRING, "供应商库存数量 MAKTX TYPE STRING, "物料描述 MATNR TYPE STRING, "物料代码 PROAMOUNT TYPE STRING, "生产数量 STOREAMOUNT TYPE STRING, "线边仓库存数量 * PRODATE TYPE DATUM, "生产日期 END OF TY_RE. DATA:GT_RE TYPE STANDARD TABLE OF TY_RE, WA_RE LIKE LINE OF GT_RE. *&job user IF SY-UNAME EQ ‘‘. LV_FLAG = ‘1‘. ELSE. LV_FLAG = ‘0‘. ENDIF. CONCATENATE ‘<in0>‘ LV_FLAG ‘</in0>‘ ‘<in1>‘ I_EBELN ‘</in1>‘ ‘<in2>‘ I_MATNR ‘</in2>‘ INTO LV_CON. *&s1.call proxy get data via cis * Z_IN-REQUEST_DATA = http://www.mamicode.com/‘<?xml version="1.0" encoding="UTF-8"?><handleIMatnrResourceService><in0>‘ && LV_FLAG && ‘</in0></handleIMatnrResourceService>‘. CONCATENATE ‘<?xml version="1.0" encoding="UTF-8"?><handleIMatnrResourceService>‘ LV_CON ‘</handleIMatnrResourceService>‘ INTO Z_IN-REQUEST_DATA. CLEAR ERROR. TRY. CREATE OBJECT PRXY EXPORTING LOGICAL_PORT_NAME = ‘ZMLSCP_GET_RESOURCE‘. CALL METHOD PRXY->REQUEST EXPORTING INPUT = Z_IN IMPORTING OUTPUT = Z_OUT. CATCH CX_AI_SYSTEM_FAULT INTO ERROR. O_STATU = ‘E‘. O_MSG = ERROR->ERRORTEXT. RETURN. ENDTRY. *&1.1 is it ok? IF Z_OUT-RETURN_CODE = ‘E‘. O_STATU = ‘E‘. O_MSG = Z_OUT-RETURN_DESC. * RETURN. ENDIF. * for test: IF Z_OUT-RETURN_DATA IS INITIAL. CONCATENATE ‘<?xml version="1.0" encoding="UTF-8"?>‘ ‘<handleIMatnrResourceServiceResponse><out>‘ ‘<MLMatnrResource><backup1/><backup2/><backup3/><backup4/><backup5/><ebeln>4800064316</ebeln><ebelp>00010</ebelp><lifnrAmount/><maktx>A级冰箱型号标贴_C0414.6-1(A</maktx>‘ ‘<matnr>000000000800013563</matnr><proAmount/><storeAmount>12.0</storeAmount></MLMatnrResource>‘ ‘<MLMatnrResource><backup1/><backup2/><backup3/><backup4/><backup5/><ebeln>4800064316</ebeln><ebelp>00020</ebelp><lifnrAmount/><maktx>A级冰箱型号标贴_C0414.6-1(A</maktx>‘ ‘<matnr>000000000800013563</matnr><proAmount/><storeAmount>12.0</storeAmount></MLMatnrResource>‘ ‘<MLMatnrResource><backup1/><backup2/><backup3/><backup4/><backup5/><ebeln>4800064317</ebeln><ebelp>00010</ebelp><lifnrAmount/><maktx>A级冰箱型号标贴_C0414.6-1(A</maktx>‘ ‘<matnr>000000000800013563</matnr><proAmount/><storeAmount>12.0</storeAmount></MLMatnrResource>‘ ‘</out></handleIMatnrResourceServiceResponse>‘ INTO Z_OUT-RETURN_DATA . ENDIF. *&s2.transfer XML IF Z_OUT-RETURN_DATA IS NOT INITIAL."业务系统返回报文不为空 TRY . CLEAR:GT_RE,WA_RE. CALL TRANSFORMATION ZML_XML_TRANS02"ZML_XML_RESOURCE SOURCE XML Z_OUT-RETURN_DATA RESULT MLMATNRRESOURCE = GT_RE."OT_RESOURCE[] IF SY-SUBRC NE 0. O_STATU = ‘E‘. O_MSG = ‘XML解析失败!‘. RETURN. ENDIF. CATCH CX_ST_ERROR INTO O_ERROR . O_STATU = ‘E‘. O_MSG = O_ERROR->GET_TEXT( ) . ENDTRY. ELSE. O_STATU = ‘E‘. O_MSG = ‘返回结果为空!‘. ENDIF. *&s3.data save to ZSRM_RESOURCE LOOP AT GT_RE INTO WA_RE. MOVE-CORRESPONDING WA_RE TO OT_RESOURCE. OT_RESOURCE-ZDATUM = SY-DATUM. OT_RESOURCE-ZCPUTM = SY-UZEIT. OT_RESOURCE-USNAM = SY-UNAME. OT_RESOURCE-ZFLAG = LV_FLAG. APPEND OT_RESOURCE. * MODIFY GT_RE FROM WA_RE. * CLEAR WA_RE. ENDLOOP. * TRY CHECK OT_RESOURCE[] IS NOT INITIAL. MODIFY ZSRM_RESOURCE FROM TABLE OT_RESOURCE. IF SY-SUBRC EQ 0. COMMIT WORK AND WAIT . DESCRIBE TABLE OT_RESOURCE LINES L_TABIX. O_STATU = ‘S‘. O_MSG = ‘成功存入ZSRM_RESOURCE‘ && L_TABIX && ‘条记录!‘. ELSE. ROLLBACK WORK. O_STATU = ‘E‘. O_MSG = ‘数据存入 ZSRM_RESOURCE表失败!‘. ENDIF. ENDFUNCTION.
20170401 ABAP调用CIS webservice
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。