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: 

Oops ALV screen refresh issue when using SAPGUI_SET_FUNCTIONCODE

Former Member
0 Kudos

Hi All,

I am facing issue while I am trying to refresh ALV data 2nd time (update with new data), when using FM - SAPGUI_SET_FUNCTIONCODE.

If I comment this FM, then refresh works ok.

My scenario is as per below, no POV event used.

===

  1. Above part of screen has some display only fields, suppose ITEM1.
  2. Below part has Oops ALV grid (using cl_gui_alv_grid) with an editable checkbox, like available inventory for this ITEM1.
  3. User selects check-box one by one in this ALV and without any further action from user, there should be a popup to tell that ITEM1 is fulfilled (suppose after 3 records selected). To do this popup,  I am calling FM - SAPGUI_SET_FUNCTIONCODE in event handling of alv.
  4. Once control reach PAI via this FM, some calculations are done in PAI and popup shown if required.
  5. When user gets popup that ITEM1 is done, they will press a pushbutton 'NEXT' which will show ITEM2 in top screen part and corresponding ITEM2 inventory records should be shown in ALV area now so that user can select again.

Point 5 is not working, no matter what I do, even on ITEM2 system is still showing ALV records of ITEM1 only.

I am using refresh_table_display and internal table is populated correctly with ITEM2 data, but still ITEM1 data is shown. If I comment FM - SAPGUI_SET_FUNCTIONCODE, then everything is working well.

I also tried to replace with CL_GUI_CFW=>SET_NEW_OK_CODE, but same refresh problem occurs.

Please help, let me know if more details are required.

15 REPLIES 15

Former Member
0 Kudos

Please help experts, let me know if scenario is not clear.

Simple way to put is - Same screen, same customer container, I want to refresh the data on press of push-button. It is not happening if I am using above said FM in event handling.

FM is used to trigger PAI when user select/unselect checkbox in ALV.

0 Kudos

Hi Diwakar,

Did you make use of cl_gui_cfw=>flush method? Please check this instead of the above mentioned FM.

"Generally this is to restrict the traffic b/w frontend and backend. This means that every operation in Control Framework should be first buffered in the backend and synchronized with the frontend at certain points (one of this point is calling synchronization method cl_gui_cfw=>flush ). This explicit order of synchronization is due to RFC call needed for every communication b/w front/back end. So to avoid to many RFC calls we do it only at certain time."

Please test using FLUSH method and let me know if the requirement is not met.

Thank You!

Syed.

0 Kudos

Hi Syed,

Thanks for reply, where this method needs to be used.

This cant replace FM as FM is helping me to trigger PAI event automatically on click of check-box. I need to take control to PAI to do some calculations (cannot be done outside PAI due to some other dependencies).

I have done event handling for EVENT data_changed OF cl_gui_alv_grid and used FM in perform of this event to trigger PAI with a dummy ok_code.

If I replace this FM with above-said method, it is not triggering PAI.

I also tried to replace FM with method  cl_gui_cfw=>set_new_ok_code, it is doing PAI triggering thing but problem of refresh remains same as with FM.

Any further help is appreciated.

Regards,

Diwakar

0 Kudos

Hi Diwakar,

Please use the FM and the method in tandem, but the method has to be called the moment you display the entries of ITEM1 i.e., in PAI of ITEM1 (after you store the selected data into internal table).

Because, Container is the same for both entries data display and there is another action in place (NEXT button) to trigger the PBO of ITEM2. So before this, the memory needs to be cleared. This is the routine culture of Dialog Programming.

Please check and let me know.

Thank You!

Syed.

0 Kudos

Hi Syed,

Tried it, still no change to status. ALV on Item2 header will still show ALV1 data.

What I tried :--

ALV Even handling --> Use same FM --> User click checkbox will Trigger PAI --> Do some computation.

After user has selected required no of entries, user will click NEXT button.

-------

In PAI,

When NEXT.

    if condition meet,

       FLUSH.

       call screen XYZ again (this is same current screen, calling again)

        

in PBO,

   Used Refresh ALV and Free container methods.

   Populate table with ITEM2 data.

Still ALV shows ITEM1 data only.

-----

2nd try FLUSH in PBO, also same.

Thanks for your sincere effort to help. Advice more

0 Kudos

Hi Diwakar,

I want you to use the FLUSH method before your computation. That is what is I mentioned in my earlier reply, to use immediately after you pick the data into your internal table after the user selects the number of records.

1. ALV Event handling

