Hi Wenbo,
I have done something similar to this in a requirement and I think if you work with these two function modules you can achieve something like this in the handle_f4 event of the ALV grid. I will list them in the order of execution and try to explain the purpose of them:
1. CALL FUNCTION 'F4IF_GET_SHLP_DESCR'
EXPORTING
shlpname = lv_shlpname
IMPORTING
shlp = ls_shlp.
2. CALL FUNCTION 'F4IF_START_VALUE_REQUEST'
EXPORTING
shlp = ls_shlp
maxrecords = 500
IMPORTING
rc = lv_subrc
TABLES
return_values = lt_f4.
For the first function module you provide a name and a type of the search help to retrieve the entire deep structure describing the search help. If the name needs to be dynamic based on some logic in the program like I had to do then you can derive a value for lv_shlpname according to your requirements. The type parameter has a default that you don't have to pass unless you have something besides the default. The important part to achieve the dynamic nature of your search help is what you do between the call for function 1 and 2. At this location in the deep structure you can find select options which you can populate dynamically based on your 'object' and 'field' values: ls_shlp-selopt. If you need more information regarding a full example let me know.
Regards,
Ryan Crosby