12-05-2006 3:48 AM
Dear all:
could anyony provide some advice on how to realize this kind of ALV?
-
|--
field2 |
-
|--
field11 | field12 | field21 | field212 |
-
|--
wait your kindly advice
12-05-2006 4:14 AM
I had similar kind of requirement. Have a look at below code. It will help you. You can execute it. You can see the report output which contains two header lines.
REPORT ztestvib MESSAGE-ID zz LINE-SIZE 50.
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 <> 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
&----
text
----
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. "top_of_page
The header lines are as below:
SEX
VBELN POSNR MALE FMALE
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers
12-05-2006 3:51 AM
You can look at hierarchy list. See the program BALVHT01.
Regards,
Ravi
Note - Please mark all the helpful answers
12-05-2006 3:59 AM
12-05-2006 4:02 AM
Hi,
Please have a look at these standard programs
BCALV_TEST_HIERSEQ_LIST
BCALV_TEST_HIERSEQ_LIST_EVENTS
Regards,
Raghavendra
12-05-2006 4:09 AM
Dears:
what i need to express is like this:
-
people |
-
man | woman |
-
i use this kind of ALV to do statistics
12-05-2006 4:10 AM
12-05-2006 4:14 AM
I had similar kind of requirement. Have a look at below code. It will help you. You can execute it. You can see the report output which contains two header lines.
REPORT ztestvib MESSAGE-ID zz LINE-SIZE 50.
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 <> 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
&----
text
----
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. "top_of_page
The header lines are as below:
SEX
VBELN POSNR MALE FMALE
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers