Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Two column header in ALV Report

Former Member
0 Kudos

Hi Experts,

Can I have 2 headers in ALV report kind of one header and one sub header below that.

like i have to display a report having the same information for 3 systems so in header I can have the system name and below that

usual headers.

Thanks

Yogesh Gupta

7 REPLIES 7

Former Member
0 Kudos

Use this function module to write commentary as header. You are free to write text in it.

REUSE_ALV_COMMENTARY_WRITE

Amandeep

former_member188685
Active Contributor
0 Kudos

it is is not possible using the ALV GRID function, ALV OO.

it is possible with ALV List function. you might loose some functionalities layout etc.

check this sample..

cehck this image..

http://img100.imageshack.us/img100/3846/output6ef.th.gif

REPORT ZTEST_ALV message-id zz .
 
TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
L_LAYOUT type slis_layout_alv,
x_events type slis_alv_event,
it_events type SLIS_T_EVENT.
 
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
MALE type i,
female type i,
END OF ITAB.
 
SELECT VBELN
POSNR
FROM VBAP
UP TO 20 ROWS
INTO TABLE ITAB.
 
 
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 1.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
 
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'MALE'.
X_FIELDCAT-SELTEXT_L = 'MALE'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 3.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'FEMALE'.
X_FIELDCAT-SELTEXT_L = 'FEMALE'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 3.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
x_events-NAME = SLIS_EV_TOP_OF_PAGE.
x_events-FORM = 'TOP_OF_PAGE'.
APPEND x_events TO iT_EVENTS.
CLEAR x_events .
 
L_LAYOUT-NO_COLHEAD = 'X'.
 
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = L_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_events = it_events
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC ne  0.
 
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
 
FORM TOP_OF_PAGE.
 
*-To display the headers for main list
FORMAT COLOR COL_HEADING.
WRITE: / SY-ULINE(103).
WRITE: / SY-VLINE,
(8) ' ' ,
SY-VLINE,
(8) ' ' ,
SY-VLINE,
(19) 'SEX'(015) centered,
sy-vline.
 
WRITE: / SY-VLINE,
(8) 'VBELN'(013) ,
SY-VLINE,
(8) 'POSNR'(014) ,
SY-VLINE,
(8) 'MALE'(016) ,
sy-vline,
(8) 'FMALE'(017) ,
sy-vline.
 
FORMAT COLOR OFF.
 
ENDFORM.

0 Kudos

Hello Yogesh,

You can use either of the method specified the first one will show a header in the ALV which is not close to the grid. This method can be used to show the current system date, system name etc which is not relevant to any column in the grid.

If say you have a column Name and below that you want first name and second name columns then you can go for the second option.

Regards

Farzan

0 Kudos

Hi Vijay,

Could you please tell me if there is any way using OOPS concept.

Regards,

Vinit

Former Member

Former Member
0 Kudos

answered

0 Kudos

Please help me to solve , I have the same problem to define two column under one header in alv report