Error while creating sales order using JCO with BAPI_SALESORDER_CREATEFROMDAT2

我的梦境 提交于 2020-01-17 05:05:05

问题


I am trying to create a sales order using BAPI_SALESORDER_CREATEFROMDAT2 butI am getting error “No customer master record exists for customer 99” when I tried to create a sales order for customer 99(example) with the partner Role ‘AG’,’WE’ where both ‘sold-to-party and ship-to-party’ are mandatory fields. If I send “SP” it will ask me to define ‘sold-to-party and ship-to-party’ ,Please let me know if I have to send some different partner roles to be able to create a sales order.

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");
    }

}

回答1:


Issue was with the partner number , adding 000000000 leading the partner number will solve the issue .



来源:https://stackoverflow.com/questions/32133170/error-while-creating-sales-order-using-jco-with-bapi-salesorder-createfromdat2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!