0
我使用SAPJCo3.jar for Java来树液的连接和通信,但是当执行程序时,得到错误在JcoStructure part.Debugger成功传递给功能模块连接部我看到在调试器但在这种行,我得到有趣的错误:JCO_CONVERTION_ERROR(122),以表型StructureRecord
JCoStructure returnStructure = function.getExportParameterList().getStructure("ET_CUSTOMERS");
,当运行程序我得到这个exeption:
Exception in thread "main" com.sap.conn.jco.ConversionException: (122) JCO_ERROR_CONVERSION: Cannot convert field ET_CUSTOMERS of type TABLE to StructureRecord
at com.sap.conn.jco.rt.AbstractRecord.createConversionException(AbstractRecord.java:416)
at com.sap.conn.jco.rt.AbstractRecord.createConversionException(AbstractRecord.java:411)
at com.sap.conn.jco.rt.AbstractRecord.getStructure(AbstractRecord.java:2585)
at com.sap.conn.jco.rt.AbstractRecord.getStructure(AbstractRecord.java:3060)
at com.sap.conn.jco.rt.AbstractRecord.getStructure(AbstractRecord.java:53)
at SAP.GetCustomers.step4WorkWithTable(GetCustomers.java:100)
at SAP.Main.main(Main.java:13)
这是我的函数的完整代码:
public static void step4WorkWithTable() throws JCoException
{
JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME2);
JCoFunction function = destination.getRepository().getFunction("Z_SYCLO1_GET_CUSTOMERS");
if(function == null)
throw new RuntimeException("Z_SYCLO1_GET_CUSTOMERS not found in SAP.");
JCoStructure returnStructure = function.getExportParameterList().getStructure("ET_CUSTOMERS");
if (! (returnStructure.getString("TYPE").equals("")||returnStructure.getString("TYPE").equals("S")))
{
throw new RuntimeException(returnStructure.getString("MESSAGE"));
}
JCoTable codes = function.getTableParameterList().getTable("Z_SYCLO1_CUSTOMERS_LIST_TT");
for (int i = 0; i < codes.getNumRows(); i++)
{
codes.setRow(i);
System.out.println(codes.getString("KUNNR") + '\t' +
codes.getString("NAME1") + '\t' +
codes.getString("NAME2") + '\t' +
codes.getString("TELF1") + '\t' +
codes.getString("STRAS") + '\t' +
codes.getString("ORT01") + '\t' +
codes.getString("REGIO") + '\t' +
codes.getString("PSTLZ") + '\t' +
codes.getString("LAND1"));
}
codes.firstRow();
for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow())
{
function = destination.getRepository().getFunction("Z_SYCLO1_GET_CUSTOMERS");
if (function == null)
throw new RuntimeException("Z_SYCLO1_GET_CUSTOMERS not found in SAP.");
function.getImportParameterList().setValue("IV_USERNAME", codes.getString("UOZKER"));
function.getExportParameterList().setActive("ET_CUSTOMERS",false);
try
{
function.execute(destination);
}
catch (AbapException e)
{
System.out.println(e.toString());
return;
}
returnStructure = function.getExportParameterList().getStructure("ET_CUSTOMERS");
if (! (returnStructure.getString("TYPE").equals("") ||
returnStructure.getString("TYPE").equals("S") ||
returnStructure.getString("TYPE").equals("W")))
{
throw new RuntimeException(returnStructure.getString("MESSAGE"));
}
JCoStructure detail = function.getExportParameterList().getStructure("ET_CUSTOMERS");
System.out.println(codes.getString("KUNNR") + '\t' +
codes.getString("NAME1") + '\t' +
codes.getString("NAME2") + '\t' +
codes.getString("TELF1") + '\t' +
codes.getString("STRAS") + '\t' +
codes.getString("ORT01") + '\t' +
codes.getString("REGIO") + '\t' +
codes.getString("PSTLZ") + '\t' +
codes.getString("LAND1"));
}
ET_CUSTOMER是我的功能模块的输出参数名称和其相关的类型等于我structure.i认为这不是一个表,它的类型向我们展示当地structure.sir,请告诉我,这是真的还是假的? – user2583486
我添加引用,并改变我的参数名ET_Customers给客户,但我不能让我的结果,任何改变 – user2583486
你将不得不整个功能模块签名添加到您的问题,如果您希望我们想出解决办法... – vwegert