Powered By

Free XML Skins for Blogger

Powered by Blogger

Wednesday, October 1, 2008

ABAP ALV LIST DISPLAY SAMPLE CODE

TYPE-POOLS:SLIS.
TABLES:EKKO.
SELECT-OPTIONS:SO_EBELN FOR EKKO-EBELN.
DATA:BEGIN OF IT_EKKO OCCURS 0,
EBELN LIKE EKKO-EBELN, "PURCHASE DOCUMENT NUMBER
BUKRS LIKE EKKO-BUKRS, "COMPANY CODE
BSTYP LIKE EKKO-BSTYP, "PURCHASE DOCUMENT CATEGORY
BSART LIKE EKKO-BSART, "PUCHASE DOCUMENT TYPE
END OF IT_EKKO.
*FIELD CATALOG TABLE DECLARATION.
DATA:I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
* I_EVENTCAT TYPE SLIS_T_EVENT WITH HEADER LINE.

START-OF-SELECTION.
*INTERNAL TABLE POPULATION
SELECT EBELN
BUKRS
BSTYP
BSART
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN SO_EBELN.

*POPULATING FIELD CATALOG USING FIELDS IN FIELDCATALOG
*I_FIELDCAT-COL_POS = 1.
*I_FIELDCAT-FIELDNAME = 'EBELN'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'EBELN'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C510'.
**I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'PURCHAGE DOCUMENT NUMBER'.
*I_FIELDCAT-OUTPUTLEN = 20.
*I_FIELDCAT-HOTSPOT = 'X'.
*I_FIELDCAT-DO_SUM = 'X'.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*I_FIELDCAT-COL_POS = 2.
*I_FIELDCAT-FIELDNAME = 'BUKRS'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'BUKRS'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C610'.
*I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
*I_FIELDCAT-OUTPUTLEN = 10.
*I_FIELDCAT-HOTSPOT = ''.
*I_FIELDCAT-DO_SUM = SPACE.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*I_FIELDCAT-COL_POS = 3.
*I_FIELDCAT-FIELDNAME = 'BSTYP'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'BSTYP'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C510'.
**I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'DOCUMENT CATEGORY'.
*I_FIELDCAT-OUTPUTLEN = 10.
*I_FIELDCAT-HOTSPOT = 'X'.
*I_FIELDCAT-DO_SUM = SPACE.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*I_FIELDCAT-COL_POS = 4.
*I_FIELDCAT-FIELDNAME = 'BSART'.
*I_FIELDCAT-TABNAME = 'IT_EKKO'.
*I_FIELDCAT-REF_FIELDNAME = 'BSART'.
*I_FIELDCAT-REF_TABNAME = 'EKKO'.
*I_FIELDCAT-KEY = ''.
*I_FIELDCAT-EMPHASIZE = 'C510'.
**I_FIELDCAT-LOWERCASE = 'X'.
**I_FIELDCAT-SELTEXT_M = 'DOCUMENT TYPE'.
*I_FIELDCAT-OUTPUTLEN = 10.
*I_FIELDCAT-HOTSPOT = 'X'.
*I_FIELDCAT-DO_SUM = SPACE.
*APPEND I_FIELDCAT TO I_FIELDCAT.
*CLEAR I_FIELDCAT.
*
*
*
*POPULATING FIELD CATALOG BY USING FUNCTION MODULE
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-CPROG
I_INTERNAL_TABNAME = 'IT_EKKO'
I_INCLNAME = SY-CPROG
CHANGING
ct_fieldcat = I_FIELDCAT[].

*DISPLAYING REPORT AS ALV LIST
*CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
* EXPORTING
* I_CALLBACK_PROGRAM = SY-CPROG
* IT_FIELDCAT = I_FIELDCAT[]
* TABLES
* t_outtab = IT_EKKO.
**
*DISPLAYING REPORT AS ALV GRID
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-CPROG
IT_FIELDCAT = I_FIELDCAT[]
TABLES
t_outtab = IT_EKKO.

No comments:

Archives