‎2007 Jan 19 7:09 PM
Hi
My internal table output is as follows :-
city sales
HYD 100
RJY 153
BVM 500
SEC 550
. .
. .
Now i have to get the top two cities of high sales.please send that coding
Regards
M.Srikanth
<u></u>
‎2007 Jan 19 7:16 PM
Hi,
SORT ITAB BY SALES DESCENDING.
READ TABLE ITAB INDEX 1.
WRITE: / 'TOP CITY- ', ITAB-CITY.
READ TABLE ITAB INDEX 2.
WRITE: / 'SECOND TOP CITY- ', ITAB-CITY.
Thanks,
Naren
‎2007 Jan 19 7:17 PM
Hi Srikanth ,
Code will be
Sort it_1 by SALES DESCENDING.
READ TABLE IT_1 INDEX 1.
READ TABLE IT_ INDEX 2.
Regards
Arun
‎2007 Jan 19 7:18 PM
Hai Srikanth
Check the following Code
data : begin of itab occurs 0,
city(3) type c,
sales type i,
end of itab.
itab-city = 'HYD'.
itab-sales = 100.
append itab.
itab-city = 'RJY'.
itab-sales = 153.
append itab.
itab-city = 'BVM'.
itab-sales = 500.
append itab.
itab-city = 'SEC'.
itab-sales = 550.
append itab.
if not itab[] is initial.
Sort itab by SALES DESCENDING.
loop at itab.
write 😕 itab-city,
itab-sales.
endloop.
endif.
Regards
Sreeni
Message was edited by:
Sreenivasulu Ponnadi
Message was edited by:
Sreenivasulu Ponnadi
‎2007 Jan 19 7:19 PM
Hi
sort internal table using sales descending. write first two records.
OR
Declare one variables. loop the intenal table compare sales value of sales with variable. & if the value of sales greater than variable assign value to variable.
e.g.:
clear v1.
Loop at internal table.
if itab-sales > v1.
v1 = itab-sales.
endloop.
Ashven
‎2007 Jan 19 7:37 PM
Hi,
SORT ITAB BY SALES DESCENDING.
LOOP AT ITAB FROM 1 TO 2.
WRITE: /ITAB-CITY 20 ITAB-SALES.
ENDLOOP.
Reward points if the answer is helpful.
Regards,
Mukul
‎2007 Jan 19 11:24 PM
Hi,
if cities appear more than once, you must collect before:
itab_coll like table of itab with header line
loop at itab
collect itab into itabv_coll
endloop.
sort itab_coll bý sales descending.
loop at itab_coll from 1 to 2.
write: / itab_coll-city, itab_coll-sales.
endloop.
Regards,
Clemens
‎2007 Jan 20 4:17 AM
sort itab by sales descending.
delete itab from 3.
loop at itab.
write : / itab-city,itab-sales.
endloop.
now your itab only contain those two rows which have highest sales value.
regards
shiba dutta