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

CL_SALV_TREE refresh

aidan_mulcahy
Active Participant
0 Likes
3,304

Hi,

sample program SALV_DEMO_TREE_EVENTS displays a fresh set of data when you press F3, shift F3 or F12.

It does this in routine display_fullscreen by:

1) calling the cl_salv_tree->factory etc... as far as gr_tree->display( ).

2) Press F3 goes into standard SLVC_FULLSCREEN routine tree_exit

3) calling the cl_salv_tree->factory etc... as far as gr_tree->display( ) with new data.

I want to move this to a user_command so that I can refresh the data on the screen without the need to exit and re-run. Effectively, how can I do step 2 with user_command (pressing a button)?

Thanks..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,963

Hi Aidan,

When you press F3 it runs the same code for displaying the tree again.

First create a button in the PF Status of the screen.(100 in this case)

Then in the PAI add the code for calling the code in PBO from the FACTORY method.

   FORM d0100_pai .
  CASE ok_code.
    WHEN 'BACK' OR 'EXIT' OR 'QUIT'.
      CLEAR ok_code.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'REF'.
      CALL METHOD gr_container->free.
      CLEAR gr_tree.
      REFRESH gt_outtab.
      TRY.
          IF cl_salv_tree=>is_offline( ) EQ if_salv_c_bool_sap=>false.
            CREATE OBJECT gr_container
              EXPORTING
                container_name = 'CONTAINER'.
          ENDIF.
          cl_salv_tree=>factory(
            EXPORTING
              r_container  = gr_container
            IMPORTING
              r_salv_tree = gr_tree
            CHANGING
              t_table      = gt_outtab ).
        CATCH cx_salv_error.
          EXIT.
      ENDTRY.
      PERFORM create_tree.
*... §3 Functions
*... §3.1 activate ALV some Functions
*... §3.2 add your own button at the left
      DATA: lr_functions TYPE REF TO cl_salv_functions_tree.
      lr_functions = gr_tree->get_functions( ).
      lr_functions->set_all( gc_true ).
      lr_functions->set_group_print( abap_false ).

      PERFORM set_columns_technical.
      PERFORM application_action.
*... §5 display the table
      gr_tree->display( ).
  ENDCASE.
ENDFORM.      

Thanks,

Shambu

Hi Aidan,

When you press F3 it runs the same code for displaying the tree again.

First create a button in the PF Status of the screen.(100 in this case)

Then in the PAI add the code for calling the code in PBO from the FACTORY method.

   FORM d0100_pai .
  CASE ok_code.
    WHEN 'BACK' OR 'EXIT' OR 'QUIT'.
      CLEAR ok_code.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'REF'.
      CALL METHOD gr_container->free.
      CLEAR gr_tree.
      REFRESH gt_outtab.
      TRY.
          IF cl_salv_tree=>is_offline( ) EQ if_salv_c_bool_sap=>false.
            CREATE OBJECT gr_container
              EXPORTING
                container_name = 'CONTAINER'.
          ENDIF.
          cl_salv_tree=>factory(
            EXPORTING
              r_container  = gr_container
            IMPORTING
              r_salv_tree = gr_tree
            CHANGING
              t_table      = gt_outtab ).
        CATCH cx_salv_error.
          EXIT.
      ENDTRY.
      PERFORM create_tree.
*... §3 Functions
*... §3.1 activate ALV some Functions
*... §3.2 add your own button at the left
      DATA: lr_functions TYPE REF TO cl_salv_functions_tree.
      lr_functions = gr_tree->get_functions( ).
      lr_functions->set_all( gc_true ).
      lr_functions->set_group_print( abap_false ).

      PERFORM set_columns_technical.
      PERFORM application_action.
*... §5 display the table
      gr_tree->display( ).
  ENDCASE.
ENDFORM.      

Thanks,

Shambu

2 REPLIES 2
Read only

Former Member
0 Likes
1,964

Hi Aidan,

When you press F3 it runs the same code for displaying the tree again.

First create a button in the PF Status of the screen.(100 in this case)

Then in the PAI add the code for calling the code in PBO from the FACTORY method.

   FORM d0100_pai .
  CASE ok_code.
    WHEN 'BACK' OR 'EXIT' OR 'QUIT'.
      CLEAR ok_code.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'REF'.
      CALL METHOD gr_container->free.
      CLEAR gr_tree.
      REFRESH gt_outtab.
      TRY.
          IF cl_salv_tree=>is_offline( ) EQ if_salv_c_bool_sap=>false.
            CREATE OBJECT gr_container
              EXPORTING
                container_name = 'CONTAINER'.
          ENDIF.
          cl_salv_tree=>factory(
            EXPORTING
              r_container  = gr_container
            IMPORTING
              r_salv_tree = gr_tree
            CHANGING
              t_table      = gt_outtab ).
        CATCH cx_salv_error.
          EXIT.
      ENDTRY.
      PERFORM create_tree.
*... §3 Functions
*... §3.1 activate ALV some Functions
*... §3.2 add your own button at the left
      DATA: lr_functions TYPE REF TO cl_salv_functions_tree.
      lr_functions = gr_tree->get_functions( ).
      lr_functions->set_all( gc_true ).
      lr_functions->set_group_print( abap_false ).

      PERFORM set_columns_technical.
      PERFORM application_action.
*... §5 display the table
      gr_tree->display( ).
  ENDCASE.
ENDFORM.      

Thanks,

Shambu

Read only

0 Likes
1,963

Thanks Shambu,

that looks like it would work if I was using the container section of the standard, but I'm not.

I'm going to award full points anyway as I wasn't clear on that.

I did get it working by putting setting my 'REFRESH' button to have okcode =  '&F03' so it uses SAP code.

And then in my code:

WHILE SY-UCOMM ne 'BACK. "only way the program can be exited.

..

create_tree etc...

...

endwhile

the only problem I have now is that they will want the nodes that are expanded to remain expanded after refresh....for now, they are closed....must check that.

Thanks for your help.