From 9246a6db02ab22311e61019b55082cb1a1a02b6d Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期三, 18 六月 2025 09:53:34 +0800 Subject: [PATCH] art: SAP集成测试代码修改 --- src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java | 47 ++++++++++++++++++++++++++++------------------- 1 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java b/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java index 665b844..438131d 100644 --- a/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java +++ b/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,28 +16,40 @@ public class SAPServiceImpl implements SAPService { @Autowired private SapRfcConnectionManager connectionManager; - @SneakyThrows + @Override - public String test() { + public String test() { JCoDestination destination = connectionManager.getDestination(); - JCoRepository repository = destination.getRepository(); - JCoFunction function = repository.getFunction("ZPPF_022"); + try { + JCoRepository repository = destination.getRepository(); + JCoFunction function = repository.getFunction("ZPPF_022"); - if (function == null) { - throw new RuntimeException("RFC 鍑芥暟妯″潡 ZPPF_022 鏈壘鍒帮紒"); - } + if (function == null) { + throw new RuntimeException("RFC 鍑芥暟妯″潡 ZPPF_022 鏈壘鍒帮紒"); + } - // 璁剧疆杈撳叆鍙傛暟 - JCoParameterList input = function.getImportParameterList(); - input.setValue("ZTAB_WERKS", Collections.singletonList("2301")); //鍙傛暟鍚嶉渶涓� SAP 鍑芥暟瀹氫箟涓�鑷� + // 璁剧疆杈撳叆鍙傛暟 + JCoParameterList input = function.getImportParameterList(); + JCoTable inputTable = function.getTableParameterList().getTable("ZTAB_WERKS"); + inputTable.appendRow(); + inputTable.setValue("ZTAB_WERKS", "2301"); //鍙傛暟鍚嶉渶涓� SAP 鍑芥暟瀹氫箟涓�鑷� - // 鎵ц璋冪敤 - function.execute(destination); + // 鎵ц璋冪敤 + 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; } } -- Gitblit v1.9.3