cancel
Showing results for 
Search instead for 
Did you mean: 

PI Mapping - create new target if subnode matches value

08-12-2020 12:15 PM
973 views 4 comments
0 Likes
SAP Managed Tags
Subscribe

Hello together,

im currently working on a message mapping i'm having some trouble with.

First of all, source structure:

- root (1)

-- item (1:N)

--- payment (1:N)

---- id (1:1)

---- amount (1:1)

target:

- root (1)

-- item (1:N)

--- condition (1:N)

---- amount (1:1)

I want to create a single "condition" node for my item, if one of the payment-ids matches a specific id. the amount should then be summed up. i have tried it with the equalS text function which creates seperate condition-nodes. But i only need one to be created. If i use a removeContext it works for a single item but creates the condition-nodes in the first item if there are multiple items in the source.

Now i'm kind of stuck what i should do next 😄

thanks in advance!

BR

Pascal

0 Likes

Accepted Solutions (0)

Answers (4)

Answers (4)

0 Likes

Hi Shashi,

well - i thought ive fixed it 😄

Unfortunately the COND-Segment gets created multiple times and i dont understand why?

0 Likes

Hi Shashi,

i think i've fixed it.

In the E1BPCOND-Mapping i now check for the payment id equalS the certificate constant. I have set it to the order context - it was on payments before, i think that was my mistake.

The first few tests looked good 🙂

0 Likes

Hi Shashi,

sorry for the late response.

sample input is:

<orders>
<order order-no="0110002604">
<order-date>2020-08-17T09:20:51+00:00</order-date>
<currency>CHF</currency>
<customer-locale>fr_CH</customer-locale>
<payments>
<payment>
<amount>10</amount>
<processor-id>B1</processor-id>
<transaction-id>XXXXXX</transaction-id>
</payment>
</payments>
</order>
<order order-no="0110002607">
<order-date>2020-08-17T09:29:56+00:00</order-date>
<currency>CHF</currency>
<customer-locale>de_CH</customer-locale>
<payments>
<payment>
<amount>39.90</amount>
<processor-id>BASIC_GIFT_CERTIFICATE</processor-id>
<transaction-id>XXXX123456789</transaction-id>
</payment>
<payment>
<amount>20.00</amount>
<processor-id>BASIC_GIFT_CERTIFICATE</processor-id>
<transaction-id>XXXX123456790</transaction-id>
</payment>
</payments>
</order>
</orders>

Output would be:

<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
	<ns0:Message1>
		<SALESORDER_CREATEFROMDAT202>
			<IDOC BEGIN="1">
				<E1SALESORDER_CREATEFROMDAT2 SEGMENT="1">
					<SALESDOCUMENTIN>0110002604</SALESDOCUMENTIN>
					<E1BPCOND SEGMENT="1">
						<ITM_NUMBER>100</ITM_NUMBER>
						<COND_TYPE>ZVKP</COND_TYPE>
						<CONDVALUE>19.9</CONDVALUE>
						<CURRENCY_2>CHF</CURRENCY_2>
						<TAX_CODE>Z3</TAX_CODE>
					</E1BPCOND>
					<E1BPCOND SEGMENT="1">
						<ITM_NUMBER>200</ITM_NUMBER>
						<COND_TYPE>ZVKP</COND_TYPE>
						<CONDVALUE>1197</CONDVALUE>
						<CURRENCY_2>CHF</CURRENCY_2>
						<TAX_CODE>Z3</TAX_CODE>
					</E1BPCOND>
				</E1SALESORDER_CREATEFROMDAT2>
			</IDOC>
		</SALESORDER_CREATEFROMDAT202>
		<SALESORDER_CREATEFROMDAT202>
			<IDOC BEGIN="1">
				<E1SALESORDER_CREATEFROMDAT2 SEGMENT="1">
					<SALESDOCUMENTIN>0110002607</SALESDOCUMENTIN>
					<E1BPCOND SEGMENT="1">
						<ITM_NUMBER>100</ITM_NUMBER>
						<COND_TYPE>ZVKP</COND_TYPE>
						<CONDVALUE>19.9</CONDVALUE>
						<CURRENCY_2>CHF</CURRENCY_2>
						<TAX_CODE>Z3</TAX_CODE>
					</E1BPCOND>
					<E1BPCOND SEGMENT="1">
						<ITM_NUMBER>200</ITM_NUMBER>
						<COND_TYPE>ZVKP</COND_TYPE>
						<CONDVALUE>20.00</CONDVALUE>
						<CURRENCY_2>CHF</CURRENCY_2>
					</E1BPCOND>
					<E1BPCOND SEGMENT="1">
						<COND_TYPE>ZOG1</COND_TYPE>
						<COND_VALUE>59.99</COND_VALUE>
						<CURRENCY>CHF</CURRENCY>
					</E1BPCOND>
				</E1SALESORDER_CREATEFROMDAT2>
			</IDOC>
		</SALESORDER_CREATEFROMDAT202>
	</ns0:Message1>
</ns0:Messages>

As you can see, the second order has two payments with id BASIC_GIFT_CERTIFICATE. In the result, the condition ZOG1 should be created with the sum of these certificates. but only the corresponding. if the payment with the given id does not exist it should not create a condition segment for it.

I have deleted the rest of the xml, so it might be a tad confusing.

thanks for your help!


BR
Pascal

Shashi_Bhushan_Kumar
Active Participant
0 Likes

Hi Pascal,

Please paste your sample input xml and desired output xml. I will do the mapping and share it with you.