cancel
Showing results for 
Search instead for 
Did you mean: 

Format the header of ALV

former_member220801
Participant
0 Kudos

I used the function 'REUSE_ALV_COMMENTARY_WRITE'. However, the header line always 'left-justified'.

Is it possible to format the header with diff. alignment?

I want to have the header 'centered'.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey ,

The header line is always left-justified .

We basically have three options for formatting :

S , A and H.

Regards,

Kunal.

Answers (2)

Answers (2)

Former Member
0 Kudos

hi Gundam,

every line in Alv top-of-page is of 60 char length(slis_listheader-info).so i think the only option we have is to add required spaces to the left and display the required string.

Former Member
0 Kudos

HI

GOOD

CHECK WITH THIS EXAMPLE AND USE IT ACCORDINGLY

REPORT Z_TEST_ALV_EVENTS .

type-pools: slis.

data: x_fieldcat type slis_fieldcat_Alv,

it_fieldcat type slis_t_fieldcat_alv,

x_events type slis_alv_event,

it_events type SLIS_T_EVENT.

data: v_lines type i.

data: begin of itab occurs 0,

vbeln like vbak-vbeln,

posnr like vbap-posnr,

end of itab.

select vbeln

posnr

from vbap

up to 100 rows

into table itab.

x_events-name = 'END_OF_LIST'.

x_events-form = 'END_OF_LIST'.

append x_events to it_events.

clear x_events.

x_events-name = 'TOP_OF_PAGE'.

x_events-form = 'TOP_OF_PAGE'.

append x_events to it_events.

clear x_events.

"if you use FM..

  • call function 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

  • IMPORTING

  • ET_EVENTS = IT_EVENTS

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 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.

*

  • read table it_events into x_events with key name = 'TOP_OF_PAGE'.

  • if sy-subrc = 0.

  • x_events-form = 'TOP_OF_PAGE'.

  • modify it_events from x_events index sy-tabix transporting form .

  • endif.

*

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = sy-repid

I_INTERNAL_TABNAME = 'ITAB'

I_INCLNAME = sy-repid

changing

ct_fieldcat = IT_FIELDCAT

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

if sy-subrc <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

describe table itab lines v_lines.

call function 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = sy-repid

I_CALLBACK_PF_STATUS_SET = 'STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

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.

DATA: LS_LINE TYPE SLIS_LISTHEADER,

E04_LT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

  • Listenüberschrift: Typ H

CLEAR LS_LINE.

LS_LINE-TYP = 'H'.

  • LS_LINE-KEY: not used for this type

LS_LINE-INFO = 'Summary'.

APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

  • Kopfinfo: Typ S

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Test'.

LS_LINE-INFO = ''.

APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

LS_LINE-KEY = 'ASIA'.

LS_LINE-INFO = 'test'.

APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

  • Aktionsinfo: Typ A

CLEAR LS_LINE.

LS_LINE-TYP = 'A'.

  • LS_LINE-KEY: not used for this type

LS_LINE-INFO = TEXT-105.

APPEND LS_LINE TO E04_LT_TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = E04_LT_TOP_OF_PAGE

I_LOGO = 'ENJOYSAP_LOGO'.

ENDFORM.

FORM END_OF_LIST.

write 😕 'No of Records ', v_lines.

ENDFORM.

THANKS

MRUTYUN

former_member220801
Participant
0 Kudos

Thanks for your reply.

In your program, the title in header section all starts from left to right. Is is possible to make it 'CENTERED'?

former_member188685
Active Contributor
0 Kudos

hi seed,

it is not possible. only left/right is possible.

regards

vijay

former_member220801
Participant
0 Kudos

oh...what's a pity

Is there any other methods to have a formated header?

I have search through the forum and found some postings of you, vijay. Instead of using 'REUSE_ALV_GRID_DISPLAY', you called another function to use ALV. However, when I copy and paste your code and execute it, there is a short dump stating that 'No such screen'.

I wonder using other methods to build ALV report that can have a much 'beautiful' and well formated ALV header section. Thanks!

former_member188685
Active Contributor
0 Kudos

Hi Gundam seed,

it gave Dump, since it requires a screen and that screen should have custom control. then only it will work. if you create the screen then it will work. even i feel the same when i looked at the comentry write FM , it doesn't allow the way we want. even if we concatenate some spaces it is not working. how ever i am also using the same alv comentry write FM , that also does the same.

Regards

vijay