1.1. Here, check if the internal table has got the selected values and if they are in place, use FLUSH to clear the memory (Don't check for Initial of Internal table)

2. Use same FM

3. User click checkbox will Trigger PAI

4. Do some computation.

After you do the computation and reach the PBO, still the memory will hold the same values of ITEM1. So before you enter into this PBO layer you should clear those values.

Please do this in the debugging mode and paste those screen shots if possible otherwise you can send them to my mail Id and I will check the same from my end.

Thank You!

Syed.

Former Member
0 Kudos

Hi Diwakar,

How about you call refresh functionality before calling the pop-up screen?


       wa_stable-row = abap_true.

       wa_stable-col = abap_true.

       CALL METHOD g_grid->refresh_table_display

         EXPORTING

           is_stable = wa_stable

         EXCEPTIONS

           finished  = 1

           OTHERS    = 2.

Call pop-up.

Regards,

Gayatri

Former Member
0 Kudos

you can try below code:

Before creating the container free the object, as below:

IF zcl_cont2 IS NOT INITIAL.

     CALL METHOD zcl_cont2->free

       EXCEPTIONS

         cntl_error        = 1

         cntl_system_error = 2

         OTHERS            = 3.

   ENDIF.

   CREATE OBJECT zcl_cont2

     EXPORTING

       container_name = 'LV_CONT2'.

   CREATE OBJECT zcl_grid2

     EXPORTING

       i_parent = zcl_cont2.

   CALL METHOD zcl_grid2->set_table_for_first_display

     EXPORTING

       i_structure_name = 'ZSTR'

     CHANGING

       it_outtab        = t_output

       it_fieldcatalog  = t_fcat1.

0 Kudos

Hi Gayatri n Tiki,

I am already using Refresh_table_display method and Free container methods.

They are working fine also normally, but if I use FM in subject, then refresh is not happening.

Thanks.

0 Kudos

Hi Diwakar,

Why are you calling your screen again? Any specific reason?


In PAI,

When NEXT.

    if condition meet,

       FLUSH.

       call screen XYZ again (this is same current screen, calling again)


Because this will create many instances of the same screen in the call stack; and when you will press the button BACK - it wont let you exit the screen processing unless all the instances from the call stack have been popped out.

So instead of calling it again, can you please try the following: After user presses the button 'NEXT',  Call refresh method using CL_GUI_CFW=>SET_NEW_OK_CODE

Regards,

Gayatri

0 Kudos

Hi Gayatri,

Call refresh method using CL_GUI_CFW=>SET_NEW_OK_CODE, won't the control remain in PAI if I use this ?

All data fetching (populating data in internal table for ITEM2) is in PBO, so if control doesn't move to PBO how to get it.


Also, on what point screen will be refreshed with ITEM2 data if there is no call to original screen again.


You may be correct, please explain more and I will try

0 Kudos

Hi Diwakar,

Where are you calling REFRESH function currently?

If we are assuming 'NEXT' to be a triggering point for updating data, is there any possibility to update the internal table for display in the PAI Module? If done so, it will execute the refresh as needed.

raymond_giuseppi
Active Contributor
0 Kudos

Well if you want you report to be driven thru function-codes/user-command the  you will tirgger a PAI/PBO cycle, and refresh of the ALV grid MUST be executed in PBO (if initial/create/else/refresh/endif) ?

Regards,

Raymond

0 Kudos

Hi All,

I need more help, on further trouble-shooting I have concluded that my problem is there even when I am not using above-said Function module, when I try to take auto action on check-box click, this alv refresh problem is happening.

My scenario is as below :-

1. Some I/O fields on top of screen related to ITEM data and below part of screen is ALV grid with editable check-box showing item inventory.

2. Some orders which have two items, system will show item1 details, user will select records and once item 1 is fulfilled..there will be a popup to inform user and then user will click a pushbutton and item2 data and inventory should show-up.

3. Additional requirement is when user select a check-box, a field on top part from item data should show total quantity selected. so if each record is 20 qty, whenever user select record 1,2, 3.....field should change 20,40,60 ,....And a final popup when required quantity is met.

4. To do this requirement 3, I am using EVENT data_changed OF cl_gui_alv_grid. In event subroutine, I am calculating QTY field value and now to refresh this field value on top part of screen, I have tried 2 ways :-

a. Call PAI using FM or Suppress Dailog which inturn call PBO again and hence QTY field is correct.

b. Directly Call Same screen using "Call screel XYZ" in event subroutine to trigger PBO and QTY field is correct.

5. Everything is working well until here, but when required qty is met and user click the pushbutton, item2 details are displayed on top part but ALV grid is not refreshed with ITEM2 data. I am also using REFRESH_TABLE_DISPLAY in pbo before showing alv grid data.

If I am not doing 4a or 4b, then refresh is working perfectly well but QTY field is not getting refreshed on checkbox click which is requirement .

Please suggest what should be done, thanks.

former_member202818
Active Contributor
0 Kudos

Hi Diwakar,

Can you make sure that the alv and custom container objects creation happening only once.

if obj_alv is initial.

craete objects for alv and custom container.

endif.

Regards

Sreekanth