Skip to Content
avatar image
Former Member

Message Mapping Problem

I have an interface which creates an IDoc in XI based on the contents of a file. The file has a header and detail record. And the IDoc has various nested segments.

The header record in the input file is linked to a top-level segment in the Idoc, and the detail record in the input file is linked to a segment within the top-level segment (at the level below).

The problem is that I need to populate some fields in the 'detail IDoc segment' using data from the header of the input file. As the header occurs only once, and the detail segment in the IDoc can occur multiple times, this causes the fields to only be transferred for the first detail segment. In all the other detail segments in the IDoc these fields are blank.

If I define the header record in the in the input file to be 'occurs 0-unbounded', and edit the XML message in the mapping test tool to have X headers, then there is no problem as long as there is no more then X detail records/detail segments.

I have also found a work around, which store the values in  a global container and retrieves it in a second user defined function, but this would not be very good if there were many fields required from the header record in the input file.

This seems like a major problem with the XI mapping tool. Has anyone else experienced this, and/or found a solution?

Thanks,

Jason Hartley

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Dec 16, 2003 at 06:56 PM

    Jason,

    Use the "Copy Value" function (under the Constants section) when mapping the header fields to fields in a repeating group.  This function essentially turns the value from the header into a constant that is reused each time the group repeats.

    Regards,

    Chris

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I did try what you suggest before I posted my message, as I thought it might do what you say (it sounds like it from the function name). However, this didn't work, and after looking at the documentation, it seems that this is  not the purpose of the function.

      The function is used if you have a field which has a max occurs > 0, and wish to transfer the various occurences to different fields in your target structure (see 'SAP Exchange Infrastructure: Designing Mappings' document for more info).

      -Jason

  • avatar image
    Former Member
    Jul 14, 2004 at 05:51 PM

    Hello Jason,

    I am having problems mapping an input file to be 'occurs 0-unbounded' to an IDOC. Could you please provide me with a sample of Java mapping which it seems you used for mapping? Or any other sample.

    Thanks,

    Yogesh

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 15, 2004 at 07:31 AM

    Hall Jason,

    I suppose you have the a source structure like the following:

    <xsd:element name="Items" type="Items"></xsd:element>

    <xsd:complexType name="Items">

    <xsd:sequence>

    <xsd:element name="Header" ></xsd:element>

    <xsd:element name="Detail" maxOccurs="unbounded"></xsd:element>

    </xsd:sequence>

    </xsd:complexType>

    and as target structure

    <xsd:element name="ItemsFlat" type="ItemsFlat"></xsd:element>

    <xsd:complexType name="ItemsFlat">

    <xsd:sequence>

    <xsd:element name="Item" type="FlatStructureType" maxOccurs="unbounded"></xsd:element>

    </xsd:sequence>

    </xsd:complexType>

    <xsd:complexType name="FlatStructureType">

    <xsd:sequence>

    <xsd:element name="Value1"></xsd:element>

    <xsd:element name="Value2"></xsd:element>

    </xsd:sequence>

    </xsd:complexType>

    You want to map the hierarchical source structure to a flat

    target structure. Simply speaking you want to map Header to Value1 and Detail to Value2.

    This is possible. Here is the textual representation of the Message Mapping definition:

    /ns1:ItemsFlat=/ns1:Items

    /ns1:ItemsFlat/Item=/ns1:Items/Detail

    /ns1:ItemsFlat/Item/Value1=CopyValue[nnumber=0](/ns1:Items/Header)

    /ns1:ItemsFlat/Item/Value2=SplitByValue[type=Each value](/ns1:Items/Detail)

    This means you have to map the unbounded element Detail to the unbounded element Item,

    the Heder element to Value1 using the CopyValue function,

    and the Detail element with the SplitByValue function to the Value2 element.

    The SplitByValue function is necessary to add addtional contexts. A context insert does always mean produce a super element.

    Regards Franz

    Add comment
    10|10000 characters needed characters exceeded