01-13-2011 6:21 AM
Hello ,
i have already searched in all threads, but i could not find help for this.
as we have filter functionality in ALV, where we can select fields and then enter our values in a pop screen where we get the selection screen type of screen .
same way i want to implement same functionality in table control.
i tried to use LVC_FILTER fm, then LVC_FILTER_APPLY.
BUT , i am nt getting filtered values in my internal table.
please sugget wht to do.
01-13-2011 6:29 AM
01-13-2011 8:49 AM
i said that i have searched in all thread, this thread also i saw, but there is no help.
01-13-2011 10:54 AM
Did you check the icon( default ) which is available in the top right corner of the table control.
01-18-2011 2:39 AM
Hi,
If you replace your table control with an ALV within a custom container, you can filter/sort all you want.
Or is there a particular reason you chose a table control?
01-18-2011 5:39 AM
Hello Medha,
The simplest way to achieve this would be ALV using custom container (OOPS), you will be able to use all functionalities given in ALV along with filter & many more.
Thanks.
01-25-2011 4:06 AM
hello guys
thanks for reply
i knw tht ALV using oops is simplest, but actually i m helping my collegue, and he has already developed most of the requirement in table control. now functional needs this filter application also.
but no prob, we have found that LVC_FILTER AND THEN LVC_FILTER_APPLY FM can be used and now its working. i m pasting the code for everybdy reference.
in usercommand ,when user presses the filter button,
write:
LOOP AT TC1-COLS INTO COLS WHERE SELECTED = 'X'.
LS_SELECTED_COLS-FIELDNAME = COLS-SCREEN-NAME+10.
APPEND LS_SELECTED_COLS TO GT_SELECTED_COLUMNS.
ENDLOOP.
SORT G_TC1_ITAB BY USERID CLASS BUKRS LIFNR DATE_TIME.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = 'ZVENINPUT'
CHANGING
CT_FIELDCAT = GT_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 99.
IF SY-SUBRC = 0.
CALL FUNCTION 'LVC_FILTER'
EXPORTING
IT_FIELDCAT = GT_FIELDCAT
IT_SELECTED_COLS = GT_SELECTED_COLUMNS
it_value_unit = lt_value_unit
it_grouplevels = lt_grouplevels
IS_LAYOUT = L_LAYOUT
is_selfield = l_selfield
IT_GROUPS = LT_GROUPS
IMPORTING
ET_FILTER_INDEX = GT_FILTER_INDEX
TABLES
IT_DATA = G_TC1_ITAB "gt_subitems
CHANGING
CT_FILTER = GT_FILTER
EXCEPTIONS
OTHERS = 0.
IF SY-SUBRC = 0.
REFRESH: G_TC1_TEMP.
REFRESH G_TC1_BUFF.
G_TC1_BUFF[] = G_TC1_ITAB[].
LOOP AT GT_FILTER_INDEX INTO GS_IDX.
READ TABLE G_TC1_ITAB INTO G_TC1_WA INDEX GS_IDX.
IF SY-SUBRC = 0.
APPEND G_TC1_WA TO G_TC1_TEMP .
CLEAR G_TC1_WA.
ENDIF.
CLEAR GS_IDX.
ENDLOOP.
LOOP AT G_TC1_TEMP INTO G_TC1_WA.
READ TABLE G_TC1_ITAB INTO G_TC1_WA1 WITH KEY
USERID = G_TC1_WA-USERID
CLASS = G_TC1_WA-CLASS
BUKRS = G_TC1_WA-BUKRS
LIFNR = G_TC1_WA-LIFNR
DATE_TIME = G_TC1_WA-DATE_TIME BINARY SEARCH.
IF SY-SUBRC = 0.
DELETE G_TC1_ITAB INDEX SY-TABIX.
ENDIF.
CLEAR: G_TC1_WA1, G_TC1_WA.
ENDLOOP.
CLEAR: G_TC1_WA1, G_TC1_WA.
LOOP AT G_TC1_ITAB INTO G_TC1_WA.
READ TABLE G_TC1_BUFF INTO G_TC1_WA1 WITH KEY
USERID = G_TC1_WA-USERID
CLASS = G_TC1_WA-CLASS
BUKRS = G_TC1_WA-BUKRS
LIFNR = G_TC1_WA-LIFNR
DATE_TIME = G_TC1_WA-DATE_TIME BINARY SEARCH.
IF SY-SUBRC = 0.
DELETE G_TC1_BUFF INDEX SY-TABIX.
ENDIF.
CLEAR: G_TC1_WA1, G_TC1_WA."raviraj
ENDLOOP.
CLEAR:G_TC1_WA.
endif.
endif.
01-25-2011 4:07 AM
04-04-2012 7:45 AM
Hi Medha,
Please send the data declarations you have done for this. It will be a great help.
01-25-2011 4:08 AM
myself solved, solution is already posted in same thread.
thanks for the replies
06-22-2011 8:01 AM
Thanks Medha for posting your code. it helped me in adding sort and filter functionality in table control. Thanks a lot.
09-07-2011 11:28 AM
Hi Nikhil,
Can you post your code as i also need to add filter and sort buttons.
i need the code to handle filter and sort buttons after calling the LVC function modules. Please help me on this.
Thanks and Regards,
Umesh J D
04-04-2012 7:19 AM
Hi Nikil,
Please provide me the data declarations you have done for this requirement.
05-25-2023 6:55 AM
Hi,
I also met with same issue recently. Tried a custom coding and wanted to share.
Please try below.
table_a - Original table with data
table_flt - Intermediate table to store filtered data temporally
Step 1
Add a button to screen and set as filter
Function Code: FC_FILTER
Step 2
Program always will display table_flt[] data. And updates original table accordingly in PAI.
---------------------------------------------------------------------
---------------------------------------------------------------------
"PBO
MODULE set_values_to_filter_tbl.
LOOP AT table_flt "Set data to output screen table
INTO gs_flt
WITH CONTROL tc_flt
CURSOR tc_flt-current_line.
ENDLOOP.
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
LOOP AT table_flt. "Set data to output screen table
MODULE tc_flt_modify.
ENDLOOP.
MODULE flt_to_org_tbl. "Update changes on filtered table data to original table
"Loop an update each record
MODULE user_command.
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
"MODULES
"PBO MODULES
MODULE set_values_to_filter_tbl.
table_flt[] = table_a[] "Copy all data to TABLE_FLT
IF gv_filter IS NOT INITIAL.
DELETE table_flt WHERE value NOT IN gt_value.
ENDIF.
ENDMODULE.
"PAI MODULES
MODULE tc_flt_modify INPUT.
MODIFY table_flt
FROM gs_flt
INDEX tc_flt-current_line.
ENDMODULE.
MODULE user_command.
WHEN 'FC_FILTER'.
CALL FUNCTION 'COMPLEX_SELECTIONS_DIALOG' "Pop up to user input (get values)
EXPORTING
text = 'Filter Values'
just_incl = 'X'
TABLES
range = gt_value
EXCEPTIONS
no_range_tab = 1
cancelled = 2
internal_error = 3
invalid_fieldname = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.
IF gt_value IS NOT INITIAL.
gv_filter = 'X'.
ELSE.
gv_filter = ''.
ENDIF.
ENDIF.
ENDMODULE.
---------------------------------------------------------------------
---------------------------------------------------------------------