on 2005 Jul 06 8:09 AM
Hi all,
I want to create simple tableView in. Can anybody please give me some code for doing the same. I have tried making tableView from the examples posted on SDN by prakash and other.
But could not get the result.
SDN gurus, Please help me.
Regards
Pravesh
Request clarification before answering.
Hi Pravesh,
If you haven't already done so, try the following link:
<b>http://help.sap.com/saphelp_nw04/helpdata/en/eb/220a415a47f06fe10000000a1550b0/frameset.htm</b>
It explains about creating a tableview.
Hope this helps you.
Ranjith
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ranjith,
Thanks for the reply. But dear I have already gone through this link. If you have created a simple table then can you post that code to me, here in this post.
Actually I want to create a table and then fill the table enteries with the result from a BAPI.
Looking for some solutions.
Regards
Pravesh
Hi Prakash,
First of all thanks for the reply. I have posted my query some time back also. I was looking for your reply there as well.
Anyways, We have created a BAPI here so I dont think that it will work there.
So just show me the way How I will get the result from the BAPI in the table. You can use the sample BAPI -- BAPI_COMPANYCODE_GETLIST.
And please give me your email ID as well. I have mailed you earlier on the emial ID you have mentioned on your business Card but it bounced back.
Thanks and regards,
Pravesh
Hi Pravesh,
Your solution is following.
<b>JSPDynpage Component:</b>
package com.ust.jcatotable;
import javax.naming.Context;
import javax.resource.cci.MappedRecord;
import javax.resource.cci.RecordFactory;
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.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 TableBean myBean = null;
public void doInitialization(){
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("display.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());
return cgService.getConnection(alias, prop);
}
public void doJca(IPortalComponentRequest request) {
IConnectionFactory connectionFactory = null;
IConnection client = null;
String rfm_name = "BAPI_COMPANYCODE_GETLIST";
try {
try {
//pass the request & system alias
//Change the alias to whatever the alias is for your R/3 system
client = getConnection(request, "R3IDES");
} catch (Exception e) {
System.out.println(
"Couldn't establish a connection with a target system.");
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());
MappedRecord exportParams = (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 = (IRecordSet) exportParams.get("COMPANYCODE_LIST");
exportTable.beforeFirst(); // Moves the cursor before the first row.
while (exportTable.next()) {
String column_1 = exportTable.getString("COMP_CODE");
String column_2 = exportTable.getString("COMP_NAME");
System.out.println(" COMPANYCODE_LIST-COMP_CODE = " + column_1);
System.out.println(" COMPANYCODE_LIST-COMP_NAME = " + column_2);
}
//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);
}
}
}
}
<b>Bean</b>
package com.ust.jcatotable;
import java.io.Serializable;
import java.util.Vector;
import com.sapportals.connector.execution.structures.IRecordSet;
import com.sapportals.htmlb.table.DefaultTableViewModel;
import com.sapportals.htmlb.table.TableViewModel;
public class TableBean implements Serializable {
public DefaultTableViewModel model;
public TableViewModel getModel() {
return this.model;
}
public void setModel(DefaultTableViewModel model) {
this.model = model;
}
public void createData(IRecordSet table) {
//this is your column names
Vector column = new Vector();
column.addElement("Company Code");
column.addElement("Company Name");
//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("COMP_CODE"));
data.addElement(table.getString("COMP_NAME"));
rVector.addElement(data);
}
} catch (Exception e) {
e.printStackTrace();
}
//this is where you create the model
this.setModel(new DefaultTableViewModel(rVector, column));
}
}
<b>JSP Page:</b>
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="application" class="com.ust.jcatotable.TableBean" />
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId" >
<hbj:tableView
id="myTableView1"
model="myBean.model"
design="ALTERNATING"
headerVisible="true"
footerVisible="true"
fillUpEmptyRows="true"
navigationMode="BYLINE"
selectionMode="MULTISELECT"
headerText="TableView example 1"
onNavigate="myOnNavigate"
visibleFirstRow="1"
visibleRowCount="30"
width="500 px"
/>
</hbj:form>
</hbj:page>
</hbj:content>
<b>Portalapp.xml</b>
<?xml version="1.0" encoding="utf-8"?>
<application>
<application-config>
<property name="PrivateSharingReference" value="com.sap.portal.htmlb,com.sap.portal.ivs.connectorservice"/>
</application-config>
<components>
<component name="Display">
<component-config>
<property name="ClassName" value="com.ust.jcatotable.Display"/>
<property name="SecurityZone" value="com.ust.jcatotable.Display/low_safety"/>
</component-config>
<component-profile>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile>
</component>
</components>
<services/>
</application>
Message was edited by: Prakash Singh
Hi prakash,
Dear actually I was trying your code but it was not working.. Initially i thought that few jars were missing. I included 2 jars in the project..
1)GenericConnector.jar
2)com.sap.portal.ivs.connectorserviceapi.jar
even then there is error. Its not even compiling.
Please refer to the code..
Here you have include two things in <b>Display.java</b>
<b>import javax.resource.cci.MappedRecord;
import javax.resource.cci.RecordFactory;</b>
where to get this jar from and whats the use of this?? I dont have this jar. Please mail me this jar as well.
Both the Bean and JspDynpage is having the error in the 1st line itself.
Moreover in <b>TableBean.java</b> if I comment the following lines the error from <b>TableBean.java</b> is removed.
<b>table.beforeFirst();
while (table.next()) {
Vector data = new Vector();
data.addElement(table.getString("COMP_CODE"));
data.addElement(table.getString("COMP_NAME"));
rVector.addElement(data);
}</b>
I am not getting now what to do next. I was trying to run this code thats why there is delay in awarding you the points.. Anyways I have done that.
But still the issue is not resolved please help me.
Regards
Pravesh
Hi prakash,
Thanks, I recieved the jars. Can you please let me know the use of these jars.
Also after including these jars in my project a runtime error has occured.
<b>An exception occurred while processing a request for :
iView : pcd:portal_content/com.hcl.FLD001/com.hcl.Pravesh/iViews.iViews/BAPICalling.BAPICalling
Component Name : CallingBAPI.Display
Tag tableView attribute model: Cannot access bean property myBean.model in page context.
Exception id: 08:10_15/04/05_0001_3296850
See the details for the exception ID in the log file</b>
What can be the reason? Looking for the response.
Thanks and with Regards
Pravesh
Hi Prakash,
I have already changed the system name to my system name. I have put the alias name in place of R3IDES, but still the problem exist.
I have checked the logs there it shows that the connection is not made with the system. Its displays the error mentioned in the catch block.
What can be the error now?
And yes I will definately reward you once it starts working. Dont worry abt that dear. I really appreciate your help.
With regards
Pravesh
Hi prakash,
I am giving you the stack trace. Have a look:
#
#1.5#000EA6C6016B00630000001E000006640003F485C78468E6#1113280345281#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Look up: deployedAdapters/SAPFactory/shareable/SAPFactory#
#1.5#000EA6C6016B00630000001F000006640003F485C78E25E7#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Connection properties#
#1.5#000EA6C6016B006300000020000006640003F485C78E2957#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: tpname, value: null#
#1.5#000EA6C6016B006300000021000006640003F485C78E29C6#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: group, value: #
#1.5#000EA6C6016B006300000022000006640003F485C78E2A25#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: logonmethod, value: UIDPW#
#1.5#000EA6C6016B006300000023000006640003F485C78E2A82#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: SystemType, value: SAP_R3#
#1.5#000EA6C6016B006300000024000006640003F485C78E2ADE#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: gwhost, value: null#
#1.5#000EA6C6016B006300000025000006640003F485C78E2B38#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: mshost, value: #
#1.5#000EA6C6016B006300000026000006640003F485C78E2BA4#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: client, value: 800#
#1.5#000EA6C6016B006300000027000006640003F485C78E2BFF#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: Language, value: en_US#
#1.5#000EA6C6016B006300000028000006640003F485C78E2C86#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: Password, value: xxxxxxxxxxxxxxx#
#1.5#000EA6C6016B006300000029000006640003F485C78E2CE3#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: r3name, value: IDS#
#1.5#000EA6C6016B00630000002A000006640003F485C78E2D3D#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: gwserv, value: null#
#1.5#000EA6C6016B00630000002B000006640003F485C78E2D96#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: UserName, value: tarun#
#1.5#000EA6C6016B00630000002C000006640003F485C78E2DF0#1113280345921#com.sap.portal.iViewServer#sap.com/irj#com.sap.portal.iViewServer#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###Key: tphost, value: null#
#1.5#000EA6C6016B00630000002F000006640003F485C791CE5F#1113280346171#com.sap.portal.connectors.R3#sap.com/irj#com.sap.portal.connectors.R3#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Error#1#/System/Server#Plain###Failed to get connection. Please contact your admin. #
#1.5#000EA6C6016B006300000030000006640003F485C791CF58#1113280346171#System.err#sap.com/irj#System.err#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Error##Plain###<b>Couldn't establish a connection with a target system</b> : Connection Failed: Nested Exception. Failed to get connection. Please contact your admin. #
#1.5#000EA6C6016B006300000031000006640003F485C792E830#1113280346234#com.sap.portal.portal#sap.com/irj#com.sap.portal.portal#praveshv#280#####SAPEngine_Application_Thread[impl:3]_31##0#0#Info##Plain###------PRT AbstractPortalComponent: calling doContent for portal component: CallingBAPI.Display#
Please notice the bold lines. This clearly means that its going into the catch block hence the connection to the system is not created. Should I create a new system? Can you please give me some links to create a system.
Thanks and Regards
Pravesh
User | Count |
---|---|
84 | |
12 | |
9 | |
8 | |
8 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.