cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping logic required--UDF

Former Member
0 Kudos

Hi Experts,

I am trying to build a mapping logic for below requirement but not able to achieve 100% using standard functions.

Some one please throw some light on this.

I have one xml document in source and wanna create 3 different files,file to file ,used multi mapping concept.

Please check the attachment.

Accepted Solutions (1)

Accepted Solutions (1)

Muniyappan
Active Contributor
0 Kudos

Hi,

create one sender message and three receiver messages.

create on variable and store values like 1,2,3 for your example1,2,3 respectively.

use this variable value in the Fixvalues to  pass required constant.

you can also manipulate the mapping to get the desired output.

insert the message as shown below in signature tab

create variable

create UDF which takes 3 inputs

do the variable mapping

mapping

do the same mapping for others paymenttermsteps,paymentermstepdetails.

fixvalues

result

hope this will give some idea to solve this mapping.

Regards,

Muniyappan.

Former Member
0 Kudos

Thank you Muniyappan,

Your logic will not work for me  logic ass follows

1)discount offered = 1% , netdays with discount 10,net days with out discount= 30

in this case i need generate unique name value equal to = 1D10N30

Uniquename= discount offered(remove percent)+D+netdays with discount+N+Netdays withour discount.

2)discount offered = .5% , netdays with discount 10,net days with out discount= 45

in this case i need generate unique name value equal to = A5D10N45

Uniquename= A+discount offered(remove percent and . prefix)+D+netdays with discount+N+Netdays withour discount.

like that..

Muniyappan
Active Contributor
0 Kudos

Hi,

thanks for letting know your logic. that is why i asked you whether your are using any constants.

as per your logic the following fields will be covered. that is good.

<UniqueName>1A5D15N60</UniqueName>

<ParentUniqueName>1A5D15N60</ParentUniqueName>

<StepJoinToken>1A5D15N60</StepJoinToken>

<ParentStepJoinToken>1A5D15N60</ParentStepJoinToken>

from your payload i can guess you are following below logic for these two fields. correct me if i am wrong.

  <DiscountOffered>1.5%</DiscountOffered> mapped to (removing%)   <Discount>1.5</Discount>

<NetDaysW_Discount>15</NetDaysW_Discount>  mapped to  <PayInDays>15</PayInDays> 

what about below three fields. these are constants or for this also you are having some logic.


<Description>description</Description>

<InstallmentPercent>1</InstallmentPercent>

<DiscountType>percent</DiscountType>

please do suggest.

(you did not mentioned about logic for third example?)

Regards,

Muniyappan.


Former Member
0 Kudos

Thank you,below fields are constants some times but i am able to build logic for below fields

<Description>description</Description>

<InstallmentPercent>1</InstallmentPercent>

<DiscountType>percent</DiscountType>

Muniyappan
Active Contributor
0 Kudos

Hi,

Thanks for your confirmation.

You don't have to create any UDF now. you can achieve this using standard function.

create a variable in the receiver side.

Use replaceString and cancat function to get UniqueName as per your logic. it will be stored in Variable

map this variable to UniqueName,ParentUniqueName,StepJoinToken,ParentStepJoinToken.

below one is for getting Name

rest of the other fields mapping

now you can test the mapping.

please let me know if you face any issues.

Regards,

Muniyappan.

Former Member
0 Kudos

Hi Muniyappan,

The logic you have provided will not work for all cases,i have tried similar logic but it satisfies only one condition.

Case1:

Discount offered=1%,NetDays with Discount=10,Netdayswithoutdiscount=40 then Unique name 1D10N40

Case2:

Discount offered=15.5%,NetDays with Discount=10,Netdayswithoutdiscount=40 then Unique name 15A5D1040

Case3:

Discount offered=.5%,NetDays with Discount=10,Netdayswithoutdiscount=40 then Unique name A5D10N40

Case4:

Discount offered=1.5%,NetDays with Discount=10,Netdayswithoutdiscount=40 then Unique name 15A5D10N40

I want logic to satiusfy above all conditions.

Appreciated your help,Thank you

Muniyappan
Active Contributor
0 Kudos

Hi,

i am able to get all required output from the same mapping which i posted last time.

please share your mapping logic screen shot for Unique Name and mapping test results.

i think you are missing something in that graphical mapping side.

are you replacing "." with "A".  using replaceAll function?

Regards,

Muniyappan.

Former Member
0 Kudos

This message was moderated.

Answers (4)

Answers (4)

Muniyappan
Active Contributor
0 Kudos

Hi,

just curious are you able to solve this?

Regards,

Muniyappan.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You should use three different message mappings (one for each interface) and then reference them in your interface determination. Configure the receiver agreements accordingly.

Hope this helps,

Mark

Former Member
0 Kudos

hi,

Basically, you need to have a single mapping with three target message structures. Each target structure can be mapped to a constant or according to how the target is supposed  to be created.

if you are able to share the issue that you are facing when you are trying to do this, please post the same here.

Regards,

ninu

Muniyappan
Active Contributor
0 Kudos

Hi,

I have one question.

You have Three messages for one input.

i could see the values in output for three different scenarios as you mentioned in screen shots.

Are you obtaining this using Constants or Fixvalues?

you can achieve this using creating variable in the receiver side as mentioned by william's blog.

http://scn.sap.com/people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-gra...

create one udf.

you have to pass three input message fields to this UDF.

create one variable x.

use if condition and check the input values for three scenarios.

assign some values for variable x like 1 to first scenario,2 to second etc.. for each if condition.

and finally return x from your UDF.

map this udf to created variable in the output structure.

each time you can use this value to pass the constant to output fileds.

Regards,

Muniyappan.