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: 

OO - ALV 2nd ALV Output shows only Prior Display

Former Member
0 Kudos

I have a Reporting system built in a function group. The user presses a function which calls the function module that does the reporting. I build the ALV and display without difficulty. The user backs out, via the back or exit or cancel. At that time, I call the gui FLUSH method. The user selects the same function (without leaving the application transaction). I enter the report ALV logic. I initialize the tables and the REF TO objects for ALV and Container. I call the ALV with set table for first display, GUI FLUSH....set my event receiver, etc., gui FLUSH again.

At that point the ALV appears with the data from the prior display. But, as soon as I press one of the standard ALV buttons, such as the REFRESH function, the refresh occurs and the display now shows the correct data. Oddly, pressing one of my custom function buttons has no effect. Use of FREE has had no effect except to remove the container completely. Setting the LIFETIME parameter for the container has no effect or completely removes the container.

Question...how can I force the 2nd and subsequent entries to the ALV output to show the correct, current display, instead of the data for the prior display?

ALV CODE:

* Create the field catalog
  PERFORM field_catalog_siur.
  ls_variant-report = sy-repid.
*
* Layout Structure
  PERFORM change_siur_grid_layout.
*
* Hide unwanted toolbar buttons
  PERFORM hide_siu_grid0102_toolbar
              TABLES siu_funct_0102.
*
* Create the grid
  PERFORM create_sui_grid0102.
*

*  display the alv output
  CALL METHOD siu_grid_0102->set_table_for_first_display
    EXPORTING
      i_bypassing_buffer   = gc_x
      i_buffer_active      = space
      is_variant           = ls_variant
      i_save               = gc_a
      i_default            = gc_x
      is_layout            = siu_layout_0102
      it_toolbar_excluding = siu_funct_0102
      i_structure_name     = 'ZST_SIU_ACTV_LIST'
    CHANGING
      it_outtab            = gt_siuv[]
      it_fieldcatalog      = siu_fieldcat_0102[].
*
* Register Events
  CREATE OBJECT event_receiver.
* define the handlers.
  SET HANDLER event_receiver->handle_user_command FOR siu_grid_0102.
  SET HANDLER event_receiver->handle_toolbar      FOR siu_grid_0102.
  SET HANDLER event_receiver->handle_double_click FOR siu_grid_0102.
* Make the new functions visible.
  CALL METHOD siu_grid_0102->set_toolbar_interactive.

Edited by: BreakPoint on Feb 2, 2012 11:14 PM

4 REPLIES 4

naimesh_patel
Active Contributor
0 Kudos

If you are destroying the control using the FREE, means you need to refresh using the REFRESH_TABLE_DISPLAY ALV, if it is bound. If you destroy the ALV object using the clear before creating another one, you need to kill the Containers as well.

I generally, destroy the ALV using FREE and get rid of the ALV object as well when user doesn't completely get out the transaction before starting the next one.

Regards,

Naimesh Patel

0 Kudos

Thanks for the reply. Not sure what you mean with the REFRESH, since I can't do that after a CLEAR on the ALV Grid. Where would I refresh in this case.

CASE sy-ucomm.
    WHEN 'CANCEL' OR 'BACK' OR 'EXIT'.
      PERFORM build_archive_table.
      CALL METHOD siu_grid_0102->free( ).  
      LEAVE TO SCREEN 0.
  ENDCASE.

After I do this, upon re-entry to the ALV output, I have no ALV display at all, just an empty screen, even though I did the create. The FREE method call destroys all hope of subsequent output, apparently, without leaving and re-entering the underlying application transaction.

IF siu_grid_0102 IS INITIAL.
    CREATE OBJECT siu_custom_cont_0102
      EXPORTING
        container_name = 'SIU_ACTVX'.
    CREATE OBJECT siu_grid_0102
      EXPORTING
        i_parent   = siu_custom_cont_0102.
  ENDIF.

0 Kudos

When you call the FREE method, you need to clear the ALV grid object.


CASE sy-ucomm.
    WHEN 'CANCEL' OR 'BACK' OR 'EXIT'.
      PERFORM build_archive_table.
      CALL METHOD siu_grid_0102->free( ).  
      clear: siu_grid_0102.
      LEAVE TO SCREEN 0.
  ENDCASE.

So, when it executes next time, it would re-instantiate the Grid again.

Regards,

Naimesh Patel

Thanks for the response again! I believe I've corrected my own error. I need to create the CONTAINER object with parameter lifetime = cntl_lifetime_dynpro. I believe when I first supplied a lifetime, I tried to put it on the ALV object, which was incorrect, of course. Now that I have lifetime on the container, I'm getting the proper display.

Thanks again.