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

ALV refresh issue with Factory method

Former Member
0 Likes
2,077

Hi experts,

Am using cl_salv_table=>factory to display my grid ALV. In this ALV I have one more functionality as when user clicks on Document number

ALV redirected to FB02 transaction (using on_double_click event).


My functionality is if user does changes anything in the FB02 and then press F3 or back button come back to ALV screen. the changes should reflect in ALV.


please suggest.


Am not using any container. I have copied standard status in my program with extra button for REFRESH and am handling same in USER COMMAND.


TRY.

        CALL METHOD cl_salv_table=>factory

          IMPORTING

            r_salv_table = gr_table

          CHANGING

            t_table      = gt_final.

      CATCH cx_salv_msg .

    ENDTRY.

    IF gr_table IS INITIAL.

      MESSAGE 'Error Creating ALV Grid ' TYPE 'I' DISPLAY LIKE 'E'.

    ENDIF.

*.................. Set_screen_status ................................ *

*...include own functions by setting own status

    gr_table->set_screen_status(

    pfstatus      =  'STANDARD'

    report        =  sy-repid

    set_functions = gr_table->c_functions_all ).

**  To change the name of the column in ALV.

    gr_columns = gr_table->get_columns( ).

    gr_columns->set_optimize( abap_true ).

** Get functions details

    gr_functions = gr_table->get_functions( ).

**  Enable Selections

    gr_selections = gr_table->get_selections( ).

    gr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).

    TRY.

        gr_column ?= gr_columns->get_column( 'ATT_NAME' ).

        gr_column->set_long_text( 'Attachment Name'(001) ).

        gr_column->set_short_text( 'Att. Name'(002) ).

        gr_column->set_medium_text( 'Attachment Name'(001) ).

      CATCH cx_salv_not_found.                          "#EC NO_HANDLER

    ENDTRY.

    TRY.

        gr_column ?= gr_columns->get_column( 'ICON' ).

        gr_column->set_long_text( 'Status'(003) ).

        gr_column->set_short_text( 'Status'(003) ).

        gr_column->set_medium_text( 'Status'(003) ).

      CATCH cx_salv_not_found.                          "#EC NO_HANDLER

    ENDTRY.

    TRY.

        gr_column ?= gr_columns->get_column( 'INSTID' ).

        gr_column->set_visible( abap_false ).

      CATCH cx_salv_not_found.                          "#EC NO_HANDLER

    ENDTRY.

******* Event Register settings *******

    gr_event = gr_table->get_event( ).

    CREATE OBJECT gr_events.

    SET HANDLER gr_events->on_double_click FOR gr_event.

    SET HANDLER gr_events->on_user_command FOR gr_event.

    gr_table->display( ).

  ENDMETHOD.                    "display_alv

*----------------------------------------------------------------------*

*       METHOD on_double_click IMPLEMENTATION

*----------------------------------------------------------------------*

  METHOD on_double_click.

    DATA: ls_final TYPE ty_final.

    IF column EQ 'BELNR'.

      CLEAR : ls_final.

      READ TABLE gt_final INTO ls_final INDEX row.

      IF sy-subrc EQ 0.

        SET PARAMETER ID 'BLN' FIELD ls_final-belnr.

        SET PARAMETER ID 'BUK' FIELD ls_final-bukrs.

        SET PARAMETER ID 'GJR' FIELD ls_final-gjahr.

        CALL TRANSACTION 'FB02' AND SKIP FIRST SCREEN.

      ENDIF.

    ENDIF.

  ENDMETHOD.                    "on_double_click  method on_user_command.

----------------------------------------------------------------------*

*       METHOD on_user_command IMPLEMENTATION

*----------------------------------------------------------------------*

  METHOD on_user_command.

    DATA: lr_selections TYPE REF TO cl_salv_selections.

lr_selections = gr_table->get_selections( ).

    lt_rows = lr_selections->get_selected_rows( ).

    CASE e_salv_function.

WHEN 'REFRESH'.

************** Refresh Code here

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,312

Topic closed. Solved by my self.

