Application Development and Automation 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: 
Read only

Problem relating to ALV

Former Member
0 Likes
937

HI,

I have 2 doubts.

1. Is it possible to have the Header in ALV Grid Display in two lines.

2. Is it possible to combine two cells in the header of the ALV Grid Display.

A Sample output that I need is:

-


Co. Cd

Age (20 to 30)

Age (30 to 40)

Age (40 to 50)

-


|______| Male | Female | Male | Female | Male | Female |

-


1000

10

8

5

1

2

0

2000

20

7

4

0

1

0

-


If you look at the Heading: 'Age (20 to 30)' is spread over the 2nd and the 3rd column. Similarly 'Age (30 to 40)' ...

How do we do this?

Next, How do we have multiple Rows on the Heading.

Any help will be greatly appreciated.

Thanks and Regards,

Ishaq.

1 ACCEPTED SOLUTION
Read only

anversha_s
Active Contributor
0 Likes
910

hi,

just exceute this report and check

report  ztest_alv_check     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 .
 
<b>  l_layout-no_colhead = 'X'.</b>
 
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.
 
*-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.

Regards

Anver

HI,

I have 2 doubts.

1. Is it possible to have the Header in ALV Grid Display in two lines.

2. Is it possible to combine two cells in the header of the ALV Grid Display.

A Sample output that I need is:

-


Co. Cd

Age (20 to 30)

Age (30 to 40)

Age (40 to 50)

-


|______| Male | Female | Male | Female | Male | Female |

-


1000

10

8

5

1

2

0

2000

20

7

4

0

1

0

-


If you look at the Heading: 'Age (20 to 30)' is spread over the 2nd and the 3rd column. Similarly 'Age (30 to 40)' ...

How do we do this?

Next, How do we have multiple Rows on the Heading.

Any help will be greatly appreciated.

Thanks and Regards,

Ishaq.

9 REPLIES 9
Read only

Former Member
0 Likes
910

Hi Ishaq,

Try using the field catalog property 'CELL_MERGE', for the cells.

Read only

0 Likes
910

Hi,

As far as I know, it is not possible to have 2 heading lines in ALV.

Thanks,

Rashmi.

Read only

0 Likes
910

HI Naveen,

Please let me know how do we use the field catalog property 'CELL_MERGE'

Thanks,

Ishaq.

Read only

Former Member
0 Likes
910

Yes we can do that... With the help of the function module REUSE_ALV_COMMENTARY_WRITE

i hope it works for u...

try this ..

U can use this in Top of page onli..

IN this u need to fill the table it_listheading..

it has components typ (type of the title) ,INfo ( text ), Key...

  • Populating the list complementary table...

fs_list-typ = 'H'.

fs_list-info = 'Flight details'.

append fs_list to t_list_complementary.

fs_list-typ = 'S'.

fs_list-info = 'connections'.

append fs_list to t_list_complementary.

form top_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = t_list_complementary

I_LOGO = 'ENJOYSAP_LOGO'

.

endform.

reward if it helps u...

sai ramesh

Read only

Former Member
0 Likes
910

Hi,

Yes it is possible.

Have a look

FORM Z_LISTHEADER USING P_I_LISTHEADER TYPE SLIS_T_LISTHEADER.

DATA: L_LISTHEADER TYPE SLIS_LISTHEADER.

REFRESH P_I_LISTHEADER.

CLEAR L_LISTHEADER.

L_LISTHEADER-TYP = 'H'.

L_LISTHEADER-INFO = TEXT-001.

APPEND L_LISTHEADER TO P_I_LISTHEADER.

CLEAR L_LISTHEADER.

L_LISTHEADER-TYP = 'H'.

L_LISTHEADER-INFO = TEXT-002.

APPEND L_LISTHEADER TO P_I_LISTHEADER.

text-001 will have the 1st line and text002 will have the second line.

Read only

0 Likes
910

> Hi,

>

> Yes it is possible.

> Have a look

>

> FORM Z_LISTHEADER USING P_I_LISTHEADER TYPE

> SLIS_T_LISTHEADER.

> DATA: L_LISTHEADER TYPE SLIS_LISTHEADER.

>

> REFRESH P_I_LISTHEADER.

> CLEAR L_LISTHEADER.

> L_LISTHEADER-TYP = 'H'.

> L_LISTHEADER-INFO = TEXT-001.

> APPEND L_LISTHEADER TO P_I_LISTHEADER.

>

> CLEAR L_LISTHEADER.

> L_LISTHEADER-TYP = 'H'.

> L_LISTHEADER-INFO = TEXT-002.

> APPEND L_LISTHEADER TO P_I_LISTHEADER.

> text-001 will have the 1st line and text002 will have

> the second line.

Please pass this list header to FM reuse alv commentary write.

Read only

0 Likes
910

Hi,

Please explain what do u want.

I am not getting you.

Regards

shreya

Read only

anversha_s
Active Contributor
0 Likes
911

hi,

just exceute this report and check

report  ztest_alv_check     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 .
 
<b>  l_layout-no_colhead = 'X'.</b>
 
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.
 
*-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.

Regards

Anver

Read only

0 Likes
910

Hi,

Can you please let me know how do we do the same for GRID Display.

Ishaq.