Skip to Content
author's profile photo Former Member
Former Member

Need UDF help regarding Mapping

Hi Guys,

we have our outbound structure like

<MT_HEADER>
<Record>(0:unbound)
<Status>(0:unbound)
<Item>(0:unbound)
<fields>

Our Target structure is

<Item>

<fields>

<Status>(0:unbound)

<Index>

<Desc>

For every item we split and create a file to target using multimapping. Status field was added recently in the structure. All da statuses that comes under one <Record> should be mapped for all the items.

Ex: If they are 5 statuses under one Record node. Each item should have those 5 status fields with index 0 to 5 and respective status.

Sample example:

Source:

<MT_HEADER>

<Record>

<Status>Yes</Status>

<Status>EX</Status>

<Item>

<Field>UED</Field>

<Item>

<Field>EUR</Field>

Expected output after multimapping is

File1:

<Item>

<Field>UED</Field>

<Status>

<Index>1</Index>

<Desc>Yes</Desc>

<Status>

<Index>2</Index>

<Desc>EX</Desc>

File2:

<Item>

<Field>EUR</Field>

<Status>

<Index>1</Index>

<Desc>Yes</Desc>

<Status>

<Index>2</Index>

<Desc>EX</Desc>

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Aug 29, 2013 at 08:25 AM

    Hello,

    I believe u are already done with Item's and Field's mapping and the only part where u r stuck is Status target field mapping. So u can refer the below attached UDF for the same:

    Execution Type: All values of a context

    Input Var1 and Var2

    for(int i=0;i<var1.length;i++){for(int j=0;j<var2.length;j++){result.addValue(var2[j]);}if(i+1<var1.length)result.addContextChange();}

    Mapping:

    Thanks

    Amit Srivastava


    Capture.PNG (17.9 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 29, 2013 at 08:31 AM

    thanks and regards,

    Praveen T


    sol11.JPG (57.8 kB)
    sol12.JPG (19.9 kB)
    sol13.JPG (15.9 kB)
    sol14.JPG (17.7 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 29, 2013 at 08:13 AM

    Hello Mahesh,

    Can you also do it with XSLT? That would be easier than a UDF.

    Best regards,

    Peter

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 29, 2013 at 08:21 AM

    I'm not perfectly positive but this might also be possible using only graphical mapping / multi - mapping. So there might not be need for UDF.

    I once did this for an IDoc splitting on one field (TANUM) utilizing built-in functions like "CopyValue", "useOneAsMany" and shifting Context on TANUM field.

    If you want to go the graphical mapping way, you may want to read some stuff about

    message split

    http://scn.sap.com/people/claus.wallacher/blog/2006/06/29/message-splitting-using-the-graphical-mapping-tool

    context

    http://scn.sap.com/people/riyaz.sayyad/blog/2006/04/23/introduction-to-context-handling-in-message-mapping

    built-in functions

    http://scn.sap.com/people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-part-ii

    general about graphical mapping

    http://scn.sap.com/people/sravya.talanki2/blog/2005/08/16/message-mapping-simplified--part-i

    http://scn.sap.com/docs/DOC-22620

    Cheers

    Jens


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 29, 2013 at 08:28 AM

    Oh, and of course as Peter mentioned, XSLT would probably fit in, too

    Have a look at <xsl:template match="<XPATH>"> and <xsl:value-of select="<XPATH>"/>

    HTH

    Cheers

    Jens

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.