新火炬后端单体项目初始化代码
zhangherong
2025-06-13 d7f212d555f92959666ce5a02060ac085531b99b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package org.jeecg.modules.sap.service.impl;
 
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoParameterList;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.config.sap.SapRfcConnectionManager;
import org.jeecg.modules.sap.service.SAPService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
@Service
@Slf4j
public class SAPServiceImpl implements SAPService {
    @Autowired
    private SapRfcConnectionManager connectionManager;
    @SneakyThrows
    @Override
    public String test() {
        JCoDestination destination = connectionManager.getDestination();
        JCoFunction function = destination.getRepository().getFunction("ZPPF_022");
 
        if (function == null) {
            throw new RuntimeException("RFC 函数模块 Z_GET_MATERIAL_INFO 未找到!");
        }
 
        // 设置输入参数
//        JCoParameterList input = function.getImportParameterList();
//        input.setValue("MATERIAL_ID", materialId); // 参数名需与 SAP 函数定义一致
//        function.getImportParameterList().setValue("MATERIAL_ID", 0);
 
        // 执行调用
        function.execute(destination);
 
        // 获取输出参数
        JCoParameterList output = function.getExportParameterList();
//        String materialName = output.getString("MATERIAL_NAME"); // 参数名需与 SAP 函数定义一致
 
        return "";
    }
}