cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Issue in SAP PI

Former Member
0 Kudos

Hi Experts,

I need one help from you.I have a scenerio where I have one field as email id.

If sender is sending the value for eail id than it will be mapped to target email else I have to take the first name and last name than dynamically I have create the email id for them in target sturcture.

Ex in case email value is coming...abhinav@yahoo.com--->mapped to target email...else abhinav.verma@yahoo.com will go o target.

First name.LastName@yahoo.com if no email id is coming.

Please let me know how to do that in mapping..

Regards,

Abhi    

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Plesae see my mapping and output

praveen_sutra
Active Contributor
0 Kudos

Hi Abhinav,

I am not sure why you are not using mapWithDefault with blank value.

Currently the mapping you did is working as expected.

You are checking whether the node exist or not.

And since u can see the node exist even thought its blank in your source message hence true condition is executing..

My suggestion again would be use mapWithDefault and test it.

thanks and regards,

Praveen T

Former Member
0 Kudos

Hi Praveen,

Thanks for sharing the info.It is working fine now.I have one more doubt if I am not passing last name than email id in output is coming like:-abhinav_@yahoo.com.(General email id structure abhinav_verma@yahoo.com)

Can you please suggest so that i will fix this criteria also.

Regards,

Abhi

praveen_sutra
Active Contributor
0 Kudos

hi Abhinav,

May i know what do u want  to be the output if last name is not present.

Note: There is difference between node being not present and value in the node being not present.

Absence of node can be handled using mapwithdefault and blank values condition can be fixed using if then else condtion.

thanks and regards,

Praveen T

praveen_sutra
Active Contributor
0 Kudos

hope this would solve your issues

you can fill what ever constant values as per requirement when first or last name is blank in constant(defaultValue)

Former Member
0 Kudos

Hi Abhinav,

before concat, just check for the existence of last name . if lastname exists then concat with firstname and last name else pass firstname as email id

Cheers

Hidayat

Former Member
0 Kudos

Hi Praveen,

If last name is not present than it should be mapped with team id.What I mean to say if email id of that person doesnt exists than info will go to team mail id.ex pi_developement_team@abc.com

Regards,

Abhi

praveen_sutra
Active Contributor
0 Kudos

Please remove the highlighted section and add the section as mentioned.

this should solve the issue.

thanks and regards,

Praveen T

Former Member
0 Kudos

Hi Praveen,

Thanks for sharing the information.I have already applied the logic and it is working fine now.

Thanks a lot again Praveen.

Regards.

Abhi

Answers (7)

Answers (7)

Muniyappan
Active Contributor
0 Kudos

Hi,

can you share us your input and expected output xml? (with email id,without email id)

it can help us to get your requirement better.

Regards,

Muniyappan.

Former Member
0 Kudos

hey Abhinav,

What I understand is that you are not using Exists function correctly. There is always a confusion with blank value and unavailable value.

you can just use one simple UDF. take first name, lastName and emailID as input. use MapWithDefult[X] for emailID

if(emailID.isequal("")||emailID.equals('X'))

return firstname+"_"+LastName;

Regards,

Gavaksh Saxena.

Former Member
0 Kudos

Hey Gavaksh,

Sorry Gavaksh for replying it so late.I was not well last week so didnt get the chance to see your suggestion.

Gavaksh,we are looking to minimize the load on PI so in most of the cases we are avoiding writing UDF.UDF we wrote but customer dint approved it.So we are using mapping concept to fix this issue.

We have 2 options either to apply  the mapping concept in PI  or fix this issue in ECC part only by writing a abap program.

I am trying to apply mapping to fix this in PI only.

Regards,

Abhi

ambrish_mishra
Active Contributor
0 Kudos

Instead of exists, do if field-> MapWithdefault EQ null

Ambrish

Former Member
0 Kudos

Use below mapping

I have used Marks for email id(you can replace Marks field with Email id field) and replace EMPName field with the concatenated values( firstname+lastname+@smting.com).

