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

alv grid display

Former Member
0 Likes
979

hi,

can anyone help me in alv, my requirement is this i have to create top-of-page event in grid display , i have to give so many details like sy-uname, creation date, company name----- how to do that please send me a code ,

thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
957

chk my blog

/people/community.user/blog/2007/05/07/alignment-of-data-in-top-of-page-in-alv-grid

hi,

can anyone help me in alv, my requirement is this i have to create top-of-page event in grid display , i have to give so many details like sy-uname, creation date, company name----- how to do that please send me a code ,

thanks in advance

7 REPLIES 7
Read only

Former Member
0 Likes
958

chk my blog

/people/community.user/blog/2007/05/07/alignment-of-data-in-top-of-page-in-alv-grid

Read only

0 Likes
957
See the smaple code

call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.






*-------------------------------------------------------------------*
* Form TOP-OF-PAGE *
*-------------------------------------------------------------------*
* ALV Report Header *
*-------------------------------------------------------------------*
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.

* Title
wa_header-typ = 'H'.
wa_header-info = 'EKKO Table Report'.
append wa_header to t_header.
clear wa_header.

* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.

* Total No. of Records Selected
describe table it_ekko lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.

call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
endform.

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_rephead.htm

Read only

0 Likes
957

hi

I am giving you the sample code for event like top-of-page.

data:it_event type slis_t_event. " table for field catalog event control "

data: wa_event type slis_alv_event. " work area "

form man_event.

data: g_top_of_page type slis_forname value 'top_of_page',

g_repid type sy-repid.

"event top_of_page defined

wa_event-name = slis_ev_top_of_page.

wa_event_form = g_top_of_page.

" appending the events into the event internal table.

append wa_event to it_event.

endform. " man_event.

form top_of_page.

data: wa_listheader type slis_listheader,

it_top_of_page type slis_t_listheader.

wa_listheader-typ = ' H '.

wa_listheader-info = text-011. " header of report

append wa_listheader to it_top_of_page.

wa_listheader-typ = ' S '.

wa_listheader-info = sy-repid.

wa_listheader-key = ' PROGRAM NAME:'.

append wa_listheader to it_top_of_page.

wa_listheader-typ = ' S '.

wa_listheader-info = sy-uname.

wa_listheader-key = ' USER NAME:'.

append wa_listheader to it_top_of_page.

wa_listheader-typ = ' S '.

wa_listheader-info = sy-datum.

wa_listheader-key = ' DATE:'.

append wa_listheader to it_top_of_page.

wa_listheader-typ = ' S '.

wa_listheader-info = sy-uzeit.

wa_listheader-key = ' TIME:'.

append wa_listheader to it_top_of_page.

*FUNCTION CALLED FOR TOP_OF_PAGE EVENT FOR DISPLAYING THE TEXT ON THE TOP OF REPORT.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_top_of_page.

  • I_LOGO =

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

endform. " top_of_page

reward points if helpful

thanks

Read only

Former Member
0 Likes
957

Hi Abhishek,

Go thru these links..take u thru sample code and basics on ALV.

http://www.erpgenie.com/abap/controls/alvgrid.htm

http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm

Hope it helps.

Read only

Former Member
0 Likes
957

Use FM REUSE_ALV_COMMENTARY_WRITE. Fill internal table for 'it_list_commentary'.

See demo program BALVST02_GRID for using it.

Cheers,

Lata

Read only

Former Member
0 Likes
957

Hi,

here a short extract:

DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

...

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = PROGNAME

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE_GRID'

IS_VARIANT = VARIANT

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FIELDCAT

IT_SORT = SORT

IT_FILTER = FILTER

I_SAVE = 'A'

IT_EVENTS = EVENTS

IT_EVENT_EXIT = EVENT_EXIT

IS_PRINT = PRINT

TABLES

T_OUTTAB = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

...

FORM TOP_OF_PAGE_GRID.

*

DATA: LS_LINE TYPE SLIS_LISTHEADER.

*

REFRESH GT_LIST_TOP_OF_PAGE.

*

LS_LINE-TYP = 'H'.

LS_LINE-INFO = SY-TITLE.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Datum'.

WRITE SY-DATUM TO LS_LINE-INFO DD/MM/YYYY.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Report'.

WRITE SY-REPID TO LS_LINE-INFO.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

