2007 Aug 27 2:36 PM
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.
2007 Aug 27 2:53 PM
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á
2007 Aug 27 2:53 PM
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á
2007 Aug 27 2:56 PM
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
2007 Aug 27 2:58 PM
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>