cancel
Showing results for 
Search instead for 
Did you mean: 

Using createIf function

Former Member
0 Kudos

Hi all,

I am following this example.

http://help.sap.com/saphelp_nw04/helpdata/en/d9/3033f96c79674f90e3ab8d101a595b/content.htm

However i have a requirement such that the occurence of internalRequest and externalRequest of the target message should be 1..1

Thus when the source message has only <request type="internal">, externalRequest still needs to be created and the elements would be fill by empty constants.

Do i have to modify it to a field level kind of mapping?

Is there an easy way to achieve this?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can use mapWithDefault and enter a default value. Just mention an empty constant in that and map it with each field under external request. Whenever the value is not coming from source it will insert the constant. so your elements will be created but without any value.

Kulwinder

Reward if helpful

Former Member
0 Kudos

The problem is with the externalRequest node.

How can i create an externalRequest node in the target message if no external request is in the source message?

Edited by: SAP noob on Jul 1, 2008 7:01 PM

Former Member
0 Kudos

Hi,

ExternalRequest node has to be created everytime. right? it should be possible by direct 1..1 mapping. If value is internal populate it with the value else hardocde with constant.

Thanks

Amit

Former Member
0 Kudos

The problem is

Source message


<RequestListMsg>
  <request type="internal">
    <creator>
      creator1
    </creator>
    <contact>
      contact1
    </contact>
    <description>
       description1
    </description>
  </request>

  <request type="external">
    <creator>
      creator2
    </creator>
    <contact>
      contact2
    </contact>
    <description>
       description2
    </description>
  </request>
</RequestListMsg>

Target Msg


<ns0:RequestListEIMsg xmlns:ns0="workshopDemo">
 <internalRequest>
    <initiator>
      creator1
    </initiator>
    <contact>
      contact1
    </contact>
    <issue>
      description1
    </issue>
 </internalRequest>

 <externalRequest>
    <initiator>
      creator2
    </initiator>
    <contact>
      contact2
    </contact>
    <issue>
      description2
    </issue>

 </externalRequest>
</ns0:RequestListEIMsg>

So if source msg does not have <request type="external">, i would like to still create the <externalRequest> in the target message and fill in the elements with empty values.

How can this be achieve?

Edited by: SAP noob on Jul 2, 2008 9:01 AM

former_member194786
Active Contributor
0 Kudos

Hi,

Use the exists function to check whether your external node is present or not. If present map the target field to the source field else map the target field with blank constants.

Hope it helps.

Regards,

Sanjeev.

former_member190389
Active Contributor
0 Kudos

if the occurrence of externalRequest node is 1..1 i.e mandatory .. then no need to worry it will get created automatically even if you dont map.

Edited by: Progirl Progirl on Jul 2, 2008 12:21 PM