Start of Content Area

Function documentation SplitByValue  Locate the document in its SAP Library structure

Use

SplitByValue() is the counterpart to removeContexts(): Instead of deleting a context, you can insert a context change in the source value queue. You then receive this element for each inserted context change instead of a top node element. However, for this to be possible, the top node source field must be assigned a top node target field and minOccurs must be >0. A maximum of minOccurs top node target fields can be inserted here.

You can insert a context change in the queue after each value, after each change to the value, or after each tag without a value.

Example

The following source structure enables the personal numbers of managers to be compiled in a list. The target structure requires that four rooms are occupied (minOccurs of rooms is 4, maxOccurs of rooms is 4). The first four managers from the list of managers are then distributed among the four rooms.

Source Structure (Left) and Target Structure (Right)

Field Name

minOccurs

maxOccurs

Field Name

minOccurs

maxOccurs

ManagerMsg

1

1

RoomsMsg

1

1

  managers

1

1

  room

4

4

    personalId

0

unbounded

    personalId

1

4

The context for personalId of the source structure is managers. There is only one context of this type. All personalId-elements are located in this context. To receive an additional context after each personalId tag, connect both personalId elements of the source and target structures, and use the function parameters to set the context change for each subelement of managers (Each Value). The manager context must also exist in the target structure. Therefore, assign the target field room to the source field managers.

Message Mapping Using SplitByValue()

Target Field Mapping

Value of SplitByValue()

/RoomsMsg=/ManagerMsg

 

/RoomsMsg/room=/ManagerMsg/managers

 

/RoomsMsg/room/personalId=
  SplitByValue(/ManagerMsg/managers/personalId)

Each Value

Since the frequency of room is set to exactly four, four contexts are generated. In other words, four times the element room with each context having a subelement personalId (the other managers do not get a room):

Example

Source Instance

Result

<?xml version="1.0"
  encoding="UTF-8"?>

 

<ManagerMsg>

  <managers>

    <personalId>
        PID001
    </personalId>
    <personalId>
        PID002
    </personalId>
    <personalId>
        PID003
    </personalId>
    <personalId>
        PID004
    </personalId>
    <personalId>
        PID005
    </personalId>
    <personalId>
        PID006
    </personalId>
    <personalId>
        PID007
    </personalId>

  </managers>

</ManagerMsg>

<?xml version="1.0" encoding="UTF-8"?>

 

<ns0:RoomsMsg
 xmlns:ns0="workshopDemo">

  <room>

    <personalId>
        PID001
    </personalId>

  </room>

  <room>

    <personalId>
        PID002
    </personalId>

  </room>

  <room>

    <personalId>
        PID003
    </personalId>

  </room>

  <room>

    <personalId>
        PID004
    </personalId>

  </room>

</ns0:RoomsMsg>

 

 

 

 

 

 

 

End of Content Area