cancel
Showing results for 
Search instead for 
Did you mean: 

how to create sales order using JCO3

Former Member
0 Kudos

Hi I am working with JCO3.0 and i am unable to create sales order. Please help me to create sales order.

Exception in thread "main" com.sap.conn.jco.JCoRuntimeException: (127) JCO_ERROR_FIELD_NOT_FOUND: Field PO_ITM is not a member of BAPIITEMIN

  at com.sap.conn.jco.rt.AbstractMetaData.indexOf(AbstractMetaData.java:404)

  at com.sap.conn.jco.rt.AbstractRecord.setValue(AbstractRecord.java:3976)

  at org.sample.poc.PO.createSaleOrder(PO.java:65)

  at org.sample.poc.PO.main(PO.java:16)

Below is my program:


public static void createSaleOrder() throws JCoException
{
JCoDestination destination = JCoDestinationManager.getDestination("ABAP_AS_WITHOUT_POOL");
JCoFunction createSalesOrderFunction  = destination.getRepository().getFunction("BAPI_SALESORDER_CREATEFROMDAT1");
if(createSalesOrderFunction==null)
{
throw new RuntimeException("Cant create sale order it is null");
}
try {
createSalesOrderFunction.execute(destination);
} catch (Exception e) {
// TODO: handle exception
}
System.out.println("Import Parameter List" + createSalesOrderFunction.getImportParameterList());
System.out.println("Export Parameter List" + createSalesOrderFunction.getExportParameterList());
System.out.println("Table Structure" + createSalesOrderFunction.getTableParameterList());

//  Fill in Input Parameters
JCoParameterList inputParamaterList = createSalesOrderFunction.getImportParameterList();
JCoParameterList tableParameterList = createSalesOrderFunction.getTableParameterList();

// Get the Table
JCoTable orderItemsTable =   tableParameterList.getTable("ORDER_ITEMS_IN");

System.out.println(orderItemsTable);
orderItemsTable.appendRow();
orderItemsTable.setRow(1);
orderItemsTable.setValue("ITM_NU","000010");
orderItemsTable.setValue("PO_ITM","89786767757575");// can be changed
orderItemsTable.setValue("MATERIAL","3000");
orderItemsTable.setValue("CUST_MAT","7789012345678901234567");// can be changed
orderItemsTable.setValue("REQ_QTY","8901234567890");// can be changed Qty * 1000
try {
createSalesOrderFunction.execute(destination);
} catch (Exception e) {
// TODO: handle exception
}
// Print the Return Message
JCoStructure returnStructure = createSalesOrderFunction.getExportParameterList().getStructure("RETURN");
rintln("BAPI_SALES_ORDER_GETLIST RETURN: " + returnStructure.getString("MESSAGE"));
}
View Entire Topic
HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Utsav,

isn't the error message clear? :

Field PO_ITM is not a member of BAPIITEMIN

I just had a look into some SAP system containing the appropriate structures and indeed I do not see such a field name. Here available field names for table structure BAPIITEMIN are ITM_NUMBER or PO_ITM_NO. Please check your RFM interface for BAPI_SALESORDER_CREATEFROMDAT1 at back-end side (SE37) and correct your code accordingly.

Furthermore calling orderItemsTable.setRow(1) is unnecessary and incorrect. Please see the contained JCo JavaDoc at methods

JCoTable.appendRow()

JCoTable.setRow(int pos)

Best regards,
Stefan

Former Member
0 Kudos

thanks , i will do that i am using ECC system. Could you please let me know how can i print the response. How i can extract the response after calling execute bapi function.

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

JCoFunction.toXML() returns the whole function data as a (proprietary) XML string. This is also includes all results if called after execution.

If you prefer to work with separate objects for the RFC request and the RFC response you may also use the JCoRequest / JCoResponse model instead of using a JCoFunction. There is no advantage if using this model, it's just a personal preference and style.