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

Jca to Rfc null return

Can somebody please help me figure out why i am not getting null when there is data returned by RFC.

I am major part i am using code posted by Prakash.

Just testing YTEST RFC which returns 10 chars.

Bean

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.connector.metadata.primitives.IByte;

import com.sapportals.connector.metadata.primitives.IString;

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 = "YTEST";

try {

try {

//pass the request & system alias

//Change the alias to whatever the alias is for your R/3 system

client = getConnection(request, "SAP_R3_HumanResources");

} 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

  • */

String RetVal = (String)exportParams.get("RETURN");

// 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("OUTPUT");

/*exportTable.beforeFirst(); // Moves the cursor before the first row.

while (exportTable.next()) {

String column_1 = exportTable.getString("PERNR");

String column_2 = exportTable.getString("ENAME");

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.setCW1(RetVal);

/*

  • 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);

}

}

}

}

tablebean:

package com.my.package;

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 {

private String CW1;

public String getCW1() {

return CW1;

}

public void setCW1(String string) {

CW1 = string;

}

}

JSP

<jsp:useBean id="myBean" scope="application" class="com.com.my.package.TableBean" />

Output "<%= myBean.getCW1()%>"

portalapp.xml

<?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.my.package.Display"/>

<property name="SecurityZone" value="com.my.packagea.Display/low_safety"/>

</component-config>

<component-profile>

<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>

</component-profile>

</component>

</components>

<services/>

</application>

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 05, 2005 at 07:15 AM

    Hi tegala,

    What is null - exportParams or RetVal?

    Yoav.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 05, 2005 at 01:32 AM

    Can you post what your RFC definiton.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 05, 2005 at 09:23 PM

    Thanks.. Export Parameters.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 06, 2005 at 07:21 AM

    Hi tegala,

    Just tell what are the import parameters of your RFC. If your RFC requires any import parameters then that has to be passed to it.

    You are just creating the instance of mappedrecord "importParams".If there are any import parameters then you have to pass that using the put() method of the mappedrecord.

    This "importParams" has to be passed while executing the Interaction.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 08, 2005 at 07:18 PM

    Thanks guys , figured out The RFC was not set to remote callable, YTEST is just a sample i was testing.

    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.