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

problem updating split OO alv

0 Likes
1,902

hi,

We have an oo alv, with 2 alvs on a single screen.

Both alvs have fields which are enabled for update.

When updating the fileds, if we press an icon on one alv,

the changes to the other alv are lost.

Is there a way to activate a method from another class ?

We can't find any documentation in Oss or SCN.

Thank you

Zvika

13 REPLIES 13
Read only

Former Member
0 Likes
1,869

Pass an instance of the first class to the second class when you instantiate it,  or preferably create a new class which inherits from cl_gui_alv_grid and contains 2 instances of the ALV grid plus it's mechanisms for displaying it,  along with your event handlers for the 2 instances.

Rich

Read only

0 Likes
1,869

Hi,

Thanks for your advice.

We don't understand how to implement the preferred option that you offered.

Could you please send us an example?

Thank you

Zvika

Read only

0 Likes
1,869

Both and @  gave you all the info you need to check the issue.

Plus, about your request of an example, did you try search the SCN? I cannot believe you did not find any example/hint when there are more than 1000 threads and wikis about ALV Splitting Google

Read only

0 Likes
1,869

Hi Zvika,

Unfo5rtunately I can't send you and example - that would basically mean doing it for you and I do  not have the time for that.

When you declare a local class (or any class for that matter),  you can inherit from a parent class,  however,  thinking about it,  you don't actually need to inherit from the cl_gui_alv_class,  just have two attributes that are alv grids.  You also have an attribute that is a splitter container and in the constructor method you instantiate the splitter and the two alv's,  passing the data required for the two alv's as parameters to the constructor. You then define handlers or methods to do what you require.

I use this technique every time I have a summary/detail display to program.

Rich

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,869

When you "press an icon on one alv, the changes to the other alv are lost", there is no Relationship between the two facts, the loss of changes is due to another action you execute when the icon is pressed. The question is "what are you doing when the icon is pressed" ? (by the way, "icon" is what ? a button in the toolbar, a button in a cell of the ALV grid...)

Read only

0 Likes
1,869

Try to debug and see if/when the other ALV is refreshed somewhere after your icon-press.

Do you have separate event handlers for the ALVs?

Have you tried using the check_changed_data method for both ALVs at the correct points? Is the internal table linked to the second ALV updated with the changes at some time? Or never at all?

Lastly, have you followed 's advise?

Read only

0 Likes
1,869

Hi.

Apparently, we didn't make ourselves clear on the problem.

Yes, we have separate event handlers for the alvs.

The problem is that each is in a class of its own.

We typed a change in each alv.

When we get to the method User_Command of one class (class_upper),

in debug we see that only the change made in THAT class (class_upper)  is recognized.

The other change that we typed in the second class (class_lower), is not found in the internal table

connected to class_lower.

The methods of class_lower are not entered at all.

Is it possible to activate the methods in class_lower at the same time as class_upper?

Hope this makes the question clearer.

We have searched google, scn, oss... and unfortunately only find examples

of split alvs with displays or copied data.  We can't find an example of updating

2 classes at the same time.

Thank you.

Zvika

Read only

0 Likes
1,869

To get the values, as said by Patrick, you must use check_changed_data on both ALV grids. Did you do that? Could you also be explicit about which technology you are using, because I'm not even sure you're using cl_gui_alv_grid.

Yes it's possible to execute methods from the bottom, that's easy as long as both ALV instances are known by both ALVs.

Read only

0 Likes
1,869

Ok,  this is where creating a new class comes in handy.

In separate alv grids any data that is changed needs to be processed by each of the grids Data_Changed and Data_Changed_Finished events.  By encapsulating these two grids into a local class, in the event handler for data_changed_finished for each grid you can call the method Check_Data_Changed of the other grid,  forcing the Data_Cghanged and Data_changed_finished events to fire.

Also,  if you have the same functionality in terms of things like drill downs,  grid colouring and layout etc etc these can all be handled by common methods.

If there is no validation for your data then you can even use the same event handler.

I assume that you have two local classes that define the event handlers for your grids.  In one of those classes add two private attributes type cl_gui_alv_grid (called grid1 and grid2 ?).  In the constructor,  pass the splitter and the two tables for the grids,  set up the grids using methods to handle the field catalog processing,  layout and event handler definition,  then call set_table_for_first_display on each grid.

In the Data_changed_finished event call the Check_Data_Changed event of the opposite grid,  making sure that you don't end up in an endless loop by calling the other grids check_data_changed_method as well....

Easy.

Read only

0 Likes
1,869

Ahh - might have given the wrong names for check_data_changed,  but that is the idea....

Read only

0 Likes
1,869

Easy way being globally declaring the instances of both alv's. And then calling the check_data_changed method at the beginning of the method in the event-handler class, not?

Read only

0 Likes
1,869

Or declaring the handler globally, at Data_change_Finished, update according the table displayed in 2nd alv and call the refresh method for both

Read only

0 Likes
1,869

Cats->Item( Cat )->Skin->Many( ).

Or - there are many ways to skin a cat....

I think,...

Better than a goat anyhow.....