Skip to Content
author's profile photo Former Member
Former Member

to Display RFC data on portal using JSPDynPages

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 12:49 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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!

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 10:26 AM

    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>
    
    
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.