cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting in Mapping

itabhishek9
Participant
0 Kudos

Hi SDNites,

I have a mapping scenario in which values has to be summed up after sorting the records. Can you please guide how can this be done i.e. can it be achieved using message mapping without UDF or do I need to use UDF mandatorily?

Input,

VBELN POSNR MATNR QTY

123 10 MAT1 2

234 10 MAT1 4

123 20 MAT2 5

123 30 MAT1 3

123 10 MAT1 8

234 10 MAT1 3

234 20 MAT2 4

Output,

VBELN POSNR MATNR QTY

123 10 MAT1 10 (Value summed up)

123 20 MAT2 5

123 30 MAT1 3 (Same material but not summed as different position)

234 10 MAT1 7

234 20 MAT2 4

I have to produce the right vbeln, posnr, matnr against the summed up quantity. Can you please advise how can this be achieved.

Regards,

Abhi

Accepted Solutions (0)

Answers (2)

Answers (2)

juan_vasquez2
Active Participant
0 Kudos

Hi Abhishek,

You can use message mapping

Sort Key element

element ----> removeContexts-- -> sort-- -> splitByValue[value change]

Other elements depend form key element

element_no_PK ---> removeContexts -----> sortByKey

Regards

Juan

ArielBravo
Active Participant
0 Kudos

Hello Abhishek,

For this kind of duties, one approach that has worked with me is using XSLT transformations. There is an specific command to sort the data and you could even summarise using xslt. It is clean and straight forward.

Have a look into the sort and sum commands

https://www.w3schools.com/xml/xsl_sort.asp

Regards,

Ariel