Thursday, July 31, 2008

Simple ALV GRID (Full screen)

By Joyjit Ghosh,
Kolkata, India.

REPORT z_alv_object_1.

DATA: i_mara TYPE STANDARD TABLE OF mara.
DATA: dref TYPE REF TO cl_salv_table.


*&---------------------------------------------------------------------*
*& Start-of-selection event
*&---------------------------------------------------------------------*
START-OF-SELECTION.

* Fetch data from database
SELECT * FROM mara
INTO TABLE i_mara
UP TO 100 ROWS.

CHECK sy-subrc = 0.

* Get the ALV instance
TRY.
CALL METHOD cl_salv_table=>factory
* EXPORTING
* list_display = IF_SALV_C_BOOL_SAP=>TRUE
* r_container =
* container_name =
IMPORTING
r_salv_table = dref
CHANGING
t_table = i_mara
.
CATCH cx_salv_msg .
MESSAGE i000(z_zzz_ca_messages)
WITH 'Error in ALV processing'(001).

LEAVE LIST-PROCESSING.
ENDTRY.

IF dref IS BOUND.

* Display AlV report
CALL METHOD dref->display( ).

ENDIF.

1 comment:

Kallol Bhowmick said...

This is one goody goody example .... I was not aware of this class until I saw ur example...

-- Kallol