cancel
Showing results for 
Search instead for 
Did you mean: 

Sum Fields based on change in another field

Former Member
0 Kudos

I have data that looks like this

<Records>

<VBLEN>123</VBLEN>

<MATNR>012356</MATNR>

<ZSPR>1.02</VBLEN>

</Records>

<Records>

<VBLEN>123</VBLEN>

<MATNR>568954</MATNR>

<ZSPR>2.05</ZSPR>

</Records>

<Records>

<VBLEN>856</VBLEN>

<MATNR>259865</MATNR>

<ZSPR>5.98</ZSPR>

</Records>

<Records>

<VBLEN>856</VBLEN>

<MATNR>359874</MATNR>

<ZSPR>4.12</ZPSR>

</Records>

<Records>

<VBLEN>856</VBLEN>

<MATNR>985698</MATNR>

<ZSPR>1.06</ZSPR>

</Records>

In my output, I have a field on every line that is a total. So My output needs to look like this.

<Records>

<VBLEN>123</VBLEN>

<MATNR>012356<MATNR>

<ZSPR_TOTAL>3.07</ZSPR_TOTAL>

</Records>

<Records>

<VBELN>123</VBLEN>

<MATNR>568954</MATNR>

<ZSPR_TOTAL>3.07<ZSPR_TOTAL>

</Records>

<Records>

<VBLEN>856</VBLEN>

<MATNR>259865</MATNR>

<ZSPR_TOTAL>11.16</ZPSR_TOTAL>

</Records>

<VBLEN>856</VBLEN>

<MATNR>359874</MATNR>

<ZSPR_TOTAL>11.16</ZSPR_TOTAL>

</Records>

<Records>

<VBLEN>856</VBLEN>

<MATNR985698</MATNR>

<ZSPR_TOTAL>11.16</ZSPR_TOTAL>

So I need the sum of ZSPR on each line, but it has to be the sum of ZSPR for each instance of VBLEN.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello.

You can use and UDF function or try this on standar Mapping. it works

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank you both for your help

former_member190624
Active Contributor
0 Kudos

Hi Dave,

If you are using below graphical mapping logic , you have to apply some logic (shown below ) for remaining fields of output.

For getting Total sum  value based on VBLEN :

For arranging remaining fields of output xml :

Note : ZSPR_TOTAL is mentioned as Total.

Thanks

Hari.