Welcome To My BLOG

This site is to give a brief idea for the abap learners who are looking for some real time programs .It consists of collection of programs from my side . I hope these programs are very much used for all of the learners. Please check the links for any information in ABAP.
Please vote for my Blog. And please input me on this mail addrssess.Email me

Share this link with your friends

http://www.rebtel.com/u/15163104576

For every friend who signs up using this link and makes a payment, we'll give you 8 €!


Thursday, September 23, 2010

Alv with header in bold

REPORT zkat.

TYPE-POOLS: SLIS.

TABLES: MARA.

DATA: BEGIN OF IT_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
END OF IT_MARA.

DATA: IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELD_CAT TYPE SLIS_FIELDCAT_ALV,
IT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENTS TYPE SLIS_ALV_EVENT,
IT_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER.

SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.

START-OF-SELECTION.

PERFORM GET_DATA.

PERFORM BUILD_FIELD_CAT.

PERFORM GET_EVENTS.

PERFORM DISPLAY_DATA.

*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_DATA .

SELECT MATNR
MTART
MATKL
FROM MARA
INTO TABLE IT_MARA
WHERE MATNR IN S_MATNR.

ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form build_field_cat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM BUILD_FIELD_CAT .

CLEAR WA_FIELD_CAT.

WA_FIELD_CAT-COL_POS = 1.
WA_FIELD_CAT-FIELDNAME = 'MATNR'.
WA_FIELD_CAT-SELTEXT_L = 'Material Number'.
APPEND WA_FIELD_CAT TO IT_FIELD_CAT.

WA_FIELD_CAT-COL_POS = 2.
WA_FIELD_CAT-FIELDNAME = 'MTART'.
WA_FIELD_CAT-SELTEXT_L = 'Material Type'.
APPEND WA_FIELD_CAT TO IT_FIELD_CAT.

WA_FIELD_CAT-COL_POS = 3.
WA_FIELD_CAT-FIELDNAME = 'MATKL'.
WA_FIELD_CAT-SELTEXT_L = 'Material Group'.
APPEND WA_FIELD_CAT TO IT_FIELD_CAT.

ENDFORM. " build_field_cat

*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = IT_FIELD_CAT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = IT_MARA.

ENDFORM. " display_data

*&---------------------------------------------------------------------*
*& Form get_events
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM GET_EVENTS .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
IMPORTING
ET_EVENTS = IT_EVENTS .

READ TABLE IT_EVENTS INTO WA_EVENTS
WITH KEY NAME = SLIS_EV_TOP_OF_PAGE.
IF SY-SUBRC = 0.
WA_EVENTS-FORM = 'TOP_OF_PAGE'.
MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
ENDIF.

ENDFORM. " get_events

*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM TOP_OF_PAGE.

WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'Material Data'.
APPEND WA_HEADER TO IT_HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_HEADER.

ENDFORM. "top_of_page

No comments: