cancel
Showing results for 
Search instead for 
Did you mean: 

1:2 Mapping Scenario

Former Member
0 Kudos

Hello all,

Please provide some helps to achieve the mapping scenario specified below:

I would like to map the Source Message to 2 Target Messages based on the value of <STATUS> ('G' or 'F'). And the 2 Target Messages will be later on used by 2 SEND steps to map them into 2 JDBC-format messages to insert 2 different tables (bulk insert).

Please tell me how to correctly configure the mapping scenario. I've tried to map them via graphical mapping(using "If without Else"), but didn't work when both 'G' and 'F' records exist in the Source Message.

<b>Source Message</b>

<XML>

<LOT> (0~unbounded)

<HEADER>

<STATUS> (1~1)

</HEADER>

<BODY>

<PO_NUM> (1~1)

</BODY>

</LOT>

</XML>

<b>Target Message</b>(same structure for both target messages)

<XML>

<LOT> (0~unbounded)

<STATUS> (1~1)

<PO_NUM> (1~1)

</LOT>

</XML>

Regards,

Steve

Accepted Solutions (1)

Accepted Solutions (1)

bhavesh_kantilal
Active Contributor
0 Kudos

Steve,

Create 2 Message Types using the same Target Datatype and then create 2 Corresponding message Interfaces.

Now, in the mapping include both the target message types as your target messages and then do the needful in the mapping using ifwithoutelse.

Regards,

Bhavesh

Former Member
0 Kudos

Hi Bhavesh,

<i>Now, in the mapping include both the target message types as your target messages and then do the needful in the mapping using ifwithoutelse.</i>

Could you specify the mapping in details? Cuz' mine didn't work.

Regards,

Steve

bhavesh_kantilal
Active Contributor
0 Kudos

Steve,

Basically prakash and myself have given the same idea. In details

<u>Message Mapping</u>

Source Message --     MessageType1
                      MessageType2

Now, while mapping the Lot / Fields of the Message Type 1 , use the following logic

Source --Lot-- Status --  
                       IFWITHOUTELSE  --- Target Fields
Constant =f

Same logic for the Lot / Fields of Message Type 2 just the constant will change.

Regards,

Bhavesh

Former Member
0 Kudos

Bhavesh,

This mapping configurations is what I have, but if there are 'G' and 'F' records mixed in the Source Message, there would be a mapping error:

-


IF

Source/Lot/Status = Constant(G)

Then

Target1/Lot/PO_NUM = Source/Lot/PO_NUM

IF

Source/Lot/Status = Constant(F)

Then

Target2/Lot/PO_NUM = Source/Lot/PO_NUM

And somehow I had to include the configuration below;otherwise, the records won't be populated.

-


IF

Source/Lot/Status = Constant(G)

Then

Target1/Lot = Source/Lot

IF

Source/Lot/Status = Constant(F)

Then

Target2/Lot = Source/Lot

Regards,

Steve

former_member206604
Active Contributor
0 Kudos

Hi Steve,

Lets take the following eg:

Source_MT

-RecordSet

--Field1

--Status

Target1_MT

-RecordSet

--Field1

--TStatus

Target2_MT

-RecordSet

--Field1

--TStatus

Your mapping should be


Status  
       
        Equals --> IFWithoutElse --Target1_MT/RecordSet  
       /                /
Constant("F")       Source_MT/RecordSet

Simillarly


Status  
       
        Equals --> IFWithoutElse --Target2_MT/RecordSet  
       /                /
Constant("G")       Source_MT/RecordSet

Try this and let me know

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

Thanks for the response. Here are what I've found with your suggestion.

<b>1)</b>

I still need to map the following, since their occurences are "1..1":

Field1 -> Field1

Status -> TStatus

<b>2)</b>

The error remains the same:

Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd.

3)

I've even tried 1:1 mapping, but the error remains the same whenever there are 'G' & 'F' records mixed in the Source_MT.

Regards,

Steve

Former Member
0 Kudos

Hi Prakash,

