cancel
Showing results for 
Search instead for 
Did you mean: 

Syntax of For Each Loop

Former Member
0 Kudos

Hi Friends,

I have two keyfigures KF1 and KF2 .

I want to write the formula i.e (KF1KF2)/Sum(KF1KF2).

This formula is to be applied depending on the Characteristic Material.

Please guide me the syntax of this formula.

Regards,

Girish

Accepted Solutions (1)

Accepted Solutions (1)

Anand71
Active Contributor
0 Kudos

Hello,

PLease try this code:




DATA Z_COM TYPE 0COMP_CODE.
DATA Z_MAT TYPE 0MATERIAL.
DATA SUM1 TYPE F.
DATA MUL1 TYPE F.

FOREACH Z_MAT,Z_COM.

MUL1 = {KF1, Z_COM, Z_MAT}* {KF2,  Z_COM, Z_MAT}.

SUM1= {KF1, Z_COM, Z_MAT}+ {KF2,  Z_COM, Z_MAT}.


{KF3, Z_COM, Z_MAT} = MUL1/SUM1.
*KF3 is the third key figure where the results are stored.
ENDFOR.

Please let me know if you need any further help.

Thanks.

With regards,

Anand Kumar

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks for ur valuable info.

Problem was resolved.

cornelia_lezoch
Active Contributor
0 Kudos

if you want to run your formula for each material and both key figures you use are filled, you do not need any loop.

The system calculates each formula for each data record.