Wednesday, November 26, 2014

Custom container + SALV - PBO runs twice under Resizing option or how to reach just one horizontal bar

SALV class is really handy, simple to use. No need of manual field catalog creation is super feature. But in some cases is does something you do not expect. This article describes one of this strange behavior.

Imagine such "uncommon" situation, you place your ALV inside custom container with some certain dimensions. There is no other vertical space, so we have fixed defined height of the container. On the other side, ALV can contain many columns. It causes later on two horizontal scroll bars. What is really annoying.

Overcome two scroll bars, but...




OK, no problem, there is a solution. We can just tick "Resizing" check box for automatic horizontal or vertical growth. We should have just one scroll bar. That's nice, But there is one quite interesting BUT.



Custom container/SALV shadow behavior


In this case PBO action is to be run twice. Why? Custom container resizing capability causes to trigger PAI immediately after SALV->display( ) method. Suddenly you can see in debug loading of method IF_SALV_DISPLAY_ADAPTER~GET_COLUMNS. Container reacts with it is own event on resizing option. One more note, here the automatic screen reload depends on amount of ALV data. If you have just few rows, nothing special would happen. But with growing number of SALV rows reload occurs.

Conclusion


Now we have to choose, to have just one scroll bar with side effect of one more automatic PAI/PBO loop on screen OR to have two bars and exactly one PBO action. Sometime it takes a time to discover such a secret behind. When you have some special logic in PBO, twice run could be unwanted behavior.


In my case I had to rewrite the PBO action to reach just one horizontal bar. I had to equip the PBO with some logic calculating with second PBO run. So some checks has to be added. The result is OK afterwards.






2 comments:

  1. What is the solution for this issue?

    ReplyDelete
    Replies
    1. Hi,
      basically you have to choose, what you want. Sometime to run PBO twice can cause a mess. So it's up to you, if you would use resizing option of container or not. Nevertheless I updated a bit conclusion part.

      Delete