Skip to Content

Custom sort & filter logic within SALV (CL_SALV_TABLE)

Hi,

I have a requirement where I would like to apply custom sort & filter logic within a custom report that's using SALV classes (CL_SALV_TABLE). I checked the SALV standard sort (CL_SALV_SORTS & filter (CL_SALV_FILTERS) classes but do not see any provision for this.

Currently, I have built a solution using a convoluted approach by utilizing BEFORE_SALV_FUNCTION & AFTER_SALV_FUNCTION events and was wondering if there was any better way.

Would it be possible to have the filter button trigger ADDED_FUNCTION / USER_COMMAND event so I could get the filtered conditions user has entered and apply sort and/or filter via custom code?

Appreciate your responses.

Thanks,

Shrinivas

Add comment
10|10000 characters needed characters exceeded

  • Could you explain why you say filter and sort cannot be done programmatically? ("do not see any provision for this")

    You mentioned the right classes, and you just have to use some of their methods (ADD_SORT, ADD_FILTER, or whatever you want).

    If you want to add a behavior to a standard button/function, you need to use BEFORE_SALV_FUNCTION or AFTER_SALV_FUNCTION, depending on what you want to use.

  • Thanks for your response.

    What I meant was that I myself cannot completely code the SORT & FILTER logic without the standard logic intervention. I want the SORT & FILTER pop-up & columns selection but want to be able to perform the actions through my code. I want the filter & sort trigger a user command and not itself perform any action.

    With the two events, for FILTER, I am having an issue where user would see the manipulated filter condition on next selection of FILTER which I wanted to avoid and so looking for any alternative or better option.

  • Get RSS Feed

1 Answer

  • Jun 04, 2017 at 11:14 AM

    So, if you "want the filter & sort trigger a user command and not itself perform any action." then you must remove the standard functions, and define your own buttons with same icons as the standard buttons, but with CUSTOM function codes (ZFILTER and ZSORT for instance).

    Edit 4 hours later: it's possible to prevent a standard function code from doing its job in event BEFORE_SALV_FUNCTION, by calling SET_FUNCTION( space ).

    Add comment
    10|10000 characters needed characters exceeded