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: 

How to realize this kind of ALV(with two headerlines)?

Former Member
0 Kudos

Dear all:

could anyony provide some advice on how to realize this kind of ALV?

-


|--


|--


field2

-


|--


|
|

|
--


field11 | field12 | field21 | field212 |

-


|--


|
|

|
--


wait your kindly advice

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

6 REPLIES 6

Former Member
0 Kudos

You can look at hierarchy list. See the program BALVHT01.

Regards,

Ravi

Note - Please mark all the helpful answers

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

As suggested,you should go for hierarchy.Check this.

http://www.geocities.com/mpioud/Abap_programs.html

Former Member
0 Kudos

Hi,

Please have a look at these standard programs

BCALV_TEST_HIERSEQ_LIST

BCALV_TEST_HIERSEQ_LIST_EVENTS

Regards,

Raghavendra

0 Kudos

Dears:

what i need to express is like this:

-


people

-


man

woman

-


i use this kind of ALV to do statistics

0 Kudos

people

-


man <b>|</b> woman

-


Former Member
0 Kudos

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