************************************************************************
* Copyright 2013, ABAP Thinkers
* All Rights Reserved
************************************************************************
* Program ID     : ZLEVI
* Program Name   : ALV Report using ALV_GRID_DISPLAY
* Create Date    : 11.14.2013
* Created by     : ABAP Thinkers
* Request No.    : local
* Description    : This program creates an ALV report using the FM
*                  ALV_GRID_DISPLAY
************************************************************************

REPORT  zlevi.
************************************************************************
********************START OF DATA DECLARATIONS**************************
************************************************************************
*----------------------------------------------------------------------*
*TYPE-POOLS                                                            *
*----------------------------------------------------------------------*
TYPE-POOLS: abap,slis.

*----------------------------------------------------------------------*
* TABLES                                                               *
*----------------------------------------------------------------------*
TABLES:sflight.

*----------------------------------------------------------------------*
* TYPES                                                                *
*----------------------------------------------------------------------*
TYPES: BEGIN OF ty_sflight.
INCLUDE STRUCTURE sflight.
TYPES:    add1,
carrname LIKE scarr-carrname,
box,
lights.
TYPES: END OF ty_sflight.

*----------------------------------------------------------------------*
*INTERNAL TABLES                                                       *
*----------------------------------------------------------------------*
DATA:
gi_sflight               TYPE STANDARD TABLE OF ty_sflight,
gi_fieldcatalog          TYPE slis_t_fieldcat_alv."

*----------------------------------------------------------------------*
*WORK AREAS                                                            *
*----------------------------------------------------------------------*
DATA:
gwa_sflight              TYPE ty_sflight,
gwa_layout               TYPE slis_layout_alv,
gwa_fieldcatalog         TYPE slis_fieldcat_alv.

************************************************************************
**********************END OF DATA  DECLARATIONS*************************
************************************************************************

**----------------------------------------------------------------------*
**INITIALIZATION                                                        *
**----------------------------------------------------------------------*
INITIALIZATION.
PERFORM f_initialize.

*----------------------------------------------------------------------*
*SELECTION SCREENS                                                     *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-001.
SELECT-OPTIONS carrid FOR sflight-carrid.
SELECT-OPTIONS connid FOR sflight-connid.
SELECT-OPTIONS fldate FOR sflight-fldate.
PARAMETERS: p_maxrow TYPE i DEFAULT 30.
SELECTION-SCREEN END OF BLOCK b01.

*----------------------------------------------------------------------*
*START OF SELECTION                                                    *
*----------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM f_selection.
PERFORM f_display_alv_report.

*&---------------------------------------------------------------------*
*&      Form  f_selection
*&---------------------------------------------------------------------*
*       Select Statement
*----------------------------------------------------------------------*
FORM f_selection.

SELECT * INTO CORRESPONDING FIELDS OF TABLE gi_sflight FROM
  ( sflight LEFT JOIN scarr
ON sflight~carrid = scarr~carrid )
UP TO p_maxrow ROWS
WHERE sflight~carrid IN carrid
  AND   sflight~connid IN connid
  AND   sflight~fldate IN fldate.
IF sy-subrc = 0.
"do nothing
ENDIF.

ENDFORM.                    "SELECTION

*&--------------------------------------------------------------*
*&      Form  f_create_layout
*&--------------------------------------------------------------*
*       Create Layout of the ALV Grid
*---------------------------------------------------------------*
FORM f_create_layout USING p_gd_layout TYPE slis_layout_alv.

p_gd_layout-zebra             = abap_true.
p_gd_layout-colwidth_optimize = abap_true.

ENDFORM. " f_create_layout

*&--------------------------------------------------------------*
*&      Form  pf_status
*&--------------------------------------------------------------*
*       Set the PF Status of the ALV Grid
*---------------------------------------------------------------*
FORM pf_status USING rt_extab TYPE slis_t_extab.."    "#EC CALLED
SET PF-STATUS  'STANDARD_FULLSCREEN'  OF PROGRAM 'SAPLKKBL'.
ENDFORM.                    "pfstatus

*&--------------------------------------------------------------*
*&      Form  f_display_alv_report
*&--------------------------------------------------------------*
*       Display ALV Report
*---------------------------------------------------------------*
FORM f_display_alv_report.

