cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing value from a different context

Former Member
0 Kudos

Hello,

I have an IDOC structure like this:

<E1BPPRODUCTLINE SEGMENT="1">

<EAN_UPC_BASE>710980201761</EAN_UPC_BASE>

</E1BPPRODUCTLINE>

<E1BPPRODUNITPRICE SEGMENT="1">

<COND_TYPE>YIFF</COND_TYPE>

<EAN_UPC_ALTUNIT>710980201761</EAN_UPC_ALTUNIT>

<CONDITION_VALUE>0.7500</CONDITION_VALUE>

</E1BPPRODUNITPRICE>

<E1BPPRODUNITPRICE SEGMENT="1">

<COND_TYPE>YK30</COND_TYPE>

<EAN_UPC_ALTUNIT>710980201761</EAN_UPC_ALTUNIT>

<CONDITION_VALUE>41.0000-</CONDITION_VALUE>

</E1BPPRODUNITPRICE>

The EDI result should be like this:

<CTP>

<212>0.7500</212>

</CTP>

The CTP tag should exist for each product line, but the value in <212> for condition type YK30 depends on the value in condition type YIFF.

More specifically, if condition type is YK30, then what should be mapped in <212> is the condition value from YIFF if it exists.

How can I do this in XI?

Thanks,

Paula

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

It is very simple , write a UDF, with the input values are COND_TYPE,CONDITION_VALUE ..type queue.

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

if cond_type(i).equals("YK30"){

for(j=0;j<cond_type(j).length;j++){

if cond_type(J).equals("YKFF"){

result.addValue(CONDITION_VALUE(j));

break;

}

}

}

<b>Note :replace with "[]"</b>

COND_TYPE -


removecontext---\ UDF -


Splitbyvalue -- target node(212)

CONDITION_VALUE-----removecontext ---/

map the empty constant to CTP if the CTP node has the mor eoccurrences

Regards

Chilla

<i>reward points if it is helpful..</i>

Answers (3)

Answers (3)

Former Member
0 Kudos

Thanks Chandra,

It works the way you suggested. I just had to add a check for the EAN_UPC_ALTUNIT and it worked.

Points rewarded.

Paula

Former Member
0 Kudos

Hi Wojciech,

Thanks for your reply, you definitely pointed me in the right direction. Here is the code I wrote:

public void getConditionValue(String[] a, String[] b, String[] c, ResultList Result, Container container)

Map map = (Map) container.getParameter("values");

if (map == null){

map = new HashMap();

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

map.put(b<i>, c<i>);

}

container.setParameter("values", map);

}

result.addValue((String)map.get(a[0]));

}

I pass it the following:

a = YIFF (constant)

b = COND_TYPE

c = CONDITION_VALUE

COND_TYPE in my case has 7 context changes and YIFF appears 3 times.

I expected the function to return the value of YIFF everytime it occurs but it only returns the last one.

What am I doing wrong?

Thanks,

Paula

Former Member
0 Kudos

Hi,

First of all please change the context of COND_TYPE and CONDITION_VALUE to upper context. It seems that now it is E1BPPRODUNITPRICE so move it up.

Also remember to handle such case when there is no YIFF. According to your code you will add null and get runtime error.

Regards,

Wojciech

Former Member
0 Kudos

Hi,

Make an value lookup. Crete UDF function in which you will use HashMap and use COND_TYPE as a key and CONDITION_VALUE as value. Later get from this HashMap first based on key equal YIFF.

Regards,

Wojciech