cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in context changing ( message mapping )

Former Member
0 Kudos

<u>source structure </u>

Message Name

Header(1)

H1

H2

LineItem(1)

Item(1-unbounded)

I1

I2

<u>target structure</u>

Message name

Header(1)

H1

status

LineItem(1)

Item(1-un)

I1

I2

The result for status should be as follows

<i>if h1 = x then status = ‘H1’failed else if h2 = x then status = ‘H2’failed

else if I1 = x then status = ‘I1’failed else if I2 = x then status = ‘I2’failed.</i>

Problem :

It works perfect as long we have only one Item (Unbounded Tab).

But since it is unbounded we have more than one item tabs.

The mapping does not produce the status element.

I tried removing the context of all the source fields, but still I coudnt produce the status element. I don’t know where to change the context.

Can somebody help me with this issue.

Thanks in advance .

Disney.

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Hi Disney,

I could not find a solution with standard.

It works with following user defined function (advanced function, cache the whole queue):


public void checkValueInQueue(String[] a, String[] b, ResultList result, Container container) {

  for (int k = 1; k < a.length; k++) {
    if (a[k].equals(b[0])) {
      result.addValue("true");
      return;
    }
  }
  result.addValue("false");

}

Assign this function for I1 and I2 instead of equalS

I1 or I2 are first vale, constant(x) is second value.

Hope that helps,

Stefan

Former Member
0 Kudos

Hi stefan,

Thanks a lot for your help.I dont have words to express my joy, I have been working on this for the last 3 days and i coudn't find a solution.

Your code absolutely fixed my problem. Thanks a lot again, for your timely help.

Regards.

Disney.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I was able to do it with the graphical mapping using standard functions only.

The output will have only one status , the place where the 1st error shows up..like it checks in header fields first, then it takes items one by one.

It is very big though & would be much simpler to do something like what stefan proposed.

Just for info this is the Text Preview for the Mapping i did...(Is there a way, if i have this to upload to a mapping?)

/ns0:MT_TRGT/Header=/ns0:MT_SRC/Header=

/ns0:MT_TRGT/Header/H1=/ns0:MT_SRC/Header/H1=

/ns0:MT_TRGT/Header/Status=iF(iF(const(), stringEquals(/ns0:MT_SRC/Header/H1=, const()), iF(const(), stringEquals(/ns0:MT_SRC/Header/H2=, const()), const())), not(stringEquals(iF(const(), stringEquals(/ns0:MT_SRC/Header/H1=, const()), iF(const(), stringEquals(/ns0:MT_SRC/Header/H2=, const()), const())), const())), ifWithoutElse(not(stringEquals(iF(concat(const(), index(/ns0:MT_SRC/Item/Items/I1=)), stringEquals(/ns0:MT_SRC/Item/Items/I1=, const()), iF(concat(const(), index(/ns0:MT_SRC/Item/Items/I2=)), stringEquals(/ns0:MT_SRC/Item/Items/I2=, const()), const())), const())), iF(concat(const(), index(/ns0:MT_SRC/Item/Items/I1=)), stringEquals(/ns0:MT_SRC/Item/Items/I1=, const()), iF(concat(const(), index(/ns0:MT_SRC/Item/Items/I2=)), stringEquals(/ns0:MT_SRC/Item/Items/I2=, const()), const()))))

/ns0:MT_TRGT/Items=/ns0:MT_SRC/Item=

/ns0:MT_TRGT/Items/Item=/ns0:MT_SRC/Item/Items=

/ns0:MT_TRGT/Items/Item/I1=/ns0:MT_SRC/Item/Items/I1=

/ns0:MT_TRGT/Items/Item/I2=/ns0:MT_SRC/Item/Items/I2=

Thanks,

Renjith.

Former Member
0 Kudos

Hi Renjith,

Thanks for your response.steven's code fixed my problem. I tried his before yours and it worked.

Once again thanks for spending your precious time for me.

Thanks.

regards.

Disney.

Former Member
0 Kudos

Hi

You need only one status message for all cases.

Clarify

Regards

Piyush

Former Member
0 Kudos

Hi Piyush,

Thanks for the response.

Yes, if the header element fails , then the satatus should be "headerelement failed", but if it dosent fail(ie , if it dosent have the value 'x') then

the 1st element of the Line item (unbounded) is checked, if it fails then status should be "element1 failed " etc.

It works fine if we have only one line item,

but since it is unbounded I am struggling to introduce the context change.

Thanks.

Disney.