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: 

Refresh button on ALV OO report

Former Member
0 Kudos

How to add a refresh button to this report. Thank you.

DATA: ispfli TYPE TABLE OF spfli.

DATA: gr_table      TYPE REF TO cl_salv_table.
DATA: gr_functions  TYPE REF TO cl_salv_functions.
DATA: gr_display    TYPE REF TO cl_salv_display_settings.
DATA: gr_columns    TYPE REF TO cl_salv_columns_table.
DATA: gr_column     TYPE REF TO cl_salv_column_table.
DATA: gr_sorts      TYPE REF TO cl_salv_sorts.
data: gr_filter     type REF TO cl_salv_filters.

DATA: color TYPE lvc_s_colo.


START-OF-SELECTION.
  SELECT * INTO TABLE ispfli FROM spfli.

  cl_salv_table=>factory( IMPORTING r_salv_table = gr_table
                          CHANGING t_table = ispfli ).

  gr_functions = gr_table->get_functions( ).
  gr_functions->set_all( abap_true ).

  gr_display = gr_table->get_display_settings( ).
  gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
  gr_display->set_list_header( 'This is the heading' ).

  gr_columns = gr_table->get_columns( ).
  gr_column ?= gr_columns->get_column( 'CITYTO').
  gr_column->set_long_text( 'Destination' ).
  gr_column->set_medium_text( 'Test' ).
  gr_column->set_short_text( 'Test' ).
  color-col = '3'.
  color-int = '1'.
  color-inv = '0'.
  gr_column->set_color( color ).

  gr_sorts = gr_table->get_sorts( ).
  gr_sorts->add_sort( 'CITYTO' ).

  gr_filter = gr_table->get_filters( ).
  gr_filter->add_filter( columnname = 'CARRID' low = 'LH') .

  gr_table->display( ).

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Ok first you need to copy the gui status STANDARD from the function group SALV into your program. This is the standard gui status used for the toolbar in your program, next modify it and add a button to the toolbar for your refresh. Then in you program, you need to tell it to use this status instead.

cl_salv_table=>factory( IMPORTING r_salv_table = gr_table
                          CHANGING t_table = ispfli ).
 
* Here you are telling the alv object to use this gui status instead
 gr_table->set_screen_status(
              pfstatus      =  'STANDARD'
              report        =  sy-repid
              set_functions = gr_table->c_functions_all ).

Now, you will have your button on the toolbar, but you will still need to handle it.

Check program SALV_DEMO_TABLE_FUNCTIONS to see what the procedures are to handle your custom button.

REgards,

Rich Heilman

10 REPLIES 10

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Ok first you need to copy the gui status STANDARD from the function group SALV into your program. This is the standard gui status used for the toolbar in your program, next modify it and add a button to the toolbar for your refresh. Then in you program, you need to tell it to use this status instead.

cl_salv_table=>factory( IMPORTING r_salv_table = gr_table
                          CHANGING t_table = ispfli ).
 
* Here you are telling the alv object to use this gui status instead
 gr_table->set_screen_status(
              pfstatus      =  'STANDARD'
              report        =  sy-repid
              set_functions = gr_table->c_functions_all ).

Now, you will have your button on the toolbar, but you will still need to handle it.

Check program SALV_DEMO_TABLE_FUNCTIONS to see what the procedures are to handle your custom button.

REgards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Also, here is a tutorial which will walk you thru the entire process. With screenshots. Hope it is helpful.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/alv%20object%...

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Once you get your event handler working, you should simply be able to call the REFRESH method from within the event handler method and it will refresh the display.,

gr_table->REFRESH( ).

REgards,

RIch Heilman

Former Member
0 Kudos
 gr_table->set_screen_status(
              pfstatus      =  'STANDARD'
              report        =  sy-repid
              set_functions = gr_table->c_functions_all ).

This is giving me a dump

0 Kudos

Did you copy the STANDARD gui status into your program? If yes, then what is the dump that you are getting.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Rich,

No I did not. How do I copy it.

Thanks

0 Kudos

Go to SE80, enter the name of the function group and hit enter, you can either copy the gui status from function group SALV, or the standard gui status from function group SALV_METADATA_STATUS. I think it may be better to use the SALV_TABLE_STANDARD from function group SALV_METADATA_STATUS instead of the STANDARD from SALV function group. Go to this funciton group, and right-click on the status that you want to copy, and choose copy. In the dialog, give the name of your program where you want to copy the status too. Once it has been copied, you need to add the button, also make sure that you pass the correct name of the status to the method below.

 gr_table->set_screen_status(
              pfstatus      =  'SALV_STANDARD'    "<-- this is the name of the copied gui status
              report        =  sy-repid
              set_functions = gr->c_functions_all ).

Again, check out the document I have supplied above, it will walk you thru the entire process(except for copying the gui status)

Regards,

Rich Heilman

Former Member
0 Kudos

When I put this code, I do not see the refresh button. It doesnt dump though, so thats good

  gr_table->set_screen_status(
               pfstatus      = 'SALV_TABLE_STANDARD'
               report        = sy-repid
               set_functions = gr_table->c_functions_all ).

0 Kudos

Did you add the button to the toolbar in this gui status? You must do that. Essential what you are doing is copying the standard toolbar, and now you need to add your custom button to it. Once you have added the button and activated the gui status, it will then show up on your toolbar when the ALV is displayed, again, you should check out that document above.

Regards,

Rich Heilman

0 Kudos

Hi Rich,

I know the above will seem ages ago.

I have a similar requirement and need to introduce an editable check-mark against each row of the fetched rows from a DB Table.

Can you please let me know how to introduce the editable check mark and then based on the final state of the checked record-set need to read the set and update the DB Table ?

THanks,

Pankaj