cancel
Showing results for 
Search instead for 
Did you mean: 

How Hash tables can be used in PI mapping

Former Member
0 Kudos

Hi Experts,

I'm don't have any idea how we store the values in hash tables and how to implement them in mapping.

In my scenario I have two fields matnum and quantity.if matnum is not null ,then we have to check whether the matnum exists in hash table and also check whether the hash table is empty or not.

How we can do this in graphical message mapping?

how to store the variable matnum in a table?

If global variables are used, how to implement in mapping.how we call the keys from hash table ?

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member611181
Participant
0 Kudos

Divya,

We have a similiar requirement for getting different values. Below param1 may you be matnum,param2 is quantity

What you need to do is first declare global varaible(A), fill hash table as below(B) and retrieve(C) based on index. You can tweak code based on your requirement

(A) Declare global variable(last icon in message mapping tool bar)

String globlalString[] = new String[10];

(B) Fill Hash Table

import java.util.Hashtable;

public void saveparam1(String[] param1,String[] param2,ResultList result,Container container){

Hashtable htparam1 = new Hashtable();

int Indx = 0;

for (int i = 0 ;i < param1.length ; i++) {

String strparam1 = param1<i>.trim();

if (strparam1.length() > 0) {

Object obj = htparam1.get(strparam1);

if (obj == null){

globlalString[Indx++] = strparam1 ;

htparam1.put(strparam1,strparam1);

}

}

}

if (Indx < globalString.length) {

for (int i = 0; i < param2.length ; i++) {

String strparam2 = param2<i>.trim();

if (strparam2.length() > 0) {

Object obj = htparam1.get(strparam2);

if (obj == null){

globalString[Indx++] = strparam2 ;

htparam1.put(strparam2,strparam2);

}

}

}

result.addValue(globalString[0]); // for first value

(C) for subsequent reading/accessing

//pass constant whatever number is required to this function

String retValue = "";

int indx = Integer.parseInt(index);

indx = indx - 1;

if ((indx >= 0) && (indx < globalString.length)){

retValue = globalString[indx];

}

}

return retValue;

Hope this helps!