cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping / UDF

Former Member
0 Kudos

Hi,

I have a sourc structure like this:

-<ListOfNPAccountNP>

-<NPAccount>

-<ListOfNPAccount_BusinessAddress>

-<NPAccount_BusinessAddress>

some fields

-</NPAccount_BusinessAddress>

-</ListOfNPAccount_BusinessAddress>

-<ListOfNPAccount_Industry>

-<NPAccount_Industry>

<b> -<ThampsonCode>S11111</ThamsonCode></b> -</NPAccount_Industry>

-<NPAccount_Industry>

<b> -<ThampsonCode>T22222</ThamsonCode></b> -</NPAccount_Industry>

-<NPAccount_Industry>

<b> -<ThampsonCode>Y33333</ThamsonCode></b> -</NPAccount_Industry>

-</ListOfNPAccount_Industry>

-<ListOfBackOfficeAccountRelationship>

-<BackOfficeAccountRelationship>

some fields

-</BackOfficeAccountRelationship>

-</ListOfBackOfficeAccountRelationship>

-</NPAccount>

-</ListOfNPAccountNP>

The structure (item level) in bold and the field 'ThampsonCode' is repeating max three times. I need to map with target SAP fields Code1, Code2 & Code3, which are at header level. Here the condition i need to check is, if that field's starting letter is "S" then i need to map with "code1", if it is "T" then "code2", if it is "Y" then "Code3".

I have achieved this with a graphical mapping, that is working absolutely fine even for one code, two codes, three codes or even for blank fields. But the problem is, since these fields are not mandatory either sides, sometimes the source is ignoring the structure in that case, i am getting my xml file tag as <b><ListOfNpAccount_Industry/></b> resulting to “Mapping Error”

I have designed my mapping as "if CODE start with 'S' then CODE else blank- > removecontext -> sort descend -> copy value -> TARGET.

Plz let me know, still I can achieve this with graphical mapping adding some more functions, if not, suggest me a UDF.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vijaya,

if it is working fine with a blank source value you could use the standard function mapWithDefault at the beginning and use a blank value as the default, so if the value is missing in the source you get the default value and build your logic upon this.

Kind Regards,

Sergio

Former Member
0 Kudos

Hi,

As i mentioned, it's working fine with blank source tag, whereas when there is no source tag, it's throwing an error. My problem is, it's not a mandatory field, hence sometimes, the structure is coming empty resulting to an mapping error. Any inputs?

regards

Former Member
0 Kudos

Vijaya, since you are dealing with a field that is not mandatory in the source XML , make an <b>exists</b> check and map this to a if-then function. Code your logic and map it to the then part. Is this what you are looking at ?

Regards

Saravana

Former Member
0 Kudos

Hi,

No Saravana, i tried tht too... but no luck.. it seems UDF is inevitable...

regards

prabhu_s2
Active Contributor
0 Kudos

did u try to use the exists node f/n for ListOfNPAccount_Industry and then map the condtion to target? hope this shud help

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

If it not working , and your target field is having 1.1 occurr, then please try to map with mapwithdefault GM function.

Regards

Chilla..

Former Member
0 Kudos

Hi guys,

thanks for your advice and support. I have achieved this with java mapping.

regards

Former Member
0 Kudos

Hi,

You have tried by adding mapWithDefault which Replaces empty contexts in the inbound queue with a default value, which you specify in the function properties. Please see this help for some information on this:

http://help.sap.com/saphelp_nw04/helpdata/en/2c/2d8c4024d26e1de10000000a1550b0/content.htm

---Satish