Here are the configurations that I have for 1:1 mapping. (only mapping records with 'G' Status to Target_MT as a workaround for 1:2 mapping, but this still doesn't work. Whenever there are 'G' & 'F' records co-exist, a mapping error is caused.) Please take a look at them.

Source_MT

-Header

--VendorCode (1..1)

--Contact (1..1)

-Body

--Lot (0..unbounded)

---PoNum (1..1)

---Status (1..1)

Target_MT

-Header

--VendorCode (1..1)

--Contact (1..1)

-Body

--Lot (0..unbounded)

---PoNum (1..1)

---Status (1..1)

Target_MT/Header/VendorCode = Source_MT/Header/VendorCode

Target_MT/Header/Contact = Source_MT/Header/Contact

IF Status Equals Constant("G")

Then Target_MT/Body/Lot = Source_MT/Body/Lot

IF Status Equals Constant("G")

Then Target_MT/Body/Lot/PoNum = Source_MT/Body/Lot/PoNum

IF Status Equals Constant("G")

Then Target_MT/Body/Lot/Status = Source_MT/Body/Lot/Status

Regards,

Steve

former_member206604
Active Contributor
0 Kudos

Hi Steve,

You need to change the <b>context</b> of the <b>Status</b> to root level I mean to <b>Messages</b> level.

If the payload has both G and F fine... what is it has either G or F? I hope you are handling that as well.

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

<i>You need to change the context of the Status to root level I mean to Messages level.</i>

Which level specifically regarding my XML structure?

<i>If the payload has both G and F fine... what is it has either G or F? I hope you are handling that as well.</i>

The situation now is, if the payload has both G and F records, the mapping would show the message:<b>Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd.</b> If it only has either G or F records, the mapping is fine.

Regards,

Steve

former_member206604
Active Contributor
0 Kudos

Hi Steve,

You need to change to root level that is Messages.

As you are doing multimapping your root level will be Messages

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

Do you mean to perform the changes below? It still doesn't work.

Target_MT

-Header

--VendorCode (1..1)

--Contact (1..1)

-Body

--Lot (0..unbounded)

---PoNum (1..1)

---Status (1..1)

to

Target_MT

-Header

--VendorCode (1..1)

--Contact (1..1)

-Lot (0..unbounded)

--PoNum (1..1)

--Status (1..1)

Regards,

Steve

former_member206604
Active Contributor
0 Kudos

Hi Steve,

When you are mapping the Status node with IFWithoutElse... <b>right click the Status node</b> and you will see a menu called<b> Context</b>... and by default it will be at <b>Lot</b> level. Change that context to <b>Messages</b> (root level)

Former Member
0 Kudos

Hi Prakash,

Ah~~~~~~~~~~~~by trying your suggestion, I finally got what I wanted. Thanks a bunch ah~~~~~~~~~~~~~~~~~~~

What is the reason behind this though?

Regards,

Steve

Former Member
0 Kudos

Hi Steve,

The best way to find out what difference the Context Change makes to output of mapping is to Test the Mapping and then go to the step -> Right click -> Display Queue.

Also check this link http://help.sap.com/saphelp_nw04/helpdata/en/bd/ca1105c81c6742a0f8c8d49f8834bf/content.htm

It explains the concept of Contexts and their use in mapping

Hope this helps.

Regards,

Seema

Former Member
0 Kudos

Seema,

I'll look into that. Thanks for providing the information.

Regards,

Steve

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Steve,

method that I specified is:

mapping1 = source -> target1

mapping2 = source -> target2

in interface determination use the interface and give the 'Condition' for it. then select the correct mapping. In this approach you do not need to create IF or context object in DESIGN. All the work can be done in CONFIG.

Otherwise you can use other methods provided above i.e. using IfWithoutElse in mapping or context.

Regards,

Faiq

Former Member
0 Kudos

Hi Steve,

The easiest way would be to create the 2 message mappings. Put the required condition 'G' or 'F' in the interface determination in Config.

It will link to the required mapping depending on your condition.

Hope it helps.

Regards,

Faiq

Former Member
0 Kudos

faiq,

I AM trying 2 message mappings which are 1:1. But with the configurations I included in my previous post, the mappings still don't work.

Regards,

Steve

former_member206604
Active Contributor
0 Kudos

Hi Steve,

How are you doing this? Is it using multimapping?

Try this

1. You should me already defined a target structure say MT_Targ and now copy that message type and create one more with a different name MT_Targ2

2.You wil be having 2 Inbound Interface 1 having MT_Targ and the other with MT_Targ2

3. In the message mapping got to the message tab and in the target side add MT_Targ2 also

4. Do the mapping with IFWihoutElse. Also make sure the same condition should also be applied while mapping MT_Src>Mt_Targ and MT_Src>MT_Targ2

5. Do the respective change in the interface mapping.

Regards,

Prakash

Former Member
0 Kudos

Hi Prakash,

<i>4. Do the mapping with IFWihoutElse. Also make sure the same condition should also be applied while mapping MT_Src>Mt_Targ and MT_Src>MT_Targ2</i>

Could you specify the mapping details? Cuz' what I have didn't work.

<i>5. Do the respective change in the interface mapping.</i>

What kind of change?

Regards,

Steve