cancel
Showing results for 
Search instead for 
Did you mean: 

Context issue?

Former Member
0 Kudos

I have a mapping problem.

I get the follwoing structure into my mapping.

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
	<ns0:Message1>
		<ns1:ResponseMsg>
			<C_NAP_AP_FLAG>PM</C_NAP_AP_FLAG>
			<E_MESCOD>MRM</E_MESCOD>
			<E_SYSTEM>QA</E_SYSTEM>
			<C_REFMES>APMM</C_REFMES>
		</ns1:ResponseMsg>
	</ns0:Message1>
	<ns0:Message2>
		<INVOIC02>
			<IDOC BEGIN="1">
				<EDI_DC40 SEGMENT="1">
				</EDI_DC40>
				<E1EDKA1 SEGMENT="1">
					<PARVW>RE</PARVW>
					<PARTN>XXX</PARTN>
					<LIFNR>XXX</LIFNR>
					<NAME1>XXX</NAME1>
				</E1EDKA1>
				<E1EDKA1 SEGMENT="2">
					<PARVW>RS</PARVW>
					<PARTN>YYY</PARTN>
					<LIFNR>YYY</LIFNR>
					<NAME1>YYY</NAME1>
				</E1EDKA1>
			</IDOC>
		</INVOIC02>
	</ns0:Message2>
</ns0:Messages>

If the following values appear

<E_SYSTEM> = QA

<PARVW> = RE

<PARTN> = XXX

Then i would like the following targetmessage.

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
	<ns0:Message1>
		<ns1:ResponseMsg>
			<C_NAP_AP_FLAG>PM</C_NAP_AP_FLAG>
			<E_MESCOD>MRM</E_MESCOD>
			<E_SYSTEM>QA</E_SYSTEM>
			<C_REFMES>APMM</C_REFMES>
		</ns1:ResponseMsg>
	</ns0:Message1>
	<ns0:Message2>
		<INVOIC02>
			<IDOC BEGIN="1">
				<EDI_DC40 SEGMENT="1">
				</EDI_DC40>
				<E1EDKA1 SEGMENT="1">
					<PARVW>RE</PARVW>
					<PARTN>ZZZ</PARTN>
					<LIFNR>XXX</LIFNR>
					<NAME1>XXX</NAME1>
				</E1EDKA1>
				<E1EDKA1 SEGMENT="2">
					<PARVW>RS</PARVW>
					<PARTN>YYY</PARTN>
					<LIFNR>YYY</LIFNR>
					<NAME1>YYY</NAME1>
				</E1EDKA1>
			</IDOC>
		</INVOIC02>
	</ns0:Message2>
</ns0:Messages>

So the PARTN in segment E1EDKA1 with a PARVW = RE will Be changed from XXX to ZZZ.

How would I solve this?

BR

Kalle

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I've done the following mapping.

E_SYSTEM ->     
Constant: QA -> equalS ->                                             
PARVW        ->   equalS ->       And ->
Constant: RE ->                                           Constant: ZZZ
                PARTN->                                 And ->                 IF -> SplitByValue -> PARTN
PARTN -> exsits -> IF ->                  equals ->        PARTN->
        Constant: [] ->    Constant: XXX ->

I hope you can follow the mapping above.

Do not get the deciered output.

BR

Kalle

stefan_grube
Active Contributor
0 Kudos

Instead of

PARTN->                                 And ->                 IF 
PARTN -> exsits -> IF ->                  equals ->        PARTN->
        Constant: [] ->    Constant: XXX ->

you should use PARTN - mapwithdefault - equals (constant"XXX") - if

another trick:

PARTN - mapwithdefault - fixvalues (XXX -> ZZZ, default = key) -

Edited by: Stefan Grube on Oct 7, 2010 2:18 PM

Former Member
0 Kudos

Hi Kalle,

a bit difficult doing it with the braincompiler

Your mapping looks pretty good, and I don't think you should have much problems with contexts. E_SYSTEM, as it occurs only once, you could use in the lowest context possible, eg. Messages or Message1, no harm in that. I don't think you need the SplitByValue, and you can keep PARNR and PARVW in their original context (as they share that context).

Displaying the queues of your mapping functions might help to see what's happening, eg. right-click on your IF function, and see what goes in and comes out. Sorry I can't be more specific.

kr,

Peter Glas

Former Member
0 Kudos
E_SYSTEM ---->
                          equalS---->
Constant(QA)-->                    
                                                AND----------------------->         (Const)XXX - THEN            
PARTN -> exists ----------->             PARTN ----->        AND----------IF -------------- >PARTN
                                                                   equalS----->            PARTN--ELSE
                                                   Constant(XXX)-- >

Change the context of PARTN to the root tag of the xml.

Edited by: nagarjuna _s on Oct 7, 2010 2:28 PM

Former Member
0 Kudos

The problem is that PARTN is 0...1 ocurrence.

If PARTN does not exist then I get the PARTN from the next segment in the target.

That would result in epic fail!

BR

Kalle

stefan_grube
Active Contributor
0 Kudos

> If PARTN does not exist then I get the PARTN from the next segment in the target.

That is the reason that you should not change context of PARTN.

If you keep the context and use mapwithdefault, then the target is supplied correctly.