‎2008 Jun 10 8:00 PM
Hi,
I have a table with several cols the 2 key are Quarter and COB ( class of business) I want to have a third col total by end of Quarter and end of COB. If I use AT END of Quarter it will only sum for the quarter. Is it possible to do something like
AT END OF quarter
AT END OF COB
SUM
.....
.....
....
END AT
END AT
Or is this going to have to be done manually?
Thanks,
George
‎2008 Jun 10 8:29 PM
Hi George,
data:begin of wa_1,
quarter(10) type c,
COB(5) type n,
tot type i,
end of wa_1,
itab1 like standard table of wa_1.
Loop at itab1 into wa_1.
wa_2 = wa_1.
At end of COB.
sum.
wa2-tot = wa_1-tot.
append wa2 to itab2.
ENDAT.
endloop.
This above code will sum up based on both Quarter and COB.Meaning that even if any one of the field*quarter or COB) changes,the Block of statment beteween AT and ENDAT will be executed.
For eg:ITAB1
Quarter COB tot
-
A1011 340 2
A1011 340 3
A1011 341 11
A1012 341 6
O/P:ITAB2
Quarter COB tot
-
A1011 340 5
A1011 341 11
A1012 341 6
Regards,
Vigneswaran S
‎2008 Jun 10 8:19 PM
‎2008 Jun 10 8:29 PM
Hi George,
data:begin of wa_1,
quarter(10) type c,
COB(5) type n,
tot type i,
end of wa_1,
itab1 like standard table of wa_1.
Loop at itab1 into wa_1.
wa_2 = wa_1.
At end of COB.
sum.
wa2-tot = wa_1-tot.
append wa2 to itab2.
ENDAT.
endloop.
This above code will sum up based on both Quarter and COB.Meaning that even if any one of the field*quarter or COB) changes,the Block of statment beteween AT and ENDAT will be executed.
For eg:ITAB1
Quarter COB tot
-
A1011 340 2
A1011 340 3
A1011 341 11
A1012 341 6
O/P:ITAB2
Quarter COB tot
-
A1011 340 5
A1011 341 11
A1012 341 6
Regards,
Vigneswaran S
‎2008 Jun 10 8:44 PM
Thanks for the replies, not sure if that is the answer though
Let's say for instance the data is like this
QTR COB Price
1 22 70.00
1 22 30.00
1 36 50.00
1 36 10.00
2 22 25.00
I would want totals like
Qtr COB Price
1 22 100.00
1 36 60.00
2 22 25.00
I tried the above code but it did not return the needed result
This is a fairly urgent matter so all input is appreciated
‎2008 Jun 10 8:49 PM
Hi,
Can u paste ur code here along with the itab declaration here?.Because the one which i shown in the Eg.is similar as the one which u have shown here.It will give the same result.
‎2008 Jun 10 8:58 PM
Hi,
Loop at itab.
At end of COB.
sum.
write: / ITAB_data-qtr,
ITAB_data-cob,
ITAB_data-price.
ENDAT.
endloop.Please reward points if it helps
Thanks
Vikranth
‎2008 Jun 10 9:10 PM
Here is what I have
TYPES: BEGIN OF ST_COLL_1,
QTR(2) TYPE N,
BRCHNR LIKE /MSG/RD_ABR_BU-BRCHNR, "COB
ABRNR LIKE /MSG/RD_ABR_BU-ABRNR,
ZJJ LIKE /MSG/RD_ABR_BU-ZJJ,
BIL_PERIOD LIKE /MSG/RD_ABR_BU-BIL_PERIOD,
BIL_DAT LIKE /MSG/RD_ABR_BU-BIL_DAT,
BUCONR LIKE /MSG/RD_ABR_BU-BUCONR,
OW_BETR LIKE /MSG/RD_ABR_BU-OW_BETR,
END OF ST_COLL_1.
DATA: T_COLL_1 TYPE ST_COLL_1 OCCURS 0,
WA_T_CO LIKE LINE OF T_COLL_1.
qtr_tot1 = 0.
qtr_tot2 = 0.
qtr_tot3 = 0.
LOOP AT t_coll_1 INTO wa_t_co.
AT END OF qtr.
SUM.
qtr_tot1 = qtr_tot1 + wa_t_co-ow_betr.
qtr_tot2 = qtr_tot2 + wa_t_co-ow_betr2.
qtr_tot3 = qtr_tot3 + wa_t_co-ow_betr3.
MOVE wa_t_co-qtr TO wa_t_cal-qtr.
MOVE qtr_tot1 TO wa_t_cal-earnprem.
MOVE qtr_tot2 TO wa_t_cal-paidloss.
MOVE qtr_tot3 TO wa_t_cal-oslr.
APPEND wa_t_cal TO t_yr_calc.
ENDAT.
ENDLOOP.
This is when I was just totaling by Quarter and it works fine, however I now need it to total by Quarter and Brchnr
‎2008 Jun 10 9:17 PM
Hi George,
THe summation will be done by system itself.You dont have to do it your program.
One more thing.You have to use at end of BRCHNR instead of At ENd of QTR ,if u want to have a sum based on both these fields.
Chk out this.
LOOP AT t_coll_1 INTO wa_t_co.
AT END OF BRCHNR.
SUM.
MOVE wa_t_co-qtr TO wa_t_cal-qtr.
MOVE wa_t_co-ow_betr TO wa_t_cal-earnprem.
MOVE wa_t_co-ow_betr2 TO wa_t_cal-paidloss.
MOVE wa_t_co-ow_betrTO wa_t_cal-oslr.
APPEND wa_t_cal TO t_yr_calc.
ENDAT.ENDLOOP.
Regards,
Vigneswaran S
‎2008 Jun 10 8:56 PM
HI,
you do not need the AT END OF QTR, the AT END OF statement uses all fields before and with the field specified as the key. The below exapme gives the result you want:
data: begin of gs_data,
qtr(1) type n,
cob(2) type n,
price type p,
end of gs_data,
gt_data like Standard TABLE OF gs_data.
start-of-selection.
gs_data-qtr = '1'.
gs_data-cob = '22'.
gs_data-price = '70.00'.
append gs_data to gt_data.
gs_data-qtr = '1'.
gs_data-cob = '22'.
gs_data-price = '30.00'.
append gs_data to gt_data.
gs_data-qtr = '1'.
gs_data-cob = '36'.
gs_data-price = '50.00'.
append gs_data to gt_data.
gs_data-qtr = '1'.
gs_data-cob = '36'.
gs_data-price = '10.00'.
append gs_data to gt_data.
gs_data-qtr = '2'.
gs_data-cob = '22'.
gs_data-price = '25.00'.
append gs_data to gt_data.
loop at gt_data into gs_data.
at end of cob.
sum.
write: / gs_data-qtr,
gs_data-cob,
gs_data-price.
endat.
endloop.
Hope this helps,
Gert