Here, there are many records in the source side. 2nd record does not contain MARKS field while 3rd record contain blank value. this mapping will check both the conditions. PFB the screenshot for the queues of Marks field and EqualS function

Also,, you can see the output queue below. for 2nd and 3rd Record, where mark field was unavailable and blank, EMPName is fwd to the target.

Please let me know if you have any confusions.

Regards,

Gavaksh Saxena

former_member463616
Contributor
0 Kudos

Hi Abhinav,

Please use below mapping logic to achieve your requirement.

Regards,

Rajesh

Muniyappan
Active Contributor
0 Kudos

Hi Abhi,

not sure why are not able to achieve this.

experts suggested ways to get it.

check this.

mapping logic.

test results.

Regards,

Muniyappan.

Former Member
0 Kudos

Hi Muniyappan,

Your mapping is very simmilar to my mapping only things which I am using is (ifs) I intead of (If) which you are using.

Regards,

Abhi

Muniyappan
Active Contributor
0 Kudos

Hi,

ok.  is it working now as you expected?

Regards,

Muniyappan.

praveen_sutra
Active Contributor
0 Kudos

Hi Abhi,

then use (If) and it should work.

difference between (If) and (ifs)

http://scn.sap.com/message/5968650#5968650

if you still face any specific issues do let us know.

thanks and regards,

Praveen T

Former Member
0 Kudos

No I have used as you said but it is not giving me the correct result.Can I have your email is ...as I am not able to upload the screenshot here.

Former Member
0 Kudos

Hi,

I changed it from ifS to if but not getting the proper result.

Regards,'

Abhi

gagandeep_batra
Active Contributor
0 Kudos

Hi abhinav

i think you are testing with blank value that is why exist is not working... try condition on blank also means if email field is blank or not exist then your logic other wise direct transfer it to target node..

regards

gagan

Former Member
0 Kudos

Hi,

I am not testing with blank Message.I am putting the value in FirstName and Last name...email id field i am keeping blank.

Regards,

Abhi

praveen_sutra
Active Contributor
0 Kudos

hi Abhinav,

Please try this.

thanks and regards,

Praveen T

Former Member
0 Kudos

HI Praveen,

If i use map with default than it will not be dynamically,it will map with that value only.

Regards,

Abhi

gagandeep_batra
Active Contributor
0 Kudos

Hi Abhinav ,

that i am saying you are testing with "email id field i am keeping blank"

so  try the logic on blank mean

if email field is blank or email field is not exist

concat first and last logic.....

otherwise

then default  value

i want to say BLANK is not tested by Exist  function.

Regards

Gagan

praveen_sutra
Active Contributor
0 Kudos

hi Abhinav,

MapWithDefault will map with a blank value only if there is no node coming.

if the node is present and u have given blank value in map with default it will not take any value.

It is just to ensure if the node is not generated we are doing a check.

thanks and regards,

Praveen T

praveen_sutra
Active Contributor
0 Kudos

[sourceEmail] --> [mapWithDefault]-->[equals ] --------> [if and else] then

                                                       [blank constant]

if true map [SourceEmail]

else map

     [firstname] [concat] [.(constant)]

          [concat]

     [latname][concat][@yahoo.com]

thanks and regards,

Praveen T

smavachee
Active Contributor
0 Kudos

You can use Email validation UDF for the same...try with below code..

public void validate(String emailid[],ResultList result,Container container)throws StreamTransformationException{

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

        { if(emailid[i].matches("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"))

            { return emailid;

            }

            else

            { return (Set condition as per your requirement);

            }

        }

    }

In mapping set a Condition..

Source Email Field > UDF Validation > Target Email Field

Hope it  helps.!

Regards,

Sunil

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can use this mapping:

                      emailid -> \

emailid -> exist ----------> ifS --> emailid

firstname -> concat[.] -> /

lastname -> /

Hope this helps,

Mark

Former Member
0 Kudos

can you please share some more details.I tried this but it is not working

praveen_sutra
Active Contributor
0 Kudos

could you please share the mapping so that we can have a better idea.