Skip to Content
0
Former Member
Sep 23, 2008 at 10:28 AM

problem while executing BAPI_PRODORD_GET_DETAIL through JAVA using JCo

411 Views

Hi All,

I am trying to get Production Order details in JAVA program using JCo. Following is the code I have written.

JCoDestination destination = JCoDestinationManager.getDestination(ABAP_AS); 

JCoFunction function = destination.getRepository().getFunction("BAPI_PRODORD_GET_DETAIL"); 
if(function == null) 
throw new RuntimeException("BAPI_PRODORD_GET_DETAIL not found in SAP."); 

function.getImportParameterList().setValue("NUMBER", 1067831); 

JCoStructure struct = com.sap.conn.jco.JCo.createStructure(destination.getRepository().getStructureDefinition("BAPI_PP_ORDER_OBJECTS")); 

struct.setValue("HEADER", 'Y'); 
struct.setValue("POSITIONS", 'Y'); 
struct.setValue("SEQUENCES", 'Y'); 
struct.setValue("OPERATIONS", 'Y'); 
struct.setValue("COMPONENTS", 'Y'); 
struct.setValue("PROD_REL_TOOLS", 'Y'); 
struct.setValue("TRIGGER_POINTS", 'Y'); 

function.getImportParameterList().setValue("ORDER_OBJECTS", struct); 
function.getImportParameterList().setValue("COLLECTIVE_ORDER",'Y'); 


try 
{ 
function.execute(destination); 
} 
catch(AbapException e) 
{ 
System.out.println(e.toString()); 
return; 
} 
JCoStructure returnStructure = function.getExportParameterList().getStructure("RETURN"); 
if (! (returnStructure.getString("TYPE").equals("") || 
   returnStructure.getString("TYPE").equals("S") || 
   returnStructure.getString("TYPE").equals("W")) ) 
{ 
System.out.println(returnStructure.getString("MESSAGE")); 

} 

JCoTable codes = function.getTableParameterList().getTable("HEADER"); 
int iCnt = codes.getNumRows(); 
System.out.println("No Of Rows " + iCnt); 
int iFldCnt = codes.getNumColumns(); 
JCoMetaData codesMD = codes.getMetaData(); 
for (int i = 0; i < codes.getNumRows(); i++) 
{ 
codes.setRow(i); 

// Display the data 

}

The number which I am passing is a valid production order. When I test this BAPI in SAP gui with same input, it gives back the data but when I try to run this through java I always get the return message as this production order does not exist. Is there anything wrong I am doing?

I am using JCo 3.0

I have tried passing various values to ORDER_HEADER structure. I have tried getting the structure from import parameter list and then setting the values on that itself. Nothing has worked for me.

Thanks,

Dayanand