on 09-20-2007 11:23 AM
hi SDN Gurus,
<b>
i am trying to display data from RFC to Portal iview.
where i have created EP project depoyed it as PAR file to portal and attached the PAR file to iview. i am able to deploy the project succesfully.
but not able to view the RFC data on iview. If i hardcore any text in the jsp i am able to see it, but not able to see the RFC data.
Can anyone Please help me in this case
Here i have created three files
display.jsp , ExecuteRFC, RFCBean.</b>
<b>the RFC i am using is HR_ENTRY_DATE
the import is Pernr
and the export is ENTRYDATE
and the system ALias is D35</b>
ExecuteRFC
package com.ust.jca;
import javax.resource.cci.MappedRecord;
import javax.resource.cci.RecordFactory;
import com.sapportals.connector.connection.IConnection;
import com.sapportals.connector.execution.functions.IInteraction;
import com.sapportals.connector.execution.functions.IInteractionSpec;
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.IPortalComponentRequest;
import com.sapportals.portal.prt.runtime.PortalRuntime;
public class ExecuteRFC extends PageProcessorComponent {
public DynPage getPage() {
return new ExecuteRFCDynPage();
}
public static class ExecuteRFCDynPage extends JSPDynPage {
private RfcBean myBean;
public void doInitialization() {
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
myBean = new RfcBean();
((IPortalComponentRequest) getRequest())
.getServletRequest()
.setAttribute(
"myBean",
myBean);
IPortalComponentRequest request =
(IPortalComponentRequest) this.getRequest();
// fill your bean with data here...
try {
//Alias is the name of the alias you defined in portal for SAP system
getSAPdata(getConnection(request, "D35"));
} catch (Exception e) {
e.printStackTrace();
}
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);
}
private void getSAPdata(IConnection client) throws Exception {
/* Start Interaction * */
IInteraction interaction = client.createInteractionEx();
// call the BAPI_MDDATASET_CREATE_OBJECT
IInteractionSpec interactionSpec = interaction.getInteractionSpec();
interactionSpec.setPropertyValue("Name", "HR_ENTRY_DATE");
RecordFactory recordFactory = interaction.getRecordFactory();
MappedRecord importParams =
recordFactory.createMappedRecord("CONTAINER_OF_IMPORT_PARAMS");
IPortalComponentRequest request = (IPortalComponentRequest)this.getRequest();
//importParams.put("SAPNAME", request.getUser().getUniqueName());
importParams.put("PERSNR", "212");
MappedRecord exportParams =
(MappedRecord) interaction.execute(interactionSpec, importParams);
myBean.setCW1(((Integer)exportParams.get("ENTRYDATE")).toString());
}
}
}
<b>RFCBean</b>
package com.ust.jca;
import java.io.Serializable;
public class RfcBean implements Serializable {
private String CW1;
private String CW2;
/**
* @return
*/
public String getCW1() {
return CW1;
}
/**
* @return
*/
public String getCW2() {
return CW2;
}
/**
* @param string
*/
public void setCW1(String string) {
CW1 = string;
}
/**
* @param string
*/
public void setCW2(String string) {
CW2 = string;
}
}
<b>display.jsp</b>
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="request" class="com.ust.jca.RfcBean" />
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId" >
<hbj:textView
text="<%=myBean.getCW1()%> hi how r u ????"
id="tv1"
design="HEADER2"
encode="false">
</hbj:textView>
<br>
<hbj:textView
text="<%=myBean.getCW2()%>123456"
id="tv1"
design="HEADER2"
encode="false">
</hbj:textView>
<br>
<hbj:textView
text="<%=myBean.getdebug()%>123456"
id="tv1"
design="HEADER2"
encode="false">
</hbj:textView>
</hbj:form>
</hbj:page>
</hbj:content>
can anyone guide where am i going wrong in this code?
Thank you.
I don't see any issue with the code. Did you check you logs for any exceptions?
Do you have the references in the portalapp.xml for the used services.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Andy,
Thanks for replying,
This is the Portalapp.xml code
<?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="ExecuteRFC">
<component-config>
<property name="ClassName" value="com.ust.jca.ExecuteRFC"/>
<property name="SecurityZone" value="com.ust.jca.ExecuteRFC/high_safety"/>
</component-config>
<component-profile>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile>
</component>
</components>
<services/>
</application>
as i am new to EP would you please help me how to check logs for exceptions.
thanks,
Sanjyoti.
Start Visual Administrator. Select ´cluster´ tab and select your server node. Search for ´Log Viewer´ under ´Services´. The default trace file should give more information. This is located on your file system as wel in /usr/sap//j2ee/cluster/server0/log.
We have had some trouble to display data from an RFC enabled BAPI in the Portal. We used JCO Pooling and eventually it succeeded. Make sure you have SSO correctly enabled to your back end system.
Please reward points to helpful answers. Good luck!
sorry experts there is some changes in display.jsp
The display code is modified to this
display.jsp
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="myBean" scope="request" class="com.ust.jca.RfcBean" />
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId" >
<hbj:textView
text="<%=myBean.getCW1()%> hi how r u ????"
id="tv1"
design="HEADER2"
encode="false">
</hbj:textView>
<br>
<hbj:textView
text="<%=myBean.getCW2()%>123456"
id="tv1"
design="HEADER2"
encode="false">
</hbj:textView>
</hbj:form>
</hbj:page>
</hbj:content>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
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.