cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping element from a different line item

Former Member
0 Kudos

Hi Experts,

I have a structure that looks like this,


LINE
 line1
  item1
  item2
 line2
  item1
  item2
 line3
  item1
  item2

and the target structure will look like this,


SEGMNT
 line1
  item1
  item2
 line2
  item1
  item2
 line3
  item1
  item2

Now, if item2 in line1 of source is missing then I want to map item2 of line2 of source to item2 of line1 of target. Please let me know how to go about this?

Thanks,

Dhawal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

i have done it with the standard functions.

How can i put a picture in here?

maybe this link works.

http://www.flickr.com/photos/48896701@N02/4479626478/sizes/o/

Edited by: Franz Schwarz on Mar 31, 2010 7:42 PM

Former Member
0 Kudos

Hi Franz,

Thanks for your efforts. I could see the mapping. I will give it a try.

Regards,

Dhawal

Former Member
0 Kudos

Hi Franz,

Full marks to you (and points too)

Problem is solved. Thanks for your help.

Best Regards,

Dhawal

Answers (6)

Answers (6)

Former Member
0 Kudos

try this:

[http://s3.directupload.net/file/d/2115/2azvy7lk_jpg.htm]

Former Member
0 Kudos

Hi Franz,

This link is blocked here. Can you please explain the logic of the UDF?

Thanks,

- Dhawal

Former Member
0 Kudos

thats ok, but is this also possible:

Source Payload

<class>

<student>

<name>ABC</name>

<grade></grade>

<student>

<name>XYZ</name>

<grade>A</grade>

<student>

<name>123</name>

<grade></grade>

<student>

<name>PQR</name>

<grade>B</grade>

Former Member
0 Kudos

No, this is not possible. Only 3 instances with value from the first instance missing.

zameerf
Contributor
0 Kudos

Hi Dhawal,

Is your requirement only for the 'item2' field of 'line1' node in target?

If so, what has to be mapped to target, if 'item2' field of 'line1' node in source is available?

Regards,

Zameer

Former Member
0 Kudos

Hi,

I will add payloads here to explain the situation in more detail.


Source Payload

<class>
 <student>
  <name>ABC</name>
  <grade></grade>
 </student>
 <student>
  <name>XYZ</name>
  <grade>A</grade>
 </student>
 <student>
  <name>PQR</name>
  <grade>B</grade>
 </student>
</class>


Current Target Payload

<Target_class>
 <student>
  <name>ABC</name>
  <grade></grade>
 </student>
 <student>
  <name>XYZ</name>
  <grade>A</grade>
 </student>
 <student>
  <name>PQR</name>
  <grade>B</grade>
 </student>
</Target_class>


Required Target Payload

<Target_class>
 <student>
  <name>ABC</name>
  <grade>A</grade>          // Here, grade A shoube be picked up from next student (XYZ)
 </student>
 <student>
  <name>XYZ</name>
  <grade>A</grade>
 </student>
 <student>
  <name>PQR</name>
  <grade>B</grade>
 </student>
</Target_class>

Now I understand that I need to write UDF for this, the question is HOW? Please guide me in this direction.'

Thanks,

Dhawal

Former Member
0 Kudos

hi,

it's difficult, but possible.

you have to do it with context changes and split by value.

maybe i'll can give you a example.

i will provide it, if i have it.

regards

franz

Former Member
0 Kudos

Hi Dhawal.

Can you explain more clearly.

line1,line2,line3 are in the same level.?

Former Member
0 Kudos

Hi,

line1, line2, line3 are at same level. In fact these are the exact same structures, or I should say these are instances of the same structure. Ok, I will refine my question. I will give a more relalistic view of my source structure


CLASS
 student
  name = 'ABC'
  grade = blank
 student
  name = 'XYZ'
  grade = 'A'
  .
  .
  .

Now my requirement is that I want to assign grade of XYZ to grade of ABC. There might be few more 'student' structures below these two but I want to get grade value from second structure itself, i.e. grade of XYZ

Thanks,

Dhawal

Former Member
0 Kudos

Hi.


I want to get grade value from second structure itself,

Well you need to write and UDF.

Can you put payload example ?

Source and target.

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>Now, if item2 in line1 of source is missing then I want to map item2 of line2 of source to item2 of line1 of target. Please let me know how to go about this?

this requirement is not clear

what if you miss the least item2 in line3 ? then the first one ? or none ? or what?

anyway you can put anything you need inside a UDF but at first you need to have a complete logic

it may not be possible without writing some code in an UDF

Regards,

Michal Krawczyk