Skip to Content
0
Former Member
Sep 20, 2007 at 10:23 AM

to Display RFC data on portal using JSPDynPages

20 Views

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.