cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to sum upto a Condition

former_member184789
Active Contributor
0 Kudos

Hi

I have a requirement where I need to to sum the values of a field E1EDL24-LFIMG of DESADV.DELVRY07 IDoc which also contains E1EDL24-MATNR, upto a point when the value of MATNR does not change. So if the first three E1EDL24 contain a MATNR-100 & value of LFIMG are 5,10,15 respectively  and the next two E1EDL24 contains MATNR 110 & value 4 & 6 then I need to sum 5,10 & 15 for MATNR-100 & 4 & 6 for MATNR-110.Thus I need a udf with two inputs, first will be MATNR, second will be LFIMG, the code should add LFIMG upto a point where the same MATNR appears, when MATNR changes, it should stop summing in the current value & should start summing again for the new MATNR until this MATNR keeps on coming.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184681
Active Contributor
0 Kudos

Hi,

If you are sure that E1EDP01 segments will come already sorted, use the following set of standard functions:

LFIMG -> formatByExample(MATNR -> removeContexts -> splitByValue(Each Value)) -> sum -> target field

if not, add sort for MATNR and sortByExample(MATNR) for LFIMG.

Regards,

Greg

rajasekhar_reddy14
Active Contributor
0 Kudos

I dont think you need UDF for this check condition MATNR Exists then use standard function SUM to sum all values.

If then combination standard fucnton works.