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

Mapping Exception Issue with RFC LookUp

Hi,

My scenario is Idoc To file, in my idoc user who created a purchase order filed is not there but in xml file i want the user who create that PO, for this i am using RFC LooUp. I want the user who created a purchase order.

Graphical Mapping looks like below.

Belnr--


>User Defined Function--


>UserName

Please find the code bloew:

String DBTABLE = "EKKO";

String lookUpField = "ERNAM";

String WHERE_CLAUSE = " EBELN "" = "" ' "a" ' " ;

JCO.Repository mRepository;

JCO.Client mConnection = JCO.createClient(

"500",

"RFCUSER",

"abc1234",

"EN",

"cxylo06",

"05");

// connect to SAP

mConnection.connect();

// create repository

mRepository = new JCO.Repository( "GenericRFCMappingLookup", mConnection );

// create function template to select data from any table

JCO.Function function = null;

IFunctionTemplate ft = mRepository.getFunctionTemplate("RFC_READ_TABLE");

function = ft.getFunction();

// Obtain parameter list for function

JCO.ParameterList input = function.getImportParameterList();

// Pass function parameters

// set import parameters table name and RFC

input.setValue( DBTABLE, "QUERY_TABLE");

input.setValue( "," , "DELIMITER");

//Fill the where clause of the table

JCO.ParameterList tabInput = function.getTableParameterList();

JCO.Table inputTable = tabInput.getTable("OPTIONS");

inputTable.appendRow();

inputTable.setValue(WHERE_CLAUSE,"TEXT");

mConnection.execute( function );

//Find the position of the field that has to be lookedUp

JCO.Table lookupFieldPos = function.getTableParameterList().getTable("FIELDS");

int pos = -1;

for (int i = 0; i < lookupFieldPos.getNumRows(); i++)

{

lookupFieldPos.setRow(i);

if (lookupFieldPos.getString("FIELDNAME").equals(lookUpField))

pos = i;

}

//Get the exact lookupvalue from the position obtained above

JCO.Table valueSet = function.getTableParameterList().getTable("DATA");

valueSet.setRow(0);

String resultSet = valueSet.getString("WA");

result.addValue(resultSet);

mConnection.disconnect();

I am not aware of java coding so kindly make necessary modifications.

Kindly suggest what changes i need to do to execute perfectly.

Your help will be greatly apprecited.

Regards,

Venkat

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 07:47 AM

    why you are using JCO?

    YOu can use RFC lookup API's..but it will work for SP14 or above.

    Thanks

    Farooq.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 08:50 AM

    By using the above mentioned code i could able to connect to sap system byt unable to retrieve the user name, kindly suggest what maodifications to be made.

    Regards,

    Venkat

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 22, 2007 at 08:51 AM

    Hi Venkat,

    If you use the JCO connection to get the value from RFC, it would be a problem in futherly like when you move this interface DEV to Q, then you need to change the connection parameters to establish the JCO connection.Same in Production environment too.It is not advisable to do JCO lookup. Go for RFC lookup as the link given by Farooq.

    Create Reciever RFC communication channel and take the XML signature of u r RFC by importing that RFC under imported objects.Create an UDF, for this see the sample code which is exisitng in document to pass the Export parameter to RFC.

    In this way u r RFC channel establish the connection to R3 and your RFC will execute and return the value.U just need to change the Reciever RFC channel parameters respective of environment.

    Cheers

    Veera

    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.