SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Display ALV report output in the SAME Selection Screen



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Fri Jan 30, 2009 12:20 pm    Post subject: Display ALV report output in the SAME Selection Screen Reply with quote

Author: Naimesh Patel

Shows the way to dispaly the report output in the same selection screen using Docking Container and SLAV 2D Table display with minimal coding

When we start running the report, it will be a normal Selection Screen:


After executing the report, our output will overlay on the Selection Screen. And it will look like this:


Steps to create an ALV on the Selection Screen, in summary :
- Create docking container in the INITALIZATION event
- Create ALV on that Docking container
- After selecting all the data, export output table to ABAP memory
- Before generating the output, import the output table from the memroy

Code:

*&---------------------------------------------------------------------*
*& Generates the ALV on the Selection Screen itself
*&
*&---------------------------------------------------------------------*
REPORT  zalv_on_sel_screen.
*
*----------------------------------------------------------------------*
*  Local class for report
*----------------------------------------------------------------------*
CLASS lcl_report DEFINITION.
*
  PUBLIC SECTION.
*
    DATA: t_data   TYPE STANDARD TABLE OF sflight,  " Output dat
          r_carrid TYPE RANGE OF sflight-carrid.    " Select Option
*
    METHODS:
      get_data,
*
      generate_output.
*
ENDCLASS.                    "lcl_report DEFINITION
*
DATA: lo_report TYPE REF TO lcl_report.
*
DATA: w_carrid TYPE sflight-carrid.
*
** Selection Screen
SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE aaa.
SELECT-OPTIONS: s_carrid FOR w_carrid.
SELECTION-SCREEN: END   OF BLOCK blk1.
*
** Initialization
INITIALIZATION.
  aaa = 'Selection Criteria'.
* object for the report
  CREATE OBJECT lo_report.
* generate output
  lo_report->generate_output( ).
*
** Start of Selection
START-OF-SELECTION.
* Get data
  lo_report->r_carrid = s_carrid[].
  lo_report->get_data( ).
*
*----------------------------------------------------------------------*
* Local Class Implementation
*----------------------------------------------------------------------*
CLASS lcl_report IMPLEMENTATION.
*
  METHOD get_data.
*
*   data selection
    SELECT * FROM sflight
           INTO  TABLE me->t_data
           WHERE carrid IN s_carrid.
    IF sy-dbcnt IS INITIAL.
      MESSAGE s398(00) WITH 'No data selected'.
    ENDIF.
*
*   export to memory
    EXPORT data = me->t_data TO MEMORY ID sy-cprog.
*
  ENDMETHOD.                    "get_data
*
  METHOD generate_output.
*
*   local data
    DATA: lo_dock TYPE REF TO cl_gui_docking_container,
          lo_cont TYPE REF TO cl_gui_container,
          lo_alv  TYPE REF TO cl_salv_table.
*
*   import output table from the memory and free afterwards
    IMPORT data = me->t_data FROM MEMORY ID sy-cprog.
    FREE MEMORY ID sy-cprog.
*
*   Only if there is some data
    CHECK me->t_data IS NOT INITIAL.
*
*   Create a docking control at bottom
    CHECK lo_dock IS INITIAL.
    CREATE OBJECT lo_dock
      EXPORTING
        repid     = sy-cprog
        dynnr     = sy-dynnr
        ratio     = 80
        side      = cl_gui_docking_container=>dock_at_bottom
        name      = 'DOCK_CONT'.
    IF sy-subrc <> 0.
      MESSAGE 'Error in the Docking control' TYPE 'S'.
    ENDIF.
*
*   Create a SALV for output
    CHECK lo_alv IS INITIAL.
    TRY.
*       Narrow Casting: To initialize custom container from
*       docking container
        lo_cont ?= lo_dock.
*
*       SALV Table Display on the Docking container
        CALL METHOD cl_salv_table=>factory
          EXPORTING
            list_display   = if_salv_c_bool_sap=>false
            r_container    = lo_cont
            container_name = 'DOCK_CONT'
          IMPORTING
            r_salv_table   = lo_alv
          CHANGING
            t_table        = me->t_data.
      CATCH cx_salv_msg .
    ENDTRY.
*
*   Pf status
    DATA: lo_functions TYPE REF TO cl_salv_functions_list.
    lo_functions = lo_alv->get_functions( ).
    lo_functions->set_default( abap_true ).
*
*   output display
    lo_alv->display( ).
*
  ENDMETHOD.                    "generate_output
*
ENDCLASS.                    "lcl_report IMPLEMENTATION


Source: http: /help-abap.blogspot.com/2008/10/dispaly-alv-report-output-in-same.html
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.