Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Regarding the fileter functionality in ALV

Former Member
0 Likes
1,032

Hi experts,

We know that in ALV report we do have an option for filtering the data according to the input given to the filter for the selcted fields. I want to implelment this logic on a separate button other than 'filter' in ALV. Can any one tell me how this can be done?

Thanks.

Warm regards,

Harshad.

1 ACCEPTED SOLUTION
Read only

jordi_escodaruiz
Active Participant
0 Likes
970

You can add a button for your functionality. To do that:

1- Create a Status GUI, and adjust the model to ALV.

2- Create a form to handle the commands. Implement here your functionality.

3- Pass to the ALV call the parameters i_callback_program, i_callback_pf_status_set, i_callback_user_command

For example:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = 'MY_STATUS' "Your status GUI

i_callback_user_command = 'MY_USER_COMMAND' "The form for the user command

....

...

FORM MY_USER_COMMAND USING p_ucomm LIKE sy-ucomm

p_selfield TYPE slis_selfield.

....

Implement here your code

...

ENDFORM

5 REPLIES 5
Read only

jordi_escodaruiz
Active Participant
0 Likes
971

You can add a button for your functionality. To do that:

1- Create a Status GUI, and adjust the model to ALV.

2- Create a form to handle the commands. Implement here your functionality.

3- Pass to the ALV call the parameters i_callback_program, i_callback_pf_status_set, i_callback_user_command

For example:

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = 'MY_STATUS' "Your status GUI

i_callback_user_command = 'MY_USER_COMMAND' "The form for the user command

....

...

FORM MY_USER_COMMAND USING p_ucomm LIKE sy-ucomm

p_selfield TYPE slis_selfield.

....

Implement here your code

...

ENDFORM

Read only

dev_parbutteea
Active Contributor
0 Likes
970

Hi,

Just set the user command code in the gui-status as in the standard button i.e. &ILT.

Regards.

Read only

Former Member
0 Likes
970

Hi ,

You can try this FM -- ALV_GROUPLEVELS_WITH_FILTER .

Regards

Pinaki

Read only

former_member404244
Active Contributor
0 Likes
970

Hi,

In the form user command u can do like this.. Supposse i want to filter based on storage location. adn the storage location internal table have all the storage locations.

DATA : lv_ref1 TYPE REF TO cl_gui_alv_grid,

lv_lines TYPE i.

DATA : lv_answer(1).

DATA: lit_selall TYPE lvc_t_moce,

ls_selall LIKE LINE OF lit_selall.

DATA lit_filter TYPE lvc_t_filt.

ls_selall-col_id = 1.

ls_selall-value = 'X'.

APPEND ls_selall TO lit_selall.

WHEN '&SALL'.

REFRESH lit_filter[].

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = lv_ref1.

CALL METHOD lv_ref1->check_changed_data.

*Get the filter criteria

CALL METHOD lv_ref1->get_filter_criteria

IMPORTING

et_filter = lit_filter.

LOOP AT git_sloc ASSIGNING <lfs_sloc>.

CLEAR lv_sel.

LOOP AT lit_filter INTO lwa_filter.

CLEAR r_val.

REFRESH r_val[].

r_val-sign = lwa_filter-sign.

r_val-option = lwa_filter-option.

r_val-low = lwa_filter-low.

r_val-high = lwa_filter-high.

APPEND r_val.

CLEAR lv_field.

CONCATENATE '<lfs_sloc>-' lwa_filter-fieldname INTO lv_field.

ASSIGN (lv_field) TO <lfs_any>.

IF <lfs_any> IN r_val.

lv_sel = 'X'.

ELSE.

CLEAR lv_sel.

ENDIF.

IF <lfs_sloc>-check IS INITIAL.

<lfs_sloc>-check = lv_sel.

ENDIF.

ENDLOOP.

ENDLOOP.

rs_selfield-refresh = gc_x.

Regards,

Nagaraj

Read only

Former Member
0 Likes
970

Solved.