Jumping between two ALV lists.

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Post Reply
Ronster
Posts: 134
Joined: Thu Apr 14, 2005 3:07 am
Location: Holland

Jumping between two ALV lists.

Post by Ronster » Thu May 22, 2008 6:01 am

Hi all,

I made a report (OO) with two ALV lists. First the main ALV presents the data. When doubleclicking the line the second ALV is called with more details on it.
When I press back, the main alv is displayed again. So far so good!

Problem is from this point the double click doesn't work anymore!

(Actually while debugging I see that the routine is correct: with data from the main table the detailed data table is filled, and then it uses commands like:

Code: Select all

CALL METHOD g_alv_grid->set_table_for_first_display
... to display the detailed data-alv.

I use this

Code: Select all

CALL METHOD g_alv_grid->set_table_for_first_display
for both ALV lists. Is this correct, or is there an alternative for the detailed alv list?
Cheers!

Ron.

phillipm
Posts: 376
Joined: Fri Oct 25, 2002 3:54 am
Location: Lyon, France

Re: Jumping between two ALV lists.

Post by phillipm » Thu May 22, 2008 7:07 am

Why don't you use the docking control?
You have the main list in the dock and the detail list in the main container.
Check the following (and sorry for the italian):

Code: Select all

REPORT zpm_docking.

* Definizione anticipata di una classe
* ricettore di eventi
CLASS alv_event_receiver DEFINITION DEFERRED.

* ----- Contenitori
DATA:
    dock            TYPE REF TO cl_gui_docking_container,
    main_container  TYPE REF TO cl_gui_custom_container
    .

* ----- Contenuti aree
*
DATA:
    alv_in_dock     TYPE REF TO cl_gui_alv_grid,
    alv_in_gui      TYPE REF TO cl_gui_alv_grid,
    event_receiver  TYPE REF TO alv_event_receiver.


* ----- Tipi
* tipi dati ALV
TYPE-POOLS: slis.

TYPES:
    BEGIN OF t_vbak_small,
      vbeln LIKE vbak-vbeln,
      auart LIKE vbak-auart,
    END OF t_vbak_small,
    BEGIN OF functions_line,
     function(10),
    END OF functions_line
    .
* ALV
DATA:
    reuse_catalog TYPE slis_t_fieldcat_alv,
    wa_catalog    LIKE LINE OF reuse_catalog
    .

* ----- Strutture e work area
DATA:
    alv_fcat_dock        TYPE lvc_t_fcat,
    wa_fcat_dock         LIKE LINE OF alv_fcat_dock,
    gt_fieldcat_lvc      TYPE lvc_t_fcat,
    gt_fcat_func         TYPE lvc_t_fcat,
    wa_fcat_func         LIKE LINE OF gt_fcat_func,
    functions            TYPE STANDARD TABLE OF functions_line,
    wa_functions         LIKE LINE OF functions,
    excl_dock_functions  TYPE ui_functions,
    wa_dock_fn           TYPE ui_func
    .

* Strutture dati
DATA:
    t_vbak      TYPE TABLE OF vbak,
    t_vbap      TYPE TABLE OF vbap,
    t_dock_data TYPE STANDARD TABLE OF t_vbak_small,
    t_gui_data  TYPE STANDARD TABLE OF vbap,
    wa_gui_dt   LIKE vbap
    .

* Campi vari
DATA:
    init,
    result_alv_displayed,
    ok_code              TYPE sy-ucomm,
    repid                TYPE sy-repid,
    dynnr                TYPE sy-dynnr.

* Screen che conterrà il contenitore principale 'CUSTOM'
CALL SCREEN 100.


* Definizione altre classi
* definizione classe ricettore eventi
CLASS alv_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
        handle_double_click FOR EVENT double_click
                             OF cl_gui_alv_grid
                             IMPORTING e_row
                                       e_column.

  PRIVATE SECTION.

ENDCLASS.


*---------------------------------------------------------------------*
*       CLASS alv_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS alv_event_receiver IMPLEMENTATION.
  METHOD handle_double_click.

    PERFORM alv_event_double_click USING e_row
                                         e_column.

  ENDMETHOD.
ENDCLASS.


*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.

*  SET PF-STATUS 'xxxxxxxx'.
  SET TITLEBAR 'MAIN'.
  IF init IS INITIAL.
    repid = sy-repid.
    dynnr = sy-dynnr.

* Creare contenitore principale
* Creare il contenitore
    CREATE OBJECT main_container
                  EXPORTING container_name = 'CUSTOM'.

* create the docking container
    CREATE OBJECT dock
                  EXPORTING repid     = repid
                            dynnr     = dynnr
                            side      = dock->dock_at_left
                            extension = 200
                            caption   = 'The caption'
                            .

* Staccare il dock dalla gui.
* Documentato ma non funziona. Sarà per futura versione.
* valori possibili per do_float:
*  - Attaccato: dock->property_docking
*  - Staccato:  dock->property_floating
*    CALL METHOD dock->float
*           EXPORTING
*              do_float          = dock->property_docking
*           EXCEPTIONS
*              cntl_system_error = 1
*              cntl_error        = 2.


    PERFORM alv_create.                 "creazione oggetti
    PERFORM alv_catalogs.               "preparazione catalogo
    PERFORM alv_dock_data.
    PERFORM alv_interface.
*    perform alv_main_data.
    PERFORM alv_output.                 "display ALV

    init = 'X'.

    CREATE OBJECT event_receiver.

* registrare eventi per ALV grid
*  if gs_test-event-double_click eq con_true.
    SET HANDLER event_receiver->handle_double_click
                FOR alv_in_dock.


  ENDIF.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  alv_create
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM alv_create.
* alv nel Dock
  CREATE OBJECT alv_in_dock
    EXPORTING
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
      i_parent          = dock
*    I_APPL_EVENTS     = space
*    I_PARENTDBG       =
*    I_APPLOGPARENT    =
*    I_GRAPHICSPARENT  =
*    I_USE_VARIANT_CLASS = SPACE
*    I_NAME            =
*  EXCEPTIONS
*    ERROR_CNTL_CREATE = 1
*    ERROR_CNTL_INIT   = 2
*    ERROR_CNTL_LINK   = 3
*    ERROR_DP_CREATE   = 4
*    others            = 5
      .

* ALV in gui
  CREATE OBJECT alv_in_gui
    EXPORTING
*    I_SHELLSTYLE      = 0
*    I_LIFETIME        =
      i_parent          = main_container
*    I_APPL_EVENTS     = space
*    I_PARENTDBG       =
*    I_APPLOGPARENT    =
*    I_GRAPHICSPARENT  =
*    I_USE_VARIANT_CLASS = SPACE
*    I_NAME            =
*  EXCEPTIONS
*    ERROR_CNTL_CREATE = 1
*    ERROR_CNTL_INIT   = 2
*    ERROR_CNTL_LINK   = 3
*    ERROR_DP_CREATE   = 4
*    others            = 5
      .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " alv_create
*&---------------------------------------------------------------------*
*&      Form  alv_output
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM alv_output.

  CALL METHOD alv_in_dock->set_table_for_first_display
    EXPORTING
      i_structure_name              = 'T_DOCK_DATA'
*    IS_VARIANT                    =
*    I_SAVE                        =
*    I_DEFAULT                     = 'X'
*    IS_LAYOUT                     =
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
    it_toolbar_excluding          = excl_dock_functions
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
    CHANGING
      it_outtab                     = t_dock_data[]
      it_fieldcatalog               =  alv_fcat_dock
*    IT_SORT                       =
*    IT_FILTER                     =
*  EXCEPTIONS
*    INVALID_PARAMETER_COMBINATION = 1
*    PROGRAM_ERROR                 = 2
*    TOO_MANY_LINES                = 3
*    others                        = 4
          .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL METHOD alv_in_gui->set_table_for_first_display
    EXPORTING
      i_structure_name              = 'VBAP'
*    IS_VARIANT                    =
*    I_SAVE                        =
*    I_DEFAULT                     = 'X'
*    IS_LAYOUT                     =
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          = excl_dock_functions
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
    CHANGING
      it_outtab                     = t_vbap[]
*      it_fieldcatalog               =  gt_fcat_func
*    IT_SORT                       =
*    IT_FILTER                     =
*  EXCEPTIONS
*    INVALID_PARAMETER_COMBINATION = 1
*    PROGRAM_ERROR                 = 2
*    TOO_MANY_LINES                = 3
*    others                        = 4
          .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " alv_output
*&---------------------------------------------------------------------*
*&      Form  alv_catalogs
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM alv_catalogs.
  DATA: repid LIKE sy-repid.
*  wa_fcat_func-fieldname = 'FUNCTION'.
*  wa_fcat_func-tabname   = 'FUNCTIONS'.
*  wa_fcat_func-outputlen = 30.
*  wa_fcat_func-scrtext_m = 'Function'.
*  append wa_fcat_func to gt_fcat_func.

  repid = sy-repid.
* Catalogo VBAK small

  PERFORM alv_cat_old2new.

* Catalogo VBAP


ENDFORM.                    " alv_catalogs
*&---------------------------------------------------------------------*
*&      Form  alv_dock_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM alv_dock_data.

  DATA:
    dt_start LIKE sy-datum.
  dt_start = sy-datum - 6.

  SELECT * UP TO 10 ROWS
           FROM vbak
           INTO CORRESPONDING FIELDS OF TABLE t_dock_data
          WHERE erdat LE sy-datum
            AND erdat GE dt_start
           .

ENDFORM.                    " alv_dock_data
*&---------------------------------------------------------------------*
*&      Form  alv_cat_old2new
*&---------------------------------------------------------------------*
*       Passaggio dati catalogo da struttura classica a nuova
*----------------------------------------------------------------------*
FORM alv_cat_old2new.

*  loop at reuse_catalog into wa_catalog.
*    move-corresponding wa_catalog to wa_fcat_dock.

  wa_fcat_dock-fieldname = 'VBELN'.
  wa_fcat_dock-tabname   = 'T_DOCK_DATA'.
  wa_fcat_dock-outputlen = 15.
  wa_fcat_dock-scrtext_m = 'Ordine'.
  APPEND wa_fcat_dock TO alv_fcat_dock.
*  endloop.

  wa_fcat_dock-fieldname = 'AUART'.
  wa_fcat_dock-tabname   = 'T_DOCK_DATA'.
  wa_fcat_dock-outputlen = 5.
  wa_fcat_dock-scrtext_m = 'Tipo'.
  APPEND wa_fcat_dock TO alv_fcat_dock.


ENDFORM.                    " alv_cat_old2new
*&---------------------------------------------------------------------*
*&      Form  alv_interface
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM alv_interface.
* interfaccia gui per ALV laterale SIDE_AREA
*wa_dock_fn = '&F15'.
*append wa_dock_fn to excl_dock_functions.
*


  wa_dock_fn = cl_gui_alv_grid=>mc_mb_view.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_mb_sum.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_loc_insert_row.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_print.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_save_variant.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_maintain_variant.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_sort_asc.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_sort_dsc.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_filter.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_graph.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_mb_export.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_views.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_find.
  APPEND wa_dock_fn TO excl_dock_functions.
  wa_dock_fn = cl_gui_alv_grid=>mc_fc_find.
  APPEND wa_dock_fn TO excl_dock_functions.


ENDFORM.                    " alv_interface
*&---------------------------------------------------------------------*
*&      Form  alv_event_double_click
*&---------------------------------------------------------------------*
*       Il doppio click in ALV_IN_DOCK avrà effetto sull'oggetto
*       ALV_IN_GUI
*----------------------------------------------------------------------*
*      -->P_E_ROW  text
*      -->P_E_COLUMN  text
*----------------------------------------------------------------------*
FORM alv_event_double_click USING    p_e_row
                                     p_e_column.
  DATA: wa_dock_dt LIKE LINE OF t_dock_data.

  READ TABLE  t_dock_data
        INTO  wa_dock_dt
        INDEX p_e_row.

  SELECT * FROM vbap
           INTO TABLE t_vbap
          WHERE vbeln EQ wa_dock_dt-vbeln.


  IF result_alv_displayed IS INITIAL.
* first_display
    CALL METHOD alv_in_gui->set_table_for_first_display
      EXPORTING
*    I_BYPASSING_BUFFER            =
*    I_BUFFER_ACTIVE               =
*    I_CONSISTENCY_CHECK           =
        i_structure_name              = 'VBAP'
*    IS_VARIANT                    =
*    I_SAVE                        =
*    I_DEFAULT                     = 'X'
*    IS_LAYOUT                     =
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
      CHANGING
        it_outtab                     = t_vbap
*    IT_FIELDCATALOG               =
*    IT_SORT                       =
*    IT_FILTER                     =
*  EXCEPTIONS
*    INVALID_PARAMETER_COMBINATION = 1
*    PROGRAM_ERROR                 = 2
*    TOO_MANY_LINES                = 3
*    others                        = 4
            .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

  ELSE.
* refresh

  ENDIF.

ENDFORM.                    " alv_event_double_click
*&---------------------------------------------------------------------*
*&      Module  user_command_100  INPUT
*&---------------------------------------------------------------------*
MODULE user_command_100 INPUT.

  CASE ok_code.
    WHEN 'BACK'.
      CALL METHOD dock->free.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.                 " user_command_100  INPUT
cheers,

pm

Ronster
Posts: 134
Joined: Thu Apr 14, 2005 3:07 am
Location: Holland

Re: Jumping between two ALV lists.

Post by Ronster » Thu May 22, 2008 9:33 am

Grazie! I will try work from here!
Cheers!

Ron.

Post Reply