on 04-25-2006 4:43 AM
Hi
I am trying to retreive rows from BAPI_SALESORDER_GETLIST using JSPDynpage. But it does not give me any records. I am quite skeptical about the way i am trying to retreive MATERIAL and BATCH number.
When i look at the log it gives me a type as "com.sapportals.connectors.SAPCFConnector.execution.structures.RecordSetWrapper@84918" for the statement ->
Object result = output.get("SALES_ORDERS");
The flow is not just geting into my While Loop.
Object rs = null;
IRecordSet exportTable = null;
Object result = output.get("SALES_ORDERS");
if ( result == null ) {
rs = new String(" ");
}
else if (result instanceof IRecordSet) {
exportTable = (IRecordSet) result;
exportTable.beforeFirst();
// Moves the cursor before the first row.
while (exportTable.next()) {
String column_1 = exportTable.getString("MATERIAL");
String column_2 = exportTable.getString("BATCH");
}
}
//create the tableview mode in the bean
myBean.createData(exportTable);
client.close();
Below is the source Code for My Bean :
public void createData(IRecordSet table) {
//this is your column names
Vector column = new Vector();
column.addElement("Material");
column.addElement("Batch");
//all this logic is for the data part.
Vector rVector = new Vector();
try {
table.beforeFirst();
while (table.next()) {
Vector data = new Vector();
data.addElement(table.getString("MATERIAL"));
data.addElement(table.getString("BATCH"));
rVector.addElement(data);
} } catch (Exception e) {
e.printStackTrace();
}
Suggestions are welcome.
Murali.
Hi Murali,
Can you please check the code before the output.get("SALES_ORDERS");
Because it could be that output does not have any records and there could be problem with the RFC or the input values you are passing.
So please check the connection is happening.
Post the Code from the connection so that the problem can be solved.
Regards,
Padmaja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is my Code:
package com.training.test;
import javax.resource.cci.MappedRecord;
import javax.resource.cci.RecordFactory;
import com.sapportals.htmlb.event.Event;
import com.sap.tc.logging.FileLog;
import com.sap.tc.logging.Location;
import com.sap.tc.logging.Severity;
import com.sapportals.connector.ConnectorException;
import com.sapportals.connector.connection.IConnection;
import com.sapportals.connector.connection.IConnectionFactory;
import com.sapportals.connector.execution.functions.IInteraction;
import com.sapportals.connector.execution.functions.IInteractionSpec;
import com.sapportals.connector.execution.structures.IRecord;
import com.sapportals.connector.execution.structures.IRecordSet;
import com.sapportals.connector.metadata.functions.IFunction;
import com.sapportals.connector.metadata.functions.IFunctionsMetaData;
import com.sapportals.htmlb.event.TableNavigationEvent;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.JSPDynPage;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
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.IPortalComponentProfile;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.runtime.PortalRuntime;
public class Display extends PageProcessorComponent {
public DynPage getPage() {
return new DisplayDynPage();
}
public static class DisplayDynPage extends JSPDynPage {
private int visibleRow;
private static Location myLoc =
Location.getLocation("com.training.test.Display");
private TableBean myBean = null;
public void doInitialization() {
visibleRow = 1;
IPortalComponentProfile profile =
((IPortalComponentRequest) getRequest())
.getComponentContext()
.getProfile();
Object o = profile.getValue("myBean");
if (o == null || !(o instanceof TableBean)) {
myBean = new TableBean();
profile.putValue("myBean", myBean);
} else {
myBean = (TableBean) o;
}
// fill your bean with data here...
IPortalComponentRequest request =
(IPortalComponentRequest) this.getRequest();
doJca(request);
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
this.setJspName("Sales.jsp");
}
private IConnection getConnection(
IPortalComponentRequest request,
String alias)
throws Exception {
IConnectorGatewayService cgService =
(IConnectorGatewayService) PortalRuntime
.getRuntimeResources()
.getService(
IConnectorService.KEY);
ConnectionProperties prop =
new ConnectionProperties(
request.getLocale(),
request.getUser());
myLoc.entering("method - murli locale" + request.getLocale());
myLoc.entering("method - bored User" + request.getUser());
return cgService.getConnection("ECC", prop);
}
public void doJca(IPortalComponentRequest request) {
IConnectionFactory connectionFactory = null;
IConnection client = null;
String rfm_name = "BAPI_SALESORDER_GETLIST";
try {
try {
client = getConnection(request, "ECC");
} catch (Exception e) {
return;
}
/* * Start Interaction * */
IInteraction interaction = client.createInteractionEx();
IInteractionSpec interactionSpec =
interaction.getInteractionSpec();
interactionSpec.setPropertyValue("Name", rfm_name);
/* * CCI api only has one datatype: Record * */
RecordFactory recordFactory = interaction.getRecordFactory();
MappedRecord importParams =
recordFactory.createMappedRecord(
"CONTAINER_OF_IMPORT_PARAMS");
IFunctionsMetaData functionsMetaData =
client.getFunctionsMetaData();
IFunction function = functionsMetaData.getFunction(rfm_name);
if (function == null) {
System.out.println(
"Couldn't find " + rfm_name + " in a target system.");
return;
}
/* * How to invoke Function modules * */
System.out.println("Invoking... " + function.getName());
importParams.put("CUSTOMER_NUMBER", "1000");
importParams.put("SALES_ORGANIZATION", "1000");
MappedRecord output =
(MappedRecord) interaction.execute(
interactionSpec,
importParams);
/* * How to get structure values * */
// IRecord exportStructure = (IRecord) exportParams.get("RETURN");
// String columnOne = exportStructure.getString("TYPE");
// String columnTwo = exportStructure.getString("CODE");
// String columnThree = exportStructure.getString("MESSAGE");
// System.out.println(" RETURN-TYPE = " + columnOne);
// System.out.println(" RETURN-CODE = " + columnTwo);
// System.out.println(" RETURN-MESSAGE =" + columnThree);
/* * How to get table values * */
//IRecordSet exportTable = null;
Object rs = null;
IRecordSet exportTable = null;
Object result = output.get("SALES_ORDERS");
if ( result == null ) {
rs = new String(" ");
}
else if (result instanceof IRecordSet) {
exportTable = (IRecordSet) result;
exportTable.beforeFirst();
// Moves the cursor before the first row.
while (exportTable.next()) {
String column_1 = exportTable.getString("MATERIAL");
String column_2 = exportTable.getString("BATCH");
}
}
//create the tableview mode in the bean
myBean.createData(exportTable);
/* * Closing the connection * */
client.close();
} catch (ConnectorException e) {
//app.putValue("error", e);
System.out.println("Caught an exception: \n" + e);
} catch (Exception e) {
System.out.println("Caught an exception: \n" + e);
}
} //doJCA Over
} //DisplayDynPage Over
}
When i debugged the code, this was what i got for the variable 'result' :
result= RecordSetWrapper (id=17493)
m_current_row= 0
m_mc= null
m_mc= SAPCFConnectorManagedConnection (id=17500)
locale= Locale (id=17503)
logged_user= null
m_associatedConnections= LinkedList (id=17504)
m_connHash= "tpnameValidateAlivefalsesap.backend.userJ2EE_ADMINlogonmethodSAPLOGONTICKETsnc_mode0SystemTypeSAP_R3gwhostclient800ashost10.6.4.251Languagesnc_qop0sysnr00gwservtrace0snc_libsnc_mynamesnc_partnernametphost"
m_converstionsValuesRepoditory= null
m_eventListeners= Vector (id=17506)
m_initialized= true
m_jcoClient= JCO$Client (id=17507)
m_jcoProperties= SAPCFConnectorConnectionSpec (id=17508)
m_jcoRepository= JCO$Repository (id=17513)
m_logWriter= null
m_managedConnectionFactory= SAPCFConnectorManagedConnectionFactory (id=17514)
m_properties= SAPCFConnectorConnectionSpec (id=17515)
mm_jcoDatabase= JcoR3MetaDatabase (id=17516)
mm_mdiObjectFactory= null
resourceBundle= PropertyResourceBundle (id=17519)
m_record= null
m_table= JCO$Table (id=17502)
blength= int[49] (id=17520)
boffset= int[49] (id=17521)
data= char[0] (id=17522)
decimals= byte[49] (id=17523)
defaults= String[49] (id=17524)
delta= null
description= String[49] (id=17525)
extended_field_meta_data= null
flags= byte[49] (id=17526)
hash_of_indices= null
last_active_timestamp= 0
length= int[49] (id=17527)
modified= false
name= String[49] (id=17528)
num_fields= 49
num_init_rows= 0
num_odata= 0
num_rows= 0
odata= Object[0] (id=17529)
offset= int[49] (id=17530)
oindex= byte[49] (id=17531)
opcode= byte[0] (id=17532)
rec_name= "BAPIORDERS"
rec_type= 4
row= 0
row_capacity= 0
row_capacity_increment= 0
row_length= 0
tab_length= 456
tab_meta= Object[49] (id=17534)
table_data_rows= null
template_data= null
template_odata= null
type= byte[49] (id=17535)
type1_data= null
type1_record= null
type_handle= 0
type_name= null
unicode_type= 4
Hi
Managed to find the bug !!! Instead of passing parameter values as
importParams.put("CUSTOMER_NUMBER", "1000");
importParams.put("SALES_ORGANIZATION", "1000");
It should have been as below :
importParams.put("CUSTOMER_NUMBER","0000001001");
importParams.put("SALES_ORGANIZATION", "1000");
Murali.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.