MES-SAP 生产报工接口代码
时间: 2023-08-06 13:04:39 浏览: 260
SAP MES功能介绍(吐血推荐)
5星 · 资源好评率100%
MES-SAP生产报工接口的代码开发需要根据具体的技术架构和接口规范进行定制开发,以下是一些通用的示例代码:
1. 使用SAP提供的RFC接口:
```
FUNCTION ZMES_SAP_PROD_REPORT.
DATA: LS_MES_PROD_REPORT TYPE ZMES_PROD_REPORT.
"读取MES系统中的生产报工数据
CALL FUNCTION 'ZMES_GET_PROD_REPORT'
EXPORTING
IV_ORDER_NO = '123456'
IMPORTING
ES_PROD_REPORT = LS_MES_PROD_REPORT.
"调用SAP系统中的RFC接口
CALL FUNCTION 'ZSAP_PROD_REPORT'
EXPORTING
IV_ORDER_NO = LS_MES_PROD_REPORT-ORDER_NO
IV_PROD_MODEL = LS_MES_PROD_REPORT-PROD_MODEL
IV_PROD_QTY = LS_MES_PROD_REPORT-PROD_QTY
IV_START_TIME = LS_MES_PROD_REPORT-START_TIME
IV_END_TIME = LS_MES_PROD_REPORT-END_TIME
IV_PROD_PROCESS = LS_MES_PROD_REPORT-PROD_PROCESS
IV_EQUIPMENT_NO = LS_MES_PROD_REPORT-EQUIPMENT_NO
IV_PERSONNEL_NO = LS_MES_PROD_REPORT-PERSONNEL_NO
IV_QUALITY = LS_MES_PROD_REPORT-QUALITY
IV_MATERIAL_CONS = LS_MES_PROD_REPORT-MATERIAL_CONS
IV_MATERIAL_SUPP = LS_MES_PROD_REPORT-MATERIAL_SUPP
IV_MATERIAL_RET = LS_MES_PROD_REPORT-MATERIAL_RET
IMPORTING
EV_RESULT = LV_RESULT.
ENDFUNCTION.
```
2. 使用IDOC接口:
```
"创建IDOC数据包
DATA: LS_IDOC_CONTROL TYPE EDIDC,
LS_IDOC_DATA TYPE EDIDD.
"填充IDOC数据包
LS_IDOC_CONTROL-DOCNUM = '000000000001'.
LS_IDOC_CONTROL-IDOCTYP = 'ZMES_PROD_REPORT'.
LS_IDOC_CONTROL-MESTYP = 'ZMES_PROD_REPORT'.
LS_IDOC_CONTROL-SNDPOR = 'MES'.
LS_IDOC_CONTROL-SNDPRN = 'MES'.
LS_IDOC_CONTROL-RCVPOR = 'SAP'.
LS_IDOC_CONTROL-RCVPRN = 'SAP'.
LS_IDOC_CONTROL-CREDAT = SY-DATUM.
LS_IDOC_CONTROL-STATUS = '03'.
LS_IDOC_CONTROL-OUTMOD = '1'.
LS_IDOC_DATA-SEGMENTTYP = 'ZMES_PROD_REPORT'.
LS_IDOC_DATA-QUALFIER = '001'.
LS_IDOC_DATA-SIGN = 'E'.
LS_IDOC_DATA-DOCNUM = '000000000001'.
LS_IDOC_DATA-SEGMENTNUM = '000001'.
LS_IDOC_DATA-PARENT = '000000'.
LS_IDOC_DATA-HLEVEL = '002'.
LS_IDOC_DATA-MES_PROD_REPORT = LS_MES_PROD_REPORT.
"发送IDOC数据包到SAP系统
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = LS_IDOC_CONTROL
MASTER_IDOC_DATA = LS_IDOC_DATA
IMPORTING
RETURN = LS_RETURN.
```
以上代码仅供参考,具体的接口代码需要根据企业的具体业务需求和技术架构进行定制开发。
阅读全文