我正在尝试使用BAPI_SALESORDER_CREATEFROMDAT2创建销售订单,但当我尝试使用合作伙伴Role'AG'创建客户99(示例)的销售订单时,我收到错误“客户99没有客户主记录”我们'卖方派对和派对派对'都是强制性领域。 如果我发送“SP”,它会要求我定义'售达方和派对方',如果我必须发送一些不同的合作伙伴角色以便能够创建销售订单,请告诉我。
public static void createSalesOrder() {
try {
JCoDestination destination = JCoDestinationManager.getDestination("ABAP_AS_WITH_POOL");
JCoFunction functionCreateOrder = destination.getRepository().getFunction("BAPI_SALESORDER_CREATEFROMDAT2");
JCoFunction functionTransComit = destination.getRepository().getFunction("BAPI_TRANSACTION_COMMIT");
JCoStructure orderHeaderIn = functionCreateOrder.getImportParameterList().getStructure("ORDER_HEADER_IN");
orderHeaderIn.setValue("SALES_ORG", "2000");
orderHeaderIn.setValue("DISTR_CHAN", "20");
orderHeaderIn.setValue("DIVISION", "20");
orderHeaderIn.setValue("DOC_TYPE", "ZAR");
JCoTable orderPartners = functionCreateOrder.getTableParameterList().getTable("ORDER_PARTNERS");
// WE,AG,SP,PH
// AG Sold to Party
// WE Ship to Party
orderPartners.appendRows(1);
orderPartners.setValue("PARTN_ROLE", "AG");
orderPartners.setValue("PARTN_NUMB", "99");
orderPartners.appendRows(1);
orderPartners.setValue("PARTN_ROLE", "WE");
orderPartners.setValue("PARTN_NUMB", "99");
System.out.println(orderPartners);
JCoTable orderItemsIn = functionCreateOrder.getTableParameterList().getTable("ORDER_ITEMS_IN");
orderItemsIn.appendRow();
orderItemsIn.setValue("MATERIAL", "PEN_ARN");
System.out.println(orderItemsIn);
JCoTable orderSchedulesIn = functionCreateOrder.getTableParameterList().getTable("ORDER_SCHEDULES_IN");
orderSchedulesIn.appendRow();
orderSchedulesIn.setValue("REQ_QTY", "1");
System.out.println(orderSchedulesIn);
functionCreateOrder.execute(destination);
functionTransComit.execute(destination);
// System.out.println(functionCreateOrder);
JCoTable returnTable = functionCreateOrder.getTableParameterList().getTable("RETURN");
System.out.println(returnTable.getString("MESSAGE"));
System.out.println("sales order number is : "
+ functionCreateOrder.getExportParameterList().getValue("SALESDOCUMENT"));
} catch (JCoException ex) {
System.out.println(ex.getMessage());
} finally {
System.out.println("Creating sales order ends");
}
}
答案 0 :(得分:0)
问题在于合作伙伴编号,添加000000000领先合作伙伴编号将解决问题。