我正在开发SAP JCo。设置日期'12.16.2016‘时出现异常
异常: com.sap.conn.jco.ConversionException:(122) JCO_ERROR_CONVERSION:无法在字段日期将'12.16.2016‘的值从类型java.lang.String转换为结构。
我的代码是
public static void YP_ECA_VIN(String date, String plant) throws Exception {
try {
JCoDestination destination;
JCoRepository sapRepository;
destination = JCoDestinationManager.getDestination(DST1);
JCoDestinationManager.getDestination(DST1);
JCoContext.begin(destination);
sapRepository = destination.getRepository();
if (sapRepository == null) {
System.out.println("Couldn't get repository!");
JCoContext.end(destination);
System.exit(0);
}
JCoFunctionTemplate template = sapRepository.getFunctionTemplate("YP_ECA_VIN");
if (template == null) {
System.out.println("Couldn't get template for YP_ECA_VIN!");
} else {
JCoFunction function = template.getFunction();
function.getImportParameterList().setValue("DATE", "12.16.2016");
function.getImportParameterList().setValue("PLANT", plant);
function.execute(destination);
int numTRows = 0;
int numTCoulmns = 0;
JCoTable table = function.getExportParameterList().getTable("OUTPUT");
// some code
}发布于 2016-12-23 14:04:27
JCO.Functions中的所有参数都应为字符串。尝试将日期值也设置为字符串。在SAP中,日期字符串的格式是"yyyyMMdd“,如"20161223”。
发布于 2016-12-24 17:27:25
名为DATE的RFM导入参数显然不是日期类型,而是结构类型。在这种情况下,您必须在JCo端使用JCoStructure实例,而不是字符串。
但是我更愿意假设您在ABAP端定义远程功能模块接口日期时犯了一个错误,并且您希望这个导入参数YP_ECA_VIN实际上是ABAP DATE类型。
https://stackoverflow.com/questions/41295925
复制相似问题