Application Development 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: 

ALV OO: Add lines to ALV with filters applied

oliver_am
Active Participant
0 Kudos

Hello,
I have an ALV OO with a custom button to copy lines (and add some modifications in the copied lines)
Each copied line is inserted below its origin line.

Its working file always but when the ALV has some filters applied.

If I apply a filter and then use the copy button not all the copied lines appears in the alv, and some of the hidden lines that dont match with the filter criteria are displayed...

If I go to the columen with the filter and apply again the filter all is displayed ok.


I think is something related with the index of the lines are been displayed with the filters...

Do you know how can I solve this issue?

I've tried using methods GET and SET FILTER CRITERIA after and before the refresh_display, but are not working.

Regards

1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor

I could reproduce easily, thanks to your good example.

In your case, the solution is to use a refresh without stable.

go_alv->refresh_table_display(
    EXCEPTIONS
      finished       = 1
      OTHERS         = 2 ).

Unfortunately, if you update the internal table and refresh with stable, the ALV grid assumes that you didn't change the lines and the filter gets wrong because you changed the lines.

12 REPLIES 12

Sandra_Rossi
Active Contributor
0 Kudos

I guess you mean CL_GUI_ALV_GRID, not the other ALV OO...

oliver_am
Active Participant

Yes, sorry, CL_GUI_ALV_GRID

raymond_giuseppi
Active Contributor
0 Kudos

What value did you pass in I_SOFT_REFRESH of REFRESH_TABLE_DISPLAY ?

oliver_am
Active Participant
0 Kudos

i_soft_refresh = X
stable-row and col = X

Sandra_Rossi
Active Contributor
0 Kudos

Did you check the questions/answers about LVC_FILTER_APPLY?

oliver_am
Active Participant
0 Kudos

I was trying to use the FM LVC_FILTER_APPLY, but is not working yet.
I have been looking for information about this FM but is not clear to me how to use it in my scenario.

What I did is create a handler for event AFTER_USER_COMMAND and then use there the FM, like in program BCALV_TEST_GRID_EVENTS.

But is not working, the displayed data is not correct. If I use the standard Filter funtionality afterwards is showing the correct lines in the ALV.

Any clue ?

Thanks in advance.

Sandra_Rossi
Active Contributor
0 Kudos

I guess LVC_FILTER_APPLY is useful only to work on filtered lines in your own program, not to filter the lines on the screen.

Maybe the right way is to use GET_FILTER_CRITERIA and SET_FILTER_CRITERIA to reapply the filter, plus maybe a REFRESH_TABLE_DISPLAY or CL_GUI_CFW=>UPDATE_VIEW.

I don't know why it doesn't work, but if you can post a minimal reproducible program, that would help to check it for you.

oliver_am
Active Participant

Here you have, a quick alv with the same problem.

test-alv-filters.txt


Try the following:

Execute the report and select the lines in 1.
Use the Copy button, you can see in 2 is working fine.

Exit the report and execute again, add a filter in field Purch.Org (3) with the value E001 (4).

Then select the last two lines of the ALV (5)

And use the button Copy, you can see the result is not correct (6). Its even displaying lines with a different EKORG.
If you put the filter again in the same column, then you can see the correct data (7).
If you remove all filters you can see all the lines ok.

Thanks in advance for any clue.
Regards.

PS: My real program has totally different fields, from other tables. This is only a small test report. But the problem is the same.

PS2: I'm in an old SAP versión: SAP ECC 6.0, SAP_ABA 701

Sandra_Rossi
Active Contributor
0 Kudos

Thanks. Let me check it in something like 2 hours.

Sandra_Rossi
Active Contributor

I could reproduce easily, thanks to your good example.

In your case, the solution is to use a refresh without stable.

go_alv->refresh_table_display(
    EXCEPTIONS
      finished       = 1
      OTHERS         = 2 ).

Unfortunately, if you update the internal table and refresh with stable, the ALV grid assumes that you didn't change the lines and the filter gets wrong because you changed the lines.

Oooook, thanks for the answer...

If they use filters only a few lines will be displayed in the ALV (I guess) so I suppose its ok.

raymond_giuseppi
Active Contributor
0 Kudos

Agree, remove the stable option in the refresh.