Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
manijangiti
Participant
587

Hi Everyone,

Recently, I worked on a requirement where the ALV output needed to appear dynamically on the same screen using a docking container instead of a separate list output. This makes the UI much more user-friendly, especially when running programs multiple times during testing.

While SALV handles the ALV part, the interesting part is embedding it inside a docking container placed at the bottom of the screen.
Below is a simple example using the SFLIGHT table. I drafted this article with support from a generative AI tool, but the explanation and experiences shared here are based on my own learning and practical testing.

REPORT ZALV_SALV_DOCK_DEMO.


CLASS LCL_REPORT DEFINITION.
  PUBLIC SECTION.
    DATA: LT_DATA   TYPE STANDARD TABLE OF SFLIGHT,     "Output data
          LR_CARRID TYPE RANGE OF SFLIGHT-CARRID.      "Select Options

    METHODS:
      GET_DATA,
      GENERATE_OUTPUT.
ENDCLASS.

DATA: LR_REPORT TYPE REF TO LCL_REPORT,
      G_CARRID  TYPE SFLIGHT-CARRID.


SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE G_TITLE.
SELECT-OPTIONS: S_CARRID FOR G_CARRID.
SELECTION-SCREEN END OF BLOCK BLK1.

INITIALIZATION.
  G_TITLE = 'Selection Criteria'.
  CREATE OBJECT LR_REPORT.
  LR_REPORT->GENERATE_OUTPUT( ).

START-OF-SELECTION.
  LR_REPORT->LR_CARRID = S_CARRID[].
  LR_REPORT->GET_DATA( ).

*---------------------------------------------------------------------*
* Class Implementation
*---------------------------------------------------------------------*
CLASS LCL_REPORT IMPLEMENTATION.

  METHOD GET_DATA.
    "Fetch data
    SELECT *
      FROM SFLIGHT
      INTO TABLE ME->LT_DATA
      WHERE CARRID IN LR_CARRID.

    IF SY-DBCNT IS INITIAL.
      MESSAGE S398(00) WITH 'No data selected'.
    ENDIF.

    "Export to memory
    EXPORT DATA = ME->LT_DATA TO MEMORY ID SY-CPROG.
  ENDMETHOD.


  METHOD GENERATE_OUTPUT.
    DATA: LR_DOCK      TYPE REF TO CL_GUI_DOCKING_CONTAINER,
          LR_CONTAINER TYPE REF TO CL_GUI_CONTAINER,
          LR_ALV       TYPE REF TO CL_SALV_TABLE.

    "Import internal table
    IMPORT DATA = ME->LT_DATA FROM MEMORY ID SY-CPROG.
    FREE MEMORY ID SY-CPROG.

    CHECK ME->LT_DATA IS NOT INITIAL.

    "Create docking container at bottom
    CREATE OBJECT LR_DOCK
      EXPORTING
        REPID = SY-CPROG
        DYNNR = SY-DYNNR
        RATIO = 80
        SIDE  = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_BOTTOM
        NAME  = 'DOCK_CONT'.

    "Container assignment
    LR_CONTAINER ?= LR_DOCK.

    TRY.
        "Create SALV inside the docking container
        CL_SALV_TABLE=>FACTORY(
          EXPORTING
            LIST_DISPLAY   = IF_SALV_C_BOOL_SAP=>FALSE
            R_CONTAINER    = LR_CONTAINER
            CONTAINER_NAME = 'DOCK_CONT'
          IMPORTING
            R_SALV_TABLE   = LR_ALV
          CHANGING
            T_TABLE        = ME->LT_DATA ).
      CATCH CX_SALV_MSG.
    ENDTRY.

    "Enable standard functions
    DATA(LR_FUNCTIONS) = LR_ALV->GET_FUNCTIONS( ).
    LR_FUNCTIONS->SET_DEFAULT( ABAP_TRUE ).

    "Display ALV
    LR_ALV->DISPLAY( ).
  ENDMETHOD.

ENDCLASS.

 

  • The ALV appears at the bottom of the same screen

  • All SALV functions like sorting, filtering, and export are enabled

  • Code is modular and reusable
    This example is useful when building interactive ABAP reports where the user should not leave the main selection screen. Using a docking container provides a clean and modern presentation for your ALV list.

    If you want to display multiple ALVs, add toolbars, or enhance SALV—for example with custom columns—I’d be happy to share extended examples as well.

    Selection Screen :
    image.png
    After Executing :
    image.png

    ✅ Conclusion (Detailed & Explanatory)

    By embedding the ALV Grid inside a docking container, we avoid the traditional list output and deliver a more user-friendly experience directly on the selection screen. SALV handles the formatting and functions, while the docking container ensures a flexible and consistent UI layout. This technique is highly useful for interactive reports, dashboards, and test-driven programs. While AI helped in organizing and refining the content, the logic, experimentation, and lessons shared are based on my own practical ABAP development work.


    ABAP Development 
    SAP BTP ABAP environment