Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi, I've a query in contrlobreak statements.How to validate the sum of data

Former Member
0 Kudos
111

Hi experts,

How to add the data using controlbreak statements with 2 fields..

can i sum up the data using 2 fields.Please help me in this regards

i am using .

at end of prctr.

at end of prctr1.

ld_amount = ld_amount + GS_ZKPC2-SALK3.

my requirement is whenever profit center ends.then ld_amount should be added.

please check this below code.let me know the solution as early as possible

LOOP AT GT_ZKPC2 INTO GS_ZKPC2.

ld_amount = ld_amount + GS_ZKPC2-SALK3

at end of prctr.

at end of prctr1.

ld_amount = ld_amount + GS_ZKPC2-SALK3.

move GS_ZKPC2-BUKRS_VF to GS_ZKPC3-BUKRS_VF.

move GS_ZKPC2-PSPNR to GS_ZKPC3-PSPNR.

move gs_zkpc2-konts to GS_ZKPC3-BUKRS_VF.

move GS_ZKPC2-ALOC_SAKHA to GS_ZKPC3-ALOC_SAKHA.

move gs_zkpc2-prctr to gs_zkpc3-prctr.

move GS_ZKPC2-SALK3 to GS_ZKPC3-SALK3.

move gs_zkpc2-prctr1 to gs_zkpc3-prctr1.

move ld_amount TO GS_ZKPC3-RAMOUNT.

APPEND GS_ZKPC3 TO GT_ZKPC3.

clear: gs_zkpc3,ld_amount.

*

endat.

endat.

endloop.

thanks in advance,

regards,

Rekha.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
85

Hi!

You can't nest AT-ENDAT events.

Check out this coding, it might not fit your needs exactly, but you can upgrade it the way you want.

CLEAR gv_prctr.

CLEAR gv_prctr1.

LOOP AT GT_ZKPC2 INTO GS_ZKPC2.

ld_amount = ld_amount + GS_ZKPC2-SALK3

at end of prctr.

SUM.

gv_prctr = gs_zkpc2-prctr.

endat.

at end of prctr1.

SUM.

gv_prctr1 = gs_zkpc2-prctr1.

endat.

endloop.

Regards

Tamá

3 REPLIES 3

Former Member
0 Kudos
86

Hi!

You can't nest AT-ENDAT events.

Check out this coding, it might not fit your needs exactly, but you can upgrade it the way you want.

CLEAR gv_prctr.

CLEAR gv_prctr1.

LOOP AT GT_ZKPC2 INTO GS_ZKPC2.

ld_amount = ld_amount + GS_ZKPC2-SALK3

at end of prctr.

SUM.

gv_prctr = gs_zkpc2-prctr.

endat.

at end of prctr1.

SUM.

gv_prctr1 = gs_zkpc2-prctr1.

endat.

endloop.

Regards

Tamá

Former Member
0 Kudos
85

Hi,

for eg if you have the data like

char prctr prctr1 ( three fields )

a 100 200

a 100 400

a 100 300

b 200 200

c 300 100

did u mean you want

a 200 700

b 200 200

c 300 100

then in that case you can use the collect statement

collect statement will do the sum up technique

when the character field are repeating

here a repeated thrice , so it has taken the sum of three rows..

and b only once and c also only once

thanks & regards,

Venkatesh

Former Member
0 Kudos
85

Try something like this..

data : lv_flag .

LOOP AT GT_ZKPC2 INTO GS_ZKPC2.

ld_amount = ld_amount + GS_ZKPC2-SALK3

at end of prctr.

<b>lv_flag = 'X'.</b>

endat.

at end of prctr1.

<b>IF LV_FLAG = 'X'.</b>

ld_amount = ld_amount + GS_ZKPC2-SALK3.

move GS_ZKPC2-BUKRS_VF to GS_ZKPC3-BUKRS_VF.

move GS_ZKPC2-PSPNR to GS_ZKPC3-PSPNR.

move gs_zkpc2-konts to GS_ZKPC3-BUKRS_VF.

move GS_ZKPC2-ALOC_SAKHA to GS_ZKPC3-ALOC_SAKHA.

move gs_zkpc2-prctr to gs_zkpc3-prctr.

move GS_ZKPC2-SALK3 to GS_ZKPC3-SALK3.

move gs_zkpc2-prctr1 to gs_zkpc3-prctr1.

move ld_amount TO GS_ZKPC3-RAMOUNT.

APPEND GS_ZKPC3 TO GT_ZKPC3.

clear: gs_zkpc3,ld_amount.

<b>

*

CLEAR LV_FLAG.</b>

endat.

endloop.

Thanks

mahesh <b></b>