新火炬后端单体项目初始化代码
zhangherong
2025-06-17 0ecd8b8c158436b23298b66b64eaef0438b6425b
src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java
@@ -3,12 +3,16 @@
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoParameterList;
import com.sap.conn.jco.JCoRepository;
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;
import java.util.Arrays;
import java.util.Collections;
@Service
@Slf4j
@@ -19,16 +23,16 @@
    @Override
    public String test() {
        JCoDestination destination = connectionManager.getDestination();
        JCoFunction function = destination.getRepository().getFunction("ZPPF_022");
        JCoRepository repository = destination.getRepository();
        JCoFunction function = repository.getFunction("ZPPF_022");
        if (function == null) {
            throw new RuntimeException("RFC 函数模块 Z_GET_MATERIAL_INFO 未找到!");
            throw new RuntimeException("RFC 函数模块 ZPPF_022 未找到!");
        }
        // 设置输入参数
//        JCoParameterList input = function.getImportParameterList();
//        input.setValue("MATERIAL_ID", materialId); // 参数名需与 SAP 函数定义一致
//        function.getImportParameterList().setValue("MATERIAL_ID", 0);
        JCoParameterList input = function.getImportParameterList();
        input.setValue("ZTAB_WERKS", Collections.singletonList("2301")); //参数名需与 SAP 函数定义一致
        // 执行调用
        function.execute(destination);