on 04-20-2006 9:15 AM
Hello everyone!
I am having problems retrieveing a result from r/3 using Connector Framework API. An ABAP consultant has created a ABAP program which returns an employee based on his or her personal number as an input.
<b>When i run the AbstractPortalComponent i get the following:
<u>RS2: com.sapportals.connectors.SAPCFConnector.execution.structures.RecordSetWrapper@24648563</u></b>
My code is as follows:
package com.sap.test;
import java.util.ArrayList;
import java.util.Iterator;
import javax.resource.cci.MappedRecord;
import javax.resource.cci.RecordFactory;
import com.sap.security.api.IUser;
import com.sapportals.connector.connection.IConnection;
import com.sapportals.connector.execution.functions.IInteraction;
import com.sapportals.connector.execution.functions.IInteractionSpec;
import com.sapportals.connector.execution.structures.IRecordSet;
import com.sapportals.connector.execution.structures.IStructureFactory;
import com.sapportals.connector.metadata.functions.IFunction;
import com.sapportals.portal.ivs.cg.ConnectionProperties;
import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
import com.sapportals.portal.ivs.cg.IConnectorService;
import com.sapportals.portal.prt.component.*;
import com.sapportals.portal.prt.runtime.PortalRuntime;
public class Search extends AbstractPortalComponent{
String sapSystem = "*****";
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response){
IConnection con = null;
ConnectionProperties conprop = null;
ConnectionProperties cp = null;
try{
Object connectorService = PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
IConnectorGatewayService cgService = (IConnectorGatewayService) connectorService;
cp = new ConnectionProperties(request.getLocale(),request.getUser());
if(cgService == null){
response.write("Error in getting Connector Gateway Service <br>");
}
try{
con = cgService.getConnection(sapSystem, cp);
IInteraction ix = con.createInteractionEx();
IInteractionSpec ixSpec = ix.getInteractionSpec();
ixSpec.setPropertyValue("Name", "Test_RFC");
RecordFactory rf = ix.getRecordFactory();
MappedRecord importParams = rf.createMappedRecord("INPUT");
IFunction function = con.getFunctionsMetaData().getFunction("Test_RFC");
IStructureFactory structureFactory = ix.retrieveStructureFactory();
IRecordSet table = (IRecordSet) structureFactory.getStructure(function.getParameter("I_PA0002").getStructure());
importParams.put("PERNR", "123456");
MappedRecord output = (MappedRecord) ix.execute(ixSpec,importParams);
Object rs = null;
try{
Object result = output.get("I_PA0002");
if(result == null){
rs = new String ("Error");
response.write("RS1: " +rs+ "<BR>");
}
else
if(result instanceof IRecordSet){
rs = (IRecordSet) result;
response.write("RS2: " +rs+ "<BR>");
}
else{
response.write("RS3: " +rs+ "<BR>");
}
}
catch(Exception e){
response.write("Error " + e.getMessage()+ "<BR>");
}
}
catch(Exception e){
response.write("Connection to SAP system failed <br>");
}
if(con == null){
response.write("Connection is null <br>");
}
else{
response.write("Connection succsesful<BR>");
}
}
catch(Exception e){
response.write("Exception occured<BR>");
}
try{
con.close();
response.write("Connection closed<br>");
}
catch(Exception e){
response.write("Could NOT close connection<BR>");
}
}
}
The result should be all data stored on the person which I search for, but instead i get the following result:
<b>
RS2: com.sapportals.connectors.SAPCFConnector.execution.structures.RecordSetWrapper@24648563</b>
I am really stuck and do not know how to solve the problem. I appreciate any help or sample (or just some answers...)
Thanks in Advance.
Best Regards,
Ola Aarthun
Hi,
From your code you are just displaying the object rs. You have to handle the display of each record the way you want it(as a table).
You can find a sample code how to build a table from the result object at the following link
Regards,
Padmaja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
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.