2015 Apr 25 6:41 AM
hi Experts,
I have a Requirement to add sort ,filter options to classical report output ,I have tried by using module-pool program but it not working .how I will add these options to classical reports.anybody please explain me.
Thank You,
Pavan Kumar Dantu
2015 Apr 25 8:21 AM
Hi Pavankumar ,
Inorder to achieve follow below steps :
1. Add push button on your classical report screen using set PF-STATUS.
2. Give Function code for the push button.
3. Handle the event AT USER-COMMAND.
4. Under this Check whether user have clicked on the sort button using SY-UCOMM.
if it is pressed then check which field selected by user. using GET CURSOR statement.
5. In FVAL of GET CURSOR you get the user selected field .
then you can apply sort on your internal table.
6. Redisplay the internal table data.
below is sample code :
DATA : gt_mara TYPE TABLE OF mara,
gs_mara TYPE mara.
SELECT * FROM mara into TABLE gt_mara UP TO 20 ROWS.
PERFORM f_show.
set PF-STATUS 'ZSTATUS'.
at USER-COMMAND.
DATA : fname TYPE string,
fval TYPE string.
IF sy-ucomm = 'SORT'.
GET CURSOR FIELD fname VALUE fval. " gives you the column name
IF fval = 'Material'. " check which column selected by user
SORT gt_mara DESCENDING by MATNR. " Sort accordingly
ELSEIF fval = 'Mat Type'.
SORT gt_mara DESCENDING by MTART.
ENDIF.
PERFORM f_show.
ENDIF.
FORM F_SHOW .
WRITE : / 'Material' ,21 'Mat Type'.
LOOP AT gt_mara INTO gs_mara.
WRITE : / gs_mara-MATNR , 21 gs_mara-MTART.
ENDLOOP.
ENDFORM.
Note : You have the select the column on which you want to apply the sort.
Thanks & Regards-
Vishal
2015 Apr 25 8:31 AM
hi Vishal,
they are expecting filter option ,for filter the output by vendor .how to solve this issue.