LS_LINE-KEY = 'Benutzer'.

WRITE SY-UNAME TO LS_LINE-INFO.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CLEAR LS_LINE.

LS_LINE-TYP = 'S'.

APPEND LS_LINE TO GT_LIST_TOP_OF_PAGE.

*

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

  • I_LOGO = 'ENJOYSAP_LOGO'

IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.

*

ENDFORM.

Regards, Dieter

Read only

Former Member
0 Likes
957

HI ,

THIS MIGHT HELP YOU OUT

&----


*& Report YMP_ALV_GRID *

*& *

&----


*& *

*& *

&----


REPORT YMP_ALV_GRID .

--


TABLE DECLARATION--

TABLES VBAK.

TYPE-POOLS : SLIS.

--


SELECT OPTIONS--

SELECT-OPTIONS S_VBELN FOR VBAK-VBELN.

--


DATA DECLARATION--

TYPES : BEGIN OF TY_VBAK,

VBELN TYPE VBELN_VA,

ERDAT TYPE ERDAT,

ERZET TYPE ERZET,

ERNAM TYPE ERNAM,

ANY(4),

END OF TY_VBAK.

TYPES : TT_VBAK TYPE STANDARD TABLE OF TY_VBAK.

DATA : IT_VBAK TYPE TT_VBAK WITH HEADER LINE,

FCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

LAYOUT TYPE SLIS_LAYOUT_ALV,

EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE.

--


START OF SELECTION--

START-OF-SELECTION.

SELECT VBELN

ERDAT

ERZET

ERNAM

FROM VBAK

INTO TABLE IT_VBAK

WHERE VBELN IN S_VBELN.

--


FIELD CAT--

FCAT-COL_POS = '1'.

FCAT-FIELDNAME = 'VBELN'.

FCAT-TABNAME = 'ITAB'.

FCAT-SELTEXT_L = 'ORDER NUMBER'.

FCAT-OUTPUTLEN = '30'.

APPEND FCAT.

CLEAR FCAT.

FCAT-COL_POS = '2'.

FCAT-FIELDNAME = 'ERDAT'.

FCAT-TABNAME = 'ITAB'.

FCAT-SELTEXT_L = 'DATE OF CREATION'.

FCAT-OUTPUTLEN = '30'.

APPEND FCAT.

CLEAR FCAT.

FCAT-COL_POS = '3'.

FCAT-FIELDNAME = 'ERZET'.

FCAT-TABNAME = 'ITAB'.

FCAT-SELTEXT_L = 'TIME OF ENTRY'.

FCAT-OUTPUTLEN = '30'.

APPEND FCAT.

CLEAR FCAT.

FCAT-COL_POS = '4'.

FCAT-FIELDNAME = 'ERNAM'.

FCAT-TABNAME = 'ITAB'.

FCAT-SELTEXT_L = 'NAME OF THE PERSON'.

FCAT-OUTPUTLEN = '30'.

APPEND FCAT.

CLEAR FCAT.

--


LAYOUT--

LAYOUT-INFO_FIELDNAME = 'ANY'.

LOOP AT IT_VBAK.

IF IT_VBAK-VBELN <= 0000303500.

IT_VBAK-ANY = 'C211'.

MODIFY IT_VBAK INDEX SY-INDEX.

ELSEIF IT_VBAK-VBELN >= 0000400242

AND IT_VBAK-VBELN <= 0000404500.

IT_VBAK-ANY = 'C411'.

MODIFY IT_VBAK INDEX SY-INDEX.

ENDIF.

ENDLOOP.

--


EVENT--

EVENTS-FORM = 'ANY1'.

EVENTS-NAME = 'TOP-OF-PAGE'.

APPEND EVENTS.

CLEAR EVENTS.

--


DISPLAY--

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-CPROG

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = EVENTS[]

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = IT_VBAK

  • 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 ANY1.

DATA HEADER TYPE SLIS_T_LISTHEADER WITH HEADER LINE.

HEADER-TYP = 'H'.

HEADER-INFO = 'SALES DOCUMENT DETAILS'.

APPEND HEADER.

CLEAR HEADER.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = HEADER[]

I_LOGO = 'SAPENJOY-LOGO'

  • I_END_OF_LIST_GRID =

.

ENDFORM.