05-27-2010 6:10 AM
Hi ! In my ALV report, added a custom net rate column. Now, I want to find out the minimum, maximum and average values from that custom nat rate colum. How that can be acheived.
05-27-2010 6:25 AM
Hi Goen ,
Say suppose your IT_FINAL is the final Internal Table.
if your Final table getting data from Single table , you can use Aggregate function directly. Please refer the below link for the same.
[http://www.thespot4sap.com/articles/SAPABAPPerformanceTuning_AggregateFunctions.asp]
if not from single table. Go by the below method.
You can use SORT statement for finding the Minimum and Maximum Net rate.
SORT IT_FINAL BY NET_RATE.
READ TABLE IT_FINAL INDEX 1.
if sy-subrc is initial.
"IT_FINAL-NET_RATE will be the Minimum one
Endif.
SORT IT_FINAL BY NET_RATE DESCENDING.
READ TABLE IT_FINAL INDEX 1.
if sy-subrc is initial.
"IT_FINAL-NET_RATE will be the Maximum one
Endif.
for getting average value , You need to sum all the entries NET RATE and then Divide by Number of entries of table.
05-27-2010 6:25 AM
Hi Goen ,
Say suppose your IT_FINAL is the final Internal Table.
if your Final table getting data from Single table , you can use Aggregate function directly. Please refer the below link for the same.
[http://www.thespot4sap.com/articles/SAPABAPPerformanceTuning_AggregateFunctions.asp]
if not from single table. Go by the below method.
You can use SORT statement for finding the Minimum and Maximum Net rate.
SORT IT_FINAL BY NET_RATE.
READ TABLE IT_FINAL INDEX 1.
if sy-subrc is initial.
"IT_FINAL-NET_RATE will be the Minimum one
Endif.
SORT IT_FINAL BY NET_RATE DESCENDING.
READ TABLE IT_FINAL INDEX 1.
if sy-subrc is initial.
"IT_FINAL-NET_RATE will be the Maximum one
Endif.
for getting average value , You need to sum all the entries NET RATE and then Divide by Number of entries of table.
05-27-2010 7:07 AM
Thanks a lot. The MAX rate is coming perfectly fine. But, the MIN rate is giving problem, because several lines of the NET RATE are 0. Please help.
05-27-2010 7:47 AM
HI Goen ,
"Declare one more ITAB IT_FINAL_TMP with same structure of IT_FINAL.
"Copy the data to new ITAB for data manipulations
IT_FINAL_TMP[] = IT_FINAL[].
" Delete the entries which are having net rate as Zero
delete ITAB IT_FINAL_TMP where NET_RATE is initial. " Write appropriate Where condition
"Use IT_FINAL_TMP for finding the MIN Value
SORT IT_FINAL_TMP BY NET_RATE.
READ TABLE IT_FINAL_TMP INDEX 1.
if sy-subrc is initial.
"IT_FINAL_TMP-NET_RATE will be the Minimum one
Endif.
Edited by: Prasath Arivazhagan on May 27, 2010 8:48 AM