Hi experts,

Am using cl_salv_table=>factory to display my grid ALV. In this ALV I have one more functionality as when user clicks on Document number

ALV redirected to FB02 transaction (using on_double_click event).


My functionality is if user does changes anything in the FB02 and then press F3 or back button come back to ALV screen. the changes should reflect in ALV.


please suggest.


Am not using any container. I have copied standard status in my program with extra button for REFRESH and am handling same in USER COMMAND.


TRY.

        CALL METHOD cl_salv_table=>factory

          IMPORTING

            r_salv_table = gr_table

          CHANGING

            t_table      = gt_final.

      CATCH cx_salv_msg .

    ENDTRY.

    IF gr_table IS INITIAL.

      MESSAGE 'Error Creating ALV Grid ' TYPE 'I' DISPLAY LIKE 'E'.

    ENDIF.

*.................. Set_screen_status ................................ *

*...include own functions by setting own status

    gr_table->set_screen_status(

    pfstatus      =  'STANDARD'

    report        =  sy-repid

    set_functions = gr_table->c_functions_all ).

**  To change the name of the column in ALV.

    gr_columns = gr_table->get_columns( ).

    gr_columns->set_optimize( abap_true ).

** Get functions details

    gr_functions = gr_table->get_functions( ).

**  Enable Selections

    gr_selections = gr_table->get_selections( ).

    gr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).

    TRY.

        gr_column ?= gr_columns->get_column( 'ATT_NAME' ).

        gr_column->set_long_text( 'Attachment Name'(001) ).

        gr_column->set_short_text( 'Att. Name'(002) ).

        gr_column->set_medium_text( 'Attachment Name'(001) ).

      CATCH cx_salv_not_found.                          "#EC NO_HANDLER

    ENDTRY.

    TRY.

        gr_column ?= gr_columns->get_column( 'ICON' ).

        gr_column->set_long_text( 'Status'(003) ).

        gr_column->set_short_text( 'Status'(003) ).

        gr_column->set_medium_text( 'Status'(003) ).

      CATCH cx_salv_not_found.                          "#EC NO_HANDLER

    ENDTRY.

    TRY.

        gr_column ?= gr_columns->get_column( 'INSTID' ).

        gr_column->set_visible( abap_false ).

      CATCH cx_salv_not_found.                          "#EC NO_HANDLER

    ENDTRY.

******* Event Register settings *******

    gr_event = gr_table->get_event( ).

    CREATE OBJECT gr_events.

    SET HANDLER gr_events->on_double_click FOR gr_event.

    SET HANDLER gr_events->on_user_command FOR gr_event.

    gr_table->display( ).

  ENDMETHOD.                    "display_alv

*----------------------------------------------------------------------*

*       METHOD on_double_click IMPLEMENTATION

*----------------------------------------------------------------------*

  METHOD on_double_click.

    DATA: ls_final TYPE ty_final.

    IF column EQ 'BELNR'.

      CLEAR : ls_final.

      READ TABLE gt_final INTO ls_final INDEX row.

      IF sy-subrc EQ 0.

        SET PARAMETER ID 'BLN' FIELD ls_final-belnr.

        SET PARAMETER ID 'BUK' FIELD ls_final-bukrs.

        SET PARAMETER ID 'GJR' FIELD ls_final-gjahr.

        CALL TRANSACTION 'FB02' AND SKIP FIRST SCREEN.

      ENDIF.

    ENDIF.

  ENDMETHOD.                    "on_double_click  method on_user_command.

----------------------------------------------------------------------*

*       METHOD on_user_command IMPLEMENTATION

*----------------------------------------------------------------------*

  METHOD on_user_command.

    DATA: lr_selections TYPE REF TO cl_salv_selections.

lr_selections = gr_table->get_selections( ).

    lt_rows = lr_selections->get_selected_rows( ).

    CASE e_salv_function.

WHEN 'REFRESH'.

************** Refresh Code here

1 REPLY 1
Read only

Former Member
0 Likes
1,313

Topic closed. Solved by my self.