PERFORM f_create_layout USING gwa_layout.
PERFORM f_build_fieldcatalog.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program       = sy-repid
i_callback_pf_status_set = 'PF_STATUS'
is_layout                = gwa_layout
it_fieldcat              = gi_fieldcatalog[]
TABLES
t_outtab                 = gi_sflight[]
EXCEPTIONS
program_error            = 1
OTHERS                   = 2.
IF sy-subrc = 0.                                          "#EC NEEDED
"do nothing
ENDIF.

ENDFORM.                    " F_DISPLAY_ALV_REPORT

*&--------------------------------------------------------------*
*&      Form  f_build_fieldcatalog
*&--------------------------------------------------------------*
*       Generate the Field Catalogs of the ALV Grid
*----------------------------------------------------------------*
FORM f_build_fieldcatalog.

REFRESH: gi_fieldcatalog.
CLEAR: gwa_fieldcatalog.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name         = sy-cprog
i_structure_name       = 'SFLIGHT'
CHANGING
ct_fieldcat            = gi_fieldcatalog
EXCEPTIONS
inconsistent_interface = 1
program_error          = 2
OTHERS                 = 3.
IF sy-subrc = 0.
"do nothing
ENDIF.

ENDFORM.                    "f_build_fieldcatalog

*&---------------------------------------------------------------------*
*&      Form  F_INITIALIZE
*&---------------------------------------------------------------------*
*       Initialize variables
*----------------------------------------------------------------------*
FORM f_initialize .

REFRESH:
gi_sflight,
gi_fieldcatalog.

CLEAR:
gwa_sflight,
gwa_layout,
gwa_fieldcatalog.
ENDFORM.                    " F_INITIALIZE

You may also like:
Disclaimer
My First Blog Post…
Archives for June 2014
Archives for June 2014
Archives for June 2014
Archives for June 2014
Archives for June 2014
Archives for June 2014
[ what's this ]
Tagged with: ABAP Code • ALV FM REUSE_ALV_GRID_DISPLAY • ALV Grid • ALV Report

How to implement a Lock object in ABAP? How to modify Standard PF-Status of ALV Grid?

You must log in to post a comment.

    Subscribe to Blog via Email

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 59 other subscribers

    Email Address

Tags
&SE16N ABAP Code ABAP Query ABAP Tip ABAP Tips ABAP Tricks ALV FM REUSE_ALV_GRID_DISPLAY ALV Grid ALV OOP ALV Report Beginners Tutorial Context Menu Data Dictionary Debugger Debugging Debugging Tips Delete Implicit Enhancement Dequeue Dialog Programming Download Download Tables Structures Enhancement Enqueue Function Group Function Module Function Modules Hilite.me Hotspot How To Implicit Enhancement Intermediate Tutorial Link Click Lock Objects Number Range PDF PF Status popup screen Query SAP Query SAP_EDIT SNRO Syntax Highlighter Transport Variants UserGroup Variants
Categories

    ABAP Code
    ABAP Query
    ABAP Tips
    ALV
    ALV Grid
    ALV OOP
    Basis
    Beginners
    Class
    Data Dictionary
    Debugging
    Dialog Programing
    Enhancement
    Forms
    Function Modules
    How To
    Implicit Enhancement
    Intermediate
    Lock Object
    Maintenance Generator
    Performance
    Roles and Authorizations
    Sapscripts
    Selection Screen
    Smartforms
    Table
    Version Management

Recent Posts

    How to upload SAP Roles to update User’s authorizations?
    Can I recover my deleted ABAP programs?
    How to execute SQL Statement without changing ABAP Code?
    How to escape ABAP line in Debug Mode?
    Dumps in Range – The Solution

Recent Comments

    levi aliangan on How to implement a Lock object in ABAP?
    soonlhs on How to implement a Lock object in ABAP?
    soonlhs on How to implement a Lock object in ABAP?
    salilbagchi on How to implement a Lock object in ABAP?
    levi aliangan on How to implement a Lock object in ABAP?

Connect@Facebook
Meta

    Register
    Log in
    Entries RSS
    Comments RSS
    WordPress.org