cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping Help

Former Member
0 Kudos

Hello Friends ...

Please help me out in this logic.

If i am having the sender and receiver structure as follows.

Source Structure

<src1>

#####<src2> (1 to unbounded)

##########<src3>

##########<src4>

##########<src5>

##########<src6>

#############<src7> (1 to unbounded)

#################<field1>

#################<field2>

In source Structure src3, src4, src5, src6 are of same level and fld1 and fld2 are also of same level and under "src7" node.

Receiver structure

<rcv1>

#####<rcv2>

##########<rcv3>

##########<rcv4>

here i am facing the problem -


the <field1> in receiver structure can have the values of "Y" or "N" under different <src7> nodes. but in the receiver structure the <rcv2> needs to be created only when the <field1> value is "Y". I mean

If the source structure is as below

<src1>

#####<src2> (1 to unbounded)

##########<src3>

##########<src4>

##########<src5>

##########<src6>

#############<src7>

#################<field1> "N"

#################<field2>

#############<src7>

#################<field1> "Y"

#################<field2>

#############<src7>

#################<field1> "N"

#################<field2>

#############<src7>

#################<field1> "N"

#################<field2>

#####<src2> (1 to unbounded)

##########<src3>

##########<src4>

##########<src5>

##########<src6>

#############<src7>

#################<field1> "N"

#################<field2>

#############<src7>

#################<field1> "N"

#################<field2>

#############<src7>

#################<field1> "N"

#################<field2>

#####<src2> (1 to unbounded)

##########<src3>

##########<src4>

##########<src5>

##########<src6>

#############<src7>

#################<field1> "N"

#################<field2>

#############<src7>

#################<field1> "N"

#################<field2>

#############<src7>

#################<field1> "Y"

#################<field2>

#############<src7>

#################<field1> "N"

#################<field2>

#############<src7>

#################<field1> "Y"

#################<field2>

Then The receiver structure needs to be like this

<rcv1>

#####<rcv2>

##########<rcv3> "Y"

##########<rcv4>

#####<rcv2>

##########<rcv3> "Y"

##########<rcv3> "Y"

##########<rcv4>

The <rcv2> needs to be created only when <src2> exists and the <field1> value in that perticular context is "Y"

As here the value of <field1> is "Y" in two instances of <src2>. I mean first instance of <src2> is having the <field1> value as "y" and third instance of <src2> is having the <field1> value as "y" but second instance of <src2> is not having atleast one value of <field1> value as "y" so we need to get the <rcv2> only two times for those intances of <src2> having <field1> value as "y" .

Please help me out in achieving this .

Thanks

Ramana.

Accepted Solutions (1)

Accepted Solutions (1)

sunil_singh13
Active Contributor
0 Kudos

Hi Ramana,

if <feild1> is "Y" and <src2> exists

<feild1> ->equals->[CONSTANT "Y"] and <src2> -> exists -> IfWithoutElse[Keeps=true]-><rcv2>

Thanks,

Sunil Singh

Former Member
0 Kudos

Hi Sunil,

I tried the logic you have given. But still its not working for me.

Now its working in unexpected manner .. its creating only one target node. please help me out .

Thanks in Advance

Ramana.

sunil_singh13
Active Contributor
0 Kudos

Hi Ramana,

You are stuck with context Assignment.

if <feild1> is "Y" and <src2> exists

<feild1> ->equals->[CONSTANT "Y"] and <src2> -> exists -> IfWithoutElse[Keeps=true]-><rcv2>

in this you will have to fulfil 2 condition one is <Feild1> shld be "Y" and <src2> shld exists.

keep the context of <feild1> and <src2>( right click on <feild1>) to Message level (not <src7> level) and then chck if value "y" is coming & "and" (BOOLEAN) this with <src2> exists.

Thanks,

Sunil Singh

Former Member
0 Kudos

Hi Sunil,

HereOur logic is not working fine. As it is comparing this <src1 existance :3> existance value to <field1> (existance :12) its creating 3 nodes on the receiver side. where as our requirement is 2. i tried with all the possiblities of contexts combination eith the node as well as field. Hope we need to change our logic itself.

Think one more time sunil. Thanks for your patience.

Regards.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Better try this


src2--------->exists---\
                              and
field1---------------------\
                             equalsS------>Createif--->rcv2
Constant[Y]----------/

Map field1 to rcv3

Former Member
0 Kudos

Hi Malini,

I tried that one but still its creating 3 nodes instead of 2.

any more ideas....

Thanks

Ramana.

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

There is no need to check for the existence of src2 since its occurrence is 1..unbounded.

You can use this mapping to eliminate the three nodes problem:

field1 (set context to src2) --> sort:lexicographical(case insensitive) --> collapseContext --> *sort:lexicographical(case insensitive) --> splitByValue:valueChanged --> rcv2

explanation:

When you use the first sort, it makes the value Y at the top of the queue, so when you use collapseContext, only single Y and N values exists..so the output should now be Y,N,Y. Then you use the second sort to make it Y,Y,N, then use splitByValue so that only the values YY gets included in the 0..unbounded occurrence when using the Test tab...It will create rcv2 nodes if and only if the queue contains a Y

The mapping is still incomplete though, as you would have to find a way to map src3

Let me know if this helped

Former Member
0 Kudos

Hi Ramana,

Check also these helpful blogs:

Implementing a Java Mapping in SAP PI

Java Mapping secrets revealed

Best Regards,

Pedro Nunes

Former Member
0 Kudos

Hi Pedro,

As I am not aware of JAVA, i cant make up this Java mapping. Hope it can possible using message mapping itself. If i am wrong please let me know.

Thanks,

Ramana,