Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Syntax of For Each Loop

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

Former Member
Former Member replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question