我正在使用以下代码调用 BAPI BAPI_SALESORDER_CREATEFROMDAT2 来创建销售订单。SAP 机器正在生成一个 SO 编号并作为响应发送,但是当我使用 va03 检查我收到的销售订单的 SO 编号时,没有创建。如果我手动使用具有相同数据的 va01,我可以成功创建销售订单。请在这方面需要帮助。
public static void createSalesOrder() {
try {
JCoDestination destination = JCoDestinationManager.getDestination("ABAP_AS_WITH_POOL");
JCoFunction functionCreateOrder = destination.getRepository().getFunction("BAPI_SALESORDER_CREATEFROMDAT2");
//this is the bapi
JCoFunction functionTransComit = destination.getRepository().getFunction("BAPI_TRANSACTION_COMMIT");
JCoStructure orderHeaderIn = functionCreateOrder.getImportParameterList().getStructure("ORDER_HEADER_IN");
orderHeaderIn.setValue("SALES_ORG", "2000");//sales organisation
orderHeaderIn.setValue("DISTR_CHAN", "20");//distribution channel
orderHeaderIn.setValue("DIVISION", "20");// sales division
orderHeaderIn.setValue("DOC_TYPE", "ZAR");// document type
orderHeaderIn.setValue("PURCH_NO_C", "TEST123");
JCoTable orderPartners = functionCreateOrder.getTableParameterList().getTable("ORDER_PARTNERS");
// WE,AG,SP,PH
// AG Sold to Party
// WE Ship to Partyx
orderPartners.appendRow();
orderPartners.setValue("PARTN_ROLE", "AG");//partner role ag is sold to party
orderPartners.setValue("PARTN_NUMB", "0000000035");// partner number
orderPartners.appendRow();
orderPartners.setValue("PARTN_ROLE", "WE");//we is ship tp party
orderPartners.setValue("PARTN_NUMB", "0000000035");// partner number
System.out.println(orderPartners);
JCoTable orderItemsIn = functionCreateOrder.getTableParameterList().getTable("ORDER_ITEMS_IN");
orderItemsIn.appendRow();
orderItemsIn.setValue("MATERIAL", "PEN_ARN");// material
System.out.println(orderItemsIn);
JCoTable orderSchedulesIn = functionCreateOrder.getTableParameterList().getTable("ORDER_SCHEDULES_IN");
orderSchedulesIn.appendRow();
orderSchedulesIn.setValue("REQ_QTY", "10");// required quantity
System.out.println(orderSchedulesIn);
functionCreateOrder.execute(destination);
// System.out.println(functionCreateOrder);
JCoTable returnTable = functionCreateOrder.getTableParameterList().getTable("RETURN");
System.out.println(returnTable);
System.out.println(returnTable.getString("MESSAGE"));
System.out.println("sales order number is : "
+ functionCreateOrder.getExportParameterList().getValue("SALESDOCUMENT"));
functionTransComit.execute(destination);
} catch (JCoException ex) {
System.out.println(ex.getMessage());
} finally {
System.out.println("Creating sales order ends");
}
}