Friday, November 23, 2007

ABAP Example Program ALV Grid Control

You need to create a screen 100 for calling it, and in the Element list of the sceen supply OK_CODE of type OK & in the layout, place a Custom - control with name DILEEP_TEST1.

Then activate modules STATUS_0100 and USER_COMMAND_0100 in the flow logic .

REPORT ZTEST_DIL4 .
TABLES ZMSTKSUM.
DATA : OK_CODE LIKE SY-UCOMM,
TAB_DISPLAY TYPE TABLE OF ZMSTKSUM,
C_CONTAINER TYPE SCRFNAME VALUE 'DILEEP_TEST1',
ALV_GRID TYPE REF TO CL_GUI_ALV_GRID,
C_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS : S_WERKS FOR ZMSTKSUM-WERKS.

SELECTION-SCREEN END OF BLOCK B1.

SELECT * FROM ZMSTKSUM INTO TABLE TAB_DISPLAY WHERE WERKS IN S_WERKS.


CALL SCREEN 100.
*&---------------------------------------------------------------------

*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------

* text
*----------------------------------------------------------------------

MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
* SET TITLEBAR 'xxx'.
IF C_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT C_CUSTOM_CONTAINER EXPORTING CONTAINER_NAME = C_CONTAINER
.
CREATE OBJECT ALV_GRID EXPORTING I_PARENT = C_CUSTOM_CONTAINER.

CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
I_STRUCTURE_NAME = 'ZMSTKSUM'
* IS_VARIANT =
* I_SAVE =
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
CHANGING
IT_OUTTAB = TAB_DISPLAY
* IT_FIELDCATALOG =
* IT_SORT =
* IT_FILTER =
* EXCEPTIONS
* INVALID_PARAMETER_COMBINATION = 1
* PROGRAM_ERROR = 2
* others = 3
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT

*&---------------------------------------------------------------------

*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------

* text
*----------------------------------------------------------------------

MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'EXIT'.
LEAVE PROGRAM.

ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT

No comments:

Blog Archive