cancel
Showing results for 
Search instead for 
Did you mean: 

RFC Lookup Code

Former Member
0 Kudos

Hi All,

I am working the File to File Scenario.

In Source file i am sending the Company Number, In target file i need to be place the company Details. Company name, Name and Address from ECC System.

For that I am planning to use the RFC lookup.

RFC : BAPI_COMPANY_GETDETAIL

Inout Parameter : Company ID

Outoput Paramer : Company Number, Name, Address.

Could you please guide me how to write the lookup RFC.

I check the below code....

//write your code here

String sapClient = SAP CLIENT;

String hostName = hostname of SAP system;

String systemNumber = system number;

String userName = SAP Logon UserName;

String password = SAP Logon password;

String language = "EN";

JCO.Repository mRepository;

JCO.Client mConnection = JCO.createClient(

sapClient,

userName,

password,

language,

hostName,

systemNumber );

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

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, "COMPANYID");

//Fill the where clause of the table

JCO.ParameterList tabInput = function.getTableParameterList();

inputTable.appendRow();

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

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

{

valueSet.setRow(i);

String resultSet [] = valueSet.getString("WA").split(",(?=(?:[\"]*\"[\"]\")(?![^\"]*\"))");

result.addValue(resultSet[pos]);

}

mConnection.disconnect();

Any one correct my code based on the requirment, I am poor in JAVA Code.

Thanks for your help,

ANU

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos
MichalKrawczyk
Active Contributor
0 Kudos

Hi,

just to mention one thing

what you specified it not an XI RFC lookup

it's a standard jco call

for real XI RFC lookups have a look at my article:

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a03e7b02-eea4-2910-089f-8214c6d1...

this way you can specify the details of the RFC channel in directory

and not as in your case hardcoded in the code - that's the main advantage

Regards,

Michal Krawczyk

Former Member
0 Kudos

@Michal, I had a hunch that you would reply with the url before me..... and I was right

I was just 60 seconds late in finding your document's URL

Thanks,

Pooja Pandey

Former Member
0 Kudos

Thanks Mik,

Could you please explain What is the difference between XI RFC lookup and standard jco call...

How Both will work....

Thanks,

ANU

MichalKrawczyk
Active Contributor
0 Kudos

hi,

in RFC lookup you use XI communication channel - defined in directory

with jco you need to hardcode configuration in the call (so difficult to change

when you move from dev to test to prd)

rfc lookups are XI specific standard

jco is java standard and you can use it from any java program

use RFC lookups

Regards,

Michal Krawczyk

Former Member
0 Kudos

Thanks Mike,

Can any one Send me the JCo Call UDF Code...

I am working the File to File Scenario.

In Source file i am sending the Company Number, In target file i need to be place the company Details. Company name, Name and Address from ECC System.

For that I am planning to use the RFC lookup.

RFC : BAPI_COMPANY_GETDETAIL

Input Parameter : Company ID

Outoput Paramer : Company Number, Name, Address.

Any one correct my code based on the requirment, I am poor in JAVA Code.

Thanks for your help,

ANU