I am working on SAP JCo and getting exception while setting date 12.16.2016
:
com.sap.conn.jco.ConversionException: (122) JCO_ERROR_CONVERSION: Cannot convert a value of '12.16.2016' from type java.lang.String to STRUCTURE at field DATE.
My code is
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
}
All parameters in JCO.Functions should be strings. Try to set date-values as strings too. In SAP the format for date-strings is "yyyyMMdd" like "20161223".