cancel
Showing results for 
Search instead for 
Did you mean: 

Table lookup instead of fixed value mapping

Former Member
0 Kudos

Hi Folks,

My current scenario is that I have used fixed value mapping to map a single target field. These details are actually maintained in the TP_Code table in R3 (a sample table).

TradingPartner:SAP:Short Text

PA:PA:Package

PL:PAL:Pallet

.....

The table contains 20 entries.

I am thinking that fixed value mapping is not a good option since there might have future changes in the TP_Code table.

Is rfc lookup a good option? But I am not sure which rfc to use and if there is any udf availble to be used in parsing the xml payload.

Please advise.

Thanks a ton!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi

In this type of scenario Value mapping is not a good option ,You hv to RFC lookup.

In the below link it has all the information..how to do the RFC lookup...

chk this link for more information

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

Thanks

MANas (reward with points)

Former Member
0 Kudos

Hi,

IF u r thinking to replace the Fixed value with RFC lookup then u have following configuration to be done.

To be done in XI:

1) Create one R3 table and maintained all the entries.

2) Through UDF u need to passthe input value to RFC function module where u will select the output value for that input value.

3) Return the value to the UDF.

refer the below link for RFC lookup:

• RFC lookup using JCO (without communication channel)

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

• RFC lookup with communication channel.

/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer

Now disadvantage of this is:

Everytime u need the output value u need to jum from Java stack to abap stack. this will not be a good solution if u ony required to get the values.

If u wanted to maintain only 20 values then I suggest u go for fixed value mapping only.

Thnx

Chirag

Former Member
0 Kudos

Thanks so much for the links!

I managed to use and run the RFC lookup to an R3 table using JCo. However, I am not getting the right result.

I am getting the result in this format -> 800,PA,PAC,Package

The correct output is PAC which is the third node. Could this only be achieved by using java tokenizer?

The code that I have used is as follows:

Import com.sap.mw.jco.*;

//write your code here

String DBTABLE = a;

String WHERE_CLAUSE = b" = ""'"c"'" ;

String sapClient = "xxx";

String hostName = "nnnxxx";

String systemNumber = "xx";

String userName = "nnnnn";

String 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( "SAPLookup", mConnection );

// Create function

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

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

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

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

mConnection.disconnect();

return resultSet;

justin_santhanam
Active Contributor
0 Kudos

Lex,

Yes, you can use StringTokenizer to get the third element.

raj.

Former Member
0 Kudos

Great!

I thought, its just a matter of picking the right field in the RFC_READ_TABLE.

I'll check on string tokenizer. Hope I could find some relevant code for this UDF.

Thanks so much Raj!

justin_santhanam
Active Contributor
0 Kudos

Lex,

You can modify your code


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

StringTokenizer st = new StringTokenizer(resultSet);
st.nextToken();
st.nextToken();
mConnection.disconnect();
return ""+st.nextToken()+"";

raj.

Former Member
0 Kudos

Hi Raj,

Thank you for the snippet.

Btw, I found another method called split().

Here's the code that I have come up with...

...import com.sap.mw.jco.;java.lang.String.;

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

String resultSet []= valueSet.getString("WA").split("
,");

mConnection.disconnect();

return resultSet[2];

Hope you'll find it interesting as much as I did.

Regards,

Lex

justin_santhanam
Active Contributor
0 Kudos

Lex,

I really appreciate it! I will make use of Split function too! Thanks for sharing the knowledge. By the way in the snippet which I provided small modification, I forget to give the token ,

StringTokenizer st = new StringTokenizer(resultset,",");

Anyhow your code looks perfect. You can go ahead with that!

Thanks,

raj.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

for RFC Mapping lookups please have a look here:

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

And here is another thread about this topic:

Regards

Patrick

Former Member
0 Kudos

Hi,

Check this

/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer

Regards

Seshagiri