on 08-04-2006 6:28 PM
Hi everybody!
Here is the little problem I'm getting, which I don't know how to solve it.
I've developed a J2EE application which connects via JCO BAPI_SALESORDER_GETLIST. I have no problem executing it, but the result I get is null.
I've executed that BAPI with same input parameters in the SAP System and I've found that this bapi loads two tables (or instances of the table) "SALES_ORDERS". The first one is empty and the second one has records.
In my code, I catch the table like this:
JCO.Table table = function.getParameterList().getTable("SALES_ORDERS");
but I'm thinking this code returns me the first one, which is empty...
Any idea about this???
Anyone knows how to catch the second one?
I'm starting with these technologies and, obviously, I'm not an expert in SAP
Thanks a lot in advance!
Alberto.
Hi,
You have to pass "CUSTOMER_NUMBER", "SALES_ORGANISATION" as compulsary import parameters to execute "BAPI_SALESORDER_GETLIST".
The returned output (RecordSet) contains "SALES_ORDERS" AS
internal table.
To read the data from "SALES_ORDERS" table...you need to check the following...
IRecordSet recSet = (IRecordSet) outputparam.get("SALES_ORDERS");
while(recSet.next())
{
res.write(recSet.getString("ITEM_NUMBER"));
res.write(recSet.getString("MATERIAL"));
res.write(recSet.getString("SHORT_TEXT"));
res.write(recSet.getString("DOC_DATE"));
res.write(recSet.getString("REQ_QTY"));
}
Before this,
1) you have to check whether you are getting connection or not.
2)whether you are passing input paramaeters correct or not.
Get back to me if any queries....
Hope this helps
Please Assign points to helpful answers
Regards,
Rama Raju
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rama, thanks for your answer.
Yes, I pass as input parameters "CUSTOMER_NUMBER" and "SALES_ORGANIZATION" and my program connects well to the sap system.
I read the output table "SALES_ORDERS" like this:
JCO.Table sales_orders = function.getTableParameterList().getTable("SALES_ORDERS");
//print results
if(sales_orders.getNumRows()>0){
do{
for(JCO.FieldIterator e = sales_orders.fields() ; e.hasMoreElements(); ){
JCO.Field field = e.nextField();
System.out.println(field.getName() + " " + field.getString());
}
}while(sales_orders.nextRow());
}
Is supposed that this code runs well, cause is code I've copied from a course.
The problem I think I have is that when I execute the Bapi in the SAP system with the same input parameters, in the output I can see that there are two instances of the table SALES_ORDERS loaded. The first one is empty and the second one has records. I suposse that my program is reading the first one... That's why I get no results...
I'd like to read the second one.
Any idea about this??
Thanks.
Alberto.
Hi Alberto,
I am able to read it from first sales_orders only.
Please try this program...
// Establish connection to R/3 System.
IConnection conn = null;
// Get the connection
try
{
IConnectorGatewayService cgSer = (IConnectorGatewayService)PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
ConnectionProperties cp = new
ConnectionProperties(req.getLocale(), req.getUser());
conn = cgSer.getConnection("yourr3sys", cp);
} catch(Exception e){
res.write("Error in connection" + e.getLocalizedMessage());
}
try
{
// Create an executable interaction interface
IInteraction ix = conn.createInteractionEx();
// Create an interaction spec
IInteractionSpec ispec = ix.getInteractionSpec();
//Set the interaction properties
ispec.setPropertyValue("Name", "BAPI_SALESORDER_GETLIST");
// Create a input record factory
RecordFactory rf = ix.getRecordFactory();
// Create a mapped input record
MappedRecord inputParam = rf.createMappedRecord("inputParam");
// Get the input parameters. Hard Coded values are passed
to test.
inputParam.put("CUSTOMER_NUMBER", "0000001000");
inputParam.put("SALES_ORGANIZATION", "1000");
// Create a mapped output record
MappedRecord outputParam =
(MappedRecord)ix.execute(ispec,inputParam);
IRecordSet recSet = (IRecordSet)outputParam.get("SALES_ORDERS");
while(recSet.next())
{
res.write(recSet.getString("ITM_NUMBER"));
res.write(recSet.getString("MATERIAL"));
res.write(recSet.getString("SHORT_TEXT"));
res.write(recSet.getString("DOC_DATE"));
res.write(recSet.getString("REQ_QTY"));
}
conn.close();
}
catch(ResourceException e){
res.write("Error in BAPI function execution" +
e.getLocalizedMessage());
}catch(Exception ex)
{
res.write("Error in BAPI function execution" + ex.getLocalizedMessage());
}
Help!, I need somebody.. 😛
I really don't know how to solve it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nobody knows anything about this???
With all input parameters I send I always get the first table empty...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Albert,
I will suggest you to use SAP Enterprise JCo rather then core JCo, that is much better to use and debug also.
Guru.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.