cancel
Showing results for 
Search instead for 
Did you mean: 

Need UDF help regarding Mapping

Former Member
0 Kudos

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>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Amit/Praveen,

It's working if Record segment comes once.but if record segment comes twice. its going wrong

praveen_sutra
Active Contributor
0 Kudos

Hi Mahesh,

1)     Would suggest to check the occurrence of receiver structure.

2)     Please see mapping for other fields

thanks and regards,

Praveen T

Former Member
0 Kudos

Hello,

I think u r not mapping target node properly. Change the context of "Item" and set it to MT_Name (source) and then map "Item" node with Target MT*** Name.

For Target "Item" field mapping, just map the same with constant.

Thanks

Amit Srivastava

Answers (4)

Answers (4)

praveen_sutra
Active Contributor
0 Kudos

thanks and regards,

Praveen T

JaySchwendemann
Active Contributor
0 Kudos

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

JaySchwendemann
Active Contributor
0 Kudos

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-mapp...

context

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

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

peter_wallner2
Active Contributor
0 Kudos

Hello Mahesh,

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

Best regards,

Peter