08-28-2007 6:21 PM
Hi,
I Had faced a problem while retrieving data
for Example
FIELD TOT HAS 40 RECORDS LIKE TOT1 TOT2..........TOT40 OF AN TABLE.
I WANTED THE OUTPUT WILL BE LIKE MENTIONED BELOW
WITH 5 TOT AT A TIME AND THEIR WILL BE BUTTON BELOW THE O/P WHICH
SHOWS NEXT OR PREV 5 TOT AT A TIME AND THE SUM WILL BE CALCULATED .
TOT1 TOT2 TOT3 TOT4 TOT5 TOTAL
3 2 4 6 0 15
1 7 8 9 4 29
3 4 5 7 3 22
5 3 1 5 2 16
08-28-2007 7:02 PM
Let us say you have put in two buttons <= and => to see next and previous
data : lv_page type i.
data : v_total type i.
lv_page = 0.
start-of-selection.
loop at itab.
v_total = itab-tot1 + itab-tot2 + itab-tot3 + itab-tot4 + itab-tot5.
write 😕 itab-tot1, itab-tot2,itab-tot3,itab-tot4,itab-tot5,v_total.
endloop.
when ever you click on next or previous button
at user command will be triggered.
if sy-ucomm eq 'NEXT'.
if lv_page ne 8.
lv_page = lv_page + 1.
endif.
endif.
if sy-ucomm eq 'BACK'.
if lv_page ne 0.
lv_page = lv_page - 1.
endif.
endif.
case lv_page.
when 0.
loop at itab.
v_total = itab-tot1 + itab-tot2 + itab-tot3 + itab-tot4 + itab-tot5.
write 😕 itab-tot1, itab-tot2,itab-tot3,itab-tot4,itab-tot5,v_total.
endloop.
when 1.
loop at itab.
v_total = itab-tot6 + itab-tot7 + itab-tot8 + itab-tot9 + itab-tot10.
write 😕 itab-tot6, itab-tot7,itab-tot8,itab-tot9,itab-tot10,v_total.
endloop.
..
..
..
when 8.
loop at itab.
v_total = itab-to36 + itab-tot37 + itab-tot38 + itab-tot39 + itab-tot40.
write 😕 itab-tot36, itab-tot37,itab-tot38,itab-tot39,itab-tot40,v_total.
endloop.
endloop.
endcae.
Try this way
Thaks
mahesh
08-28-2007 7:36 PM
hi Nchandra,
You can use "Write to", only change the (tot1, tot2, tot3, tot4, tot5 and total) for the table fields.
and the better is the Data "end",
the value of "end" is all what you need.
DATA: tot1(5) value '5',
tot2(5) value '2',
tot3(5) value '6',
tot4(5) value '9',
tot5(5) value '1',
total(5),
end(30).
total = tot1 + tot2 + tot3 + tot4 + tot5.
Write: 'TOT1', 'TOT2', 'TOT3', 'TOT4', 'TOT5', 'TOTAL'.
Write: tot1 to end, tot2 to end5, tot3 to end10,
tot4 to end15, tot5 to end20, total to end+25,
/ end.
Regargs
Allan Cristian