cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping doubt

Former Member
0 Kudos

Hi Experts,

My source data will have below structure.

<Source>
<D_235>Type</D_235>
<D_234>Number</D_234>
<D_235_2>Type</D_235_2>
<D_234_2>Number</D_234_2>
<D_235_3>Type</D_235_3>
<D_234_3>Number</D_234_3>

</Source>

Target Structure:

<Target>

<IDTNR>

</Target>

Mapping condition is:

IDTNR will contain concatenation of all Numbers which are coming from source if Type is not equals to "VN"

Data may come from source in any format like:

With only one number

<D_235>

<D_234>

<D_235_2>Type</D_235_2>

<D_234_2>Number</D_234_2>

<D_235_3/>

<D_234_3/>

or with two numbers

<D_235>A</D_235>

<D_234>123</D_234>

<D_235_2>B</D_235_2>

<D_234_2>876</D_234_2>

<D_235_3/>

<D_234_3/>

or with all 3 numbers with one type as "VN"

<D_235>H</D_235>

<D_234>980</D_234>

<D_235_2>P</D_235_2>

<D_234_2>760</D_234_2>

<D_235_3>VN</D_235_3>

<D_234_3>435</D_234_3>

Please help me on mapping for IDTNR field.

Thanks & Regards,

A.Neelima.

Accepted Solutions (1)

Accepted Solutions (1)

former_member312864
Active Participant
0 Kudos

Hi,

You can use below graphical mapping logic to populate desired result

Instead of TYPE replace with <D_235>, for NUMINSET replace with  <D_235_2>, for MSGNR replace with <D_235_3>

Instead of MSGID replace with  <D_234> for the first if then else statement

                                                   <D_234_2> for second if then else statement

                                                   <D_234_3> for third if then else statement

                                                   

Regards,

Former Member
0 Kudos

Hi Sarojkanta,

Thanks for your reply.

I just used Not after equlas function and in concat i used "/" because i need to seperate all materials with "/" symbol as per my requirement.

With the above mapping i am getting below out put.

If Input is :

<D_235>VN</D_235>

<D_234>12345</D_234>

<D_235_2>A</D_235_2>

<D_234_2>123</D_234_2>

<D_235_3/>

<D_234_3/>

I am getting Output for IDTNR as :

/123/

But expected output as 123(with out pipe symbol).

Appreciate your help on this.

Thanks & Regards,

A.Neelima.

former_member312864
Active Participant
0 Kudos

It means if you have multiple material then you need a "/" in between for separation  but for single value you dont need "/" symbols. Is it your requirement ?

Former Member
0 Kudos

Yes. Correct.

Thanks & Regards,

A.Neelima.

former_member312864
Active Participant
0 Kudos

You can put a logic to check for value"VN" in <D_235> before concat "/" else pass with null in constant.

like if <D_235> not equals to "VN" then concat "/" else constant NULL

like wise check for <D_235_2> before concating last value

Former Member
0 Kudos

Thanks for your reply.

Can you explain little bit more. I did not get you.

Regards,

A.Neelima.

former_member312864
Active Participant
0 Kudos

why dont you try with a logic like below

if beginsWith "/" then use replaceString for replacing "/"with "".

former_member312864
Active Participant
0 Kudos

use below logic before passing final output to target.

Former Member
0 Kudos

Hi,

After concat (/) i should use replacewithstring function. Its not working..

Any other logic i can use to acheive my mapping requirement.

Regards,

A.Neelima.

former_member312864
Active Participant
0 Kudos

could you please share your mapping screenshot

Former Member
0 Kudos

Hi,

On this requirement mapping sheet is not updated yet.

I will explain requirement once again.

From sender i will get below possible number of inputs.

Possible scenario 1:

<D_235>

<D_234>

<D_235_2>IN</D_235_2>

<D_234_2>123</D_234_2>

<D_235_3/>

<D_234_3/>

Possible scenario 2:

<D_235>VN</D_235>

<D_234>456</D_234>

<D_235_2>BP</D_235_2>

<D_234_2>789</D_234_2>

<D_235_3/>

<D_234_3/>

Possible scenario 3:

<D_235>IN</D_235>

<D_234>980</D_234>

<D_235_2>VN</D_235_2>

<D_234_2>760</D_234_2>

<D_235_3>BP</D_235_3>

<D_234_3>120</D_234_3>

Below are the expected outputs fror each scenario:

Possible scenario 1 Output:

<IDTNR>123<IDTNR>

Possible scenario 2 Output:

<IDTNR>789<IDTNR>

Possible scenario 2 Output:

<IDTNR>980|120<IDTNR>

So my requirement is need to check D_235, D_235_2, D_235_3 are not equls to VN and its not empty value, and each output should concatenate with "|" pipe symbol if i get more than one number.

And "|" pipe symbol  should not come in starting of the output or ending of the output or in middle of two numbers two pipe symbols.

Ex: |123 or 123| or 123||980 ---- Its not correct

Hope its clear now.

Thanks & Regards,

A.Neelima.

former_member312864
Active Participant
0 Kudos

I was trying with graphical maping and its getting very complecated. I sugest try to use below udf for desired output.

take 6 input arguments  v1,v2,v3,m1,m2,m3

in the maping pass <D_235> to V1
                   <D_235_2> to V2
                   <D_235_3/> to V3
                   <D_234> to m1
                   <D_234_2> to m2
                   <D_234_3/> to m3


map the udf output to <IDTNR>

Logic for UDF
-------------------
String output = new String();
if((!(v1.equals("VN")))&&(!(v2.equals("VN")))&&(!(v3.equals("VN"))))
output = m1+"|"+m2+"|"+m3;
else if((v1.equals("VN"))&&(!(v2.equals("VN")))&&(!(v3.equals("VN"))))
output = m2+"|"+m3;
else if((!(v1.equals("VN")))&&(v2.equals("VN"))&&(!(v3.equals("VN"))))
output = m1+"|"+m3;
else if((!(v1.equals("VN")))&&(!(v2.equals("VN")))&&(v3.equals("VN")))
output = m1+"|"+m2;

else if((!(v1.equals("VN")))&&(v2.equals("VN"))&&(v3.equals("VN")))
output = m1;
else if((v1.equals("VN"))&&(!(v2.equals("VN")))&&(v3.equals("VN")))
output = m2;
else if((v1.equals("VN"))&&(v2.equals("VN"))&&(!(v3.equals("VN"))))
output = m3;

return output;

-----------------------

Regards,

Former Member
0 Kudos

Hi,

Thanks for your reply.

By using this UDF also i am getting output as "|123" if i use below input data.

<D_235/>

<D_234/>

<D_235_2>VN</D_235_2>

<D_234_2>098</D_234_2>

<D_235_3>IN</D_235_3>

<D_234_3>123</D_234_3>

Expected output is : <IDTNR>123</IDTNR>

Coming output is : <IDTNR>|123</IDTNR>

Regards,

A.Neelima.

Former Member
0 Kudos

Hi Neelima,

For logic to work .. use IF..Else node for D_235 Nodes and if its null pass VN.

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Hi Sarojkanta,

I have modified UDF which you have given, according to all possible scenarios.

Now its working fine.

Thanks for your help.

Below is the UDF which i have modified.

String output = new String();
if((((((!(v1.equals("VN")))&&(!(v1.equals("")))))&&((!(v2.equals("VN")))&&(!(v2.equals("")))))&&((!(v3.equals("VN")))&&(!(v3.equals(""))))))
output = m1+"|"+m2+"|"+m3;
else if(((((!(v1.equals("VN")))&&(!(v1.equals("")))))&&((!(v2.equals("VN")))&&(!(v2.equals(""))))))
output = m1+"|"+m2;
else if(((((!(v2.equals("VN")))&&(!(v2.equals("")))))&&((!(v3.equals("VN")))&&(!(v3.equals(""))))))
output = m2+"|"+m3;
else if(((((!(v1.equals("VN")))&&(!(v1.equals("")))))&&((!(v3.equals("VN")))&&(!(v3.equals(""))))))
output = m1+"|"+m3;
else if((((((!(v1.equals("VN")))&&(!(v1.equals("")))))&&((v2.equals("VN"))&&(v2.equals(""))))&&((v3.equals("VN"))&&(v3.equals("")))))
output = m1;
else if((((((!(v2.equals("VN")))&&(!(v2.equals("")))))&&((v1.equals("VN"))&&(v1.equals(""))))&&((v3.equals("VN"))&&(v3.equals("")))))
output = m2;
else if((((((!(v3.equals("VN")))&&(!(v3.equals("")))))&&((v1.equals("VN"))&&(v1.equals(""))))&&((v2.equals("VN"))&&(v2.equals("")))))
output = m3;
else if(((!(v1.equals("VN")))&&(!(v1.equals(""))))&&((((v2.equals("VN"))&&(!(v2.equals(""))))||((v3.equals("VN"))&&(!(v3.equals("")))))))
output = m1;
else if(((!(v2.equals("VN")))&&(!(v2.equals(""))))&&((((v1.equals("VN"))&&(!(v1.equals(""))))||((v3.equals("VN"))&&(!(v3.equals("")))))))
output = m2;
else if(((!(v3.equals("VN")))&&(!(v3.equals(""))))&&((((v1.equals("VN"))&&(!(v1.equals(""))))||((v2.equals("VN"))&&(!(v2.equals("")))))))
output = m3;
else if(((!(v1.equals("VN")))&&(!(v1.equals(""))))&&((v2.equals(""))||(v3.equals(""))))
output = m1;
else if(((!(v2.equals("VN")))&&(!(v2.equals(""))))&&((v1.equals(""))||(v3.equals(""))))
output = m2;
else if(((!(v3.equals("VN")))&&(!(v3.equals(""))))&&((v2.equals(""))||(v1.equals(""))))
output = m3;

return output;

Regards,

A.Neelima.

former_member312864
Active Participant
0 Kudos

Hi Neelima,

I did not consider null value thats why not added anything in the logic .

Also in the logic add a logic for all the valuesfor type are null or equals to "VN"

Regards,

Answers (0)