cancel
Showing results for 
Search instead for 
Did you mean: 

Fox Formula In IP.

Former Member
0 Kudos

Hi Friends,

I have a problem in Executing Fox Formula.

I want to Add all rows of the Column. And want to Use the Total Summation Of Column in Another Column Using ForEach Loop but it is not working as Expected.

I Posted the Following Code :

DATA Z_MAT TYPE 0MATERIAL.

DATA Z_COM TYPE 0COMP_CODE.

DATA TLACTSUM TYPE F.

FOREACH Z_MAT, Z_COM.

TLACTSUM = TLACTSUM + {ZTP_TOTC,Z_MAT,Z_COM }.

{ ZTP_LP2 ,ZFISC_YEAR }= TLACTSUM.

ENDFOR.

My Requirement is :

ZTP_TOTC ZTP_LP2

20 140

40 140

30 140

50 140

140 is addition of all the fields in Column (i.e 204030+50).

But Output i'm getting is :

ZTP_TOTC ZTP_LP2

20 20

40 40

30 30

50 50

Please Help with Answer.

Regards,

Girish

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Anand and Andrey,

I used Both the methods but the Code is Still giving the Same result as Above.

Please Suggest any other code

cornelia_lezoch
Active Contributor
0 Kudos

Hi,

there is a basic error in your formula.

what are the fiels to be changed? either its material and comcode and the term {ZTP_TOTC,Z_MAT,Z_COM } is right but in the term { ZTP_LP2 ,ZFISC_YEAR } there is material and compcode missing - or the other way around.

regards

Cornelia

cornelia_lezoch
Active Contributor
0 Kudos

and by the way, I always put an if ... (lower or greater) 0 around the loop and a sum = 0 before like:

TLACTSUM = 0.

if {ZTP_TOTC,Z_MAT,Z_COM } (lower or greater) 0.

TLACTSUM = TLACTSUM + {ZTP_TOTC,Z_MAT,Z_COM }.

endif.

Anand71
Active Contributor
0 Kudos

Hello,

Use this following code:

DATA Z_MAT TYPE 0MATERIAL.

DATA Z_COM TYPE 0COMP_CODE.

DATA TLACTSUM TYPE F.

TLACTSUM = 0.

FOREACH Z_MAT, Z_COM.

TLACTSUM = TLACTSUM + {ZTP_TOTC,Z_MAT,Z_COM }.

ENDFOR.

FOREACH Z_MAT, Z_COM.

{ ZTP_LP2 ,ZFISC_YEAR }= TLACTSUM.

TLACTSUM = 0.

ENDFOR.

Thanks.

With regards,

Anand Kumar

Former Member
0 Kudos

Hi.

Try to add another loop within first loop.

The main loop will run on all records and the inner loop will summarize the totals for the block.

Regards.