zhangherong
2025-06-18 9246a6db02ab22311e61019b55082cb1a1a02b6d
art: SAP集成测试代码修改
已修改1个文件
25 ■■■■■ 文件已修改
src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java
@@ -1,9 +1,6 @@
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 com.sap.conn.jco.JCoRepository;
import com.sap.conn.jco.*;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.config.sap.SapRfcConnectionManager;
@@ -19,10 +16,11 @@
public class SAPServiceImpl implements SAPService {
    @Autowired
    private SapRfcConnectionManager connectionManager;
    @SneakyThrows
    @Override
    public String test() {
        JCoDestination destination = connectionManager.getDestination();
        try {
        JCoRepository repository = destination.getRepository();
        JCoFunction function = repository.getFunction("ZPPF_022");
@@ -32,15 +30,26 @@
        // 设置输入参数
        JCoParameterList input = function.getImportParameterList();
        input.setValue("ZTAB_WERKS", Collections.singletonList("2301")); //参数名需与 SAP 函数定义一致
            JCoTable inputTable = function.getTableParameterList().getTable("ZTAB_WERKS");
            inputTable.appendRow();
            inputTable.setValue("ZTAB_WERKS", "2301"); //参数名需与 SAP 函数定义一致
        // 执行调用
        function.execute(destination);
        // 获取输出参数
        JCoParameterList output = function.getExportParameterList();
            JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_AUFNR");
            int numRows = outputTable.getNumRows();
            for (int i = 0; i < numRows; i++) {
                outputTable.setRow(i);
                log.info("Row {} : {}", i, outputTable.getString("AUFNR"));
            }
//        String materialName = output.getString("MATERIAL_NAME"); // 参数名需与 SAP 函数定义一致
        return "";
            return String.valueOf(numRows);
        } catch (JCoException e) {
            log.error(e.getMessage(), e);
        }
        return null;
    }
}