我正在尝试使用 JCO3 创建采购订单。我能够在没有任何错误的情况下执行我的函数,但我不确定什么是错误的系统没有抛出任何错误,并且它也没有在 SAP 系统中创建 PO。
JCoDestination destination = JCoDestinationManager.getDestination("ABAP_AS_WITHOUT_POOL");
JCoFunction createPurchaseOrderFunction = destination.getRepository().getFunction("BAPI_PO_CREATE1");
JCoFunction functionTransactionCommit = destination.getRepository().getFunction("BAPI_TRANSACTION_COMMIT");
// Input Header
JCoStructure poOrderHeader = createPurchaseOrderFunction.getImportParameterList().getStructure("POHEADER");
System.out.println("Header Structure" + poOrderHeader);
poOrderHeader.setValue("COMP_CODE", "0001");
poOrderHeader.setValue("DOC_TYPE", "NB");
//Date today = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
//String date = dateFormat.format(today);
String dateinString = "20.08.2015";
Date date = dateFormat.parse(dateinString);
System.out.println("Date is: " + date);
poOrderHeader.setValue("CREAT_DATE",date);
poOrderHeader.setValue("VENDOR", "V544100170");
poOrderHeader.setValue("LANGU", "EN");
poOrderHeader.setValue("PURCH_ORG", "0005");
poOrderHeader.setValue("PUR_GROUP", "001");
poOrderHeader.setValue("CURRENCY", "INR");
// PO Items
JCoTable poItems = createPurchaseOrderFunction.getTableParameterList().getTable("POITEM");
poItems.appendRow();
poItems.setValue("PO_ITEM", "1");
poItems.setValue("MATERIAL", "ZZMT_TEST2");
poItems.setValue("PLANT", "Z111");
poItems.setValue("QUANTITY", "100");
poItems.setValue("NET_PRICE", "150");
try
{
JCoContext.begin(destination);
createPurchaseOrderFunction.execute(destination);
functionTransactionCommit.execute(destination);
functionTransactionCommit.getImportParameterList().setValue("WAIT", 10);
JCoContext.end(destination);
}
catch(Exception e)
{
throw e;
}
// Print the Return Structure Message
// JCoStructure returnStructure = createPurchaseOrderFunction.getExportParameterList().getStructure("RETURN");
// if (! (returnStructure.getString("TYPE").equals("")||returnStructure.getString("TYPE").equals("S")) )
// {
// throw new RuntimeException(returnStructure.getString("MESSAGE"));
// }
JCoTable table = createPurchaseOrderFunction.getTableParameterList().getTable("POITEM");
// Iterate over table and print JCOFiled
for(JCoField field : table)
{
System.out.println("Name: "+field.getName() + "----" + "Value:" + field.getValue());
System.out.println("------------------------------------------------------------------");
}
System.out.println("---------------------------------------------------------------------------------");
System.out.println("Table" + table);