cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping node name and value

Former Member
0 Kudos

Hi,

I have source strcture as

ID

Code

Dept

City

My target structure is

Name

Value

After mapping i need my target xml file to be

<Object>

<Name>ID</Name>

<Value>001</Value>

<Name>Code</Name>

<Value>XYZ</Value>

<Name>Dept</Name>

<Value>SAP</Value>

<Name>City</Name>

<Value>NY</Value>

</Object>

Any input?

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

The recursive template is explained in the following weblog.

/people/udo.martens/blog/2006/04/26/xslt-recursive-templates

For XSL, refer to w3schools.org, http://www.w3schools.com/xsl/xsl_languages.asp

Thanks,

Prateek

STALANKI
Active Contributor
0 Kudos

One simple way to do in message mapping if the source structure is as simple as that then I do not recoommend java or xslt..

write a small udf which takes ID,Code,DEPT,CITY.

result.addValue("ID").

result.addValue("Code").

result.addValue("DEPT").

result.addValue("CITY").

MAP THIS to name..:)

write a small udf which takes ID,Code,DEPT,CITY.

result.addValue(a).

result.addValue(b).

result.addValue(c).

result.addValue(d).

a=id..b=code in UDF...!

Hope I didnot understand the requiremnet in a simple fashion:)

Former Member
0 Kudos

let me explain my scenario more clearly...

My source message is Idoc whose structure is as follows

IDOC 1..1

- E1AFKOL 1..1

Dept

Code

-- E1AFKOL 0..99999

-


E1AFVOL 0..99999

-


E1RESBL 0..99999

Charg

Now my otarget strcuture is

ObjectCollection 1..1

-Object 0..99999

--Field 0..99999

Name

Value

Now what i want is, for each occurance of Segment E1AFVOL, Object node should get repeated and for each occurance of segment E1RESBL (child of segment E1AFVOL) 'Field' node should be repeated.

e.g. Input is

IDOC 1..1

- E1AFKOL 1..1

Dept SAP

Code 001

-- E1AFKOL 0..99999

-


E1AFVOL 0..99999

-


E1RESBL 0..99999

Charg A1

-


E1RESBL 0..99999

Charg A2

-


E1AFVOL 0..99999

-


E1RESBL 0..99999

Charg A1

Therefor output would be

ObjectCollection

-<Object>

--<Field>

Name CHARG

Value A1

Name Dept

Value SAP

Name Code

Value 001

--</Field>

--<Field>

Name CHARG

Value A2

Name Dept

Value SAP

Name Code

Value 001

--</Field>

-</Object>

-<Object>

--<Field>

Name CHARG

Value A1

Name Dept

Value SAP

Name Code

Value 001

--</Field>

-</Object>

i am not sure if this can be achieved by graphical mapping.

If not please explain me how XKST mapping would be used in this case?

Former Member
0 Kudos

Hi,

You can use either java or XSLT mapping to achieve this as this is not possible using message mapping.

Refer to following demo.

https://media.sdn.sap.com/SDNTV/main.asp?mediaId=109 - Java Mapping.

https://media.sdn.sap.com/SDNTV/main.asp?mediaId=116 - XSLT mapping

Thanks,

Prateek

Former Member
0 Kudos

Hi Yashpal,

Anyway you have a fixed Message type and structure will not change right?? Then why dont you hardcode all the field names in mapping and just pass the values as it is.

Regards,

Ananth

Former Member
0 Kudos

Hi Yashpal,

AFAIK, You can't acheive this functionality in Graphical mapping. So you can try Java mapping for the same.

Please refer the following links.

<a href="/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i">Java Mapping Blog</a>

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm">SAP Help-Java Mapping</a>

Regards,

Ananth