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: 

alv grid

Former Member
0 Kudos

hi ,

i want to display 'enjoysap_logo ' on the top of my display.. but tat thing is not coming .. please help me

REPORT YASEC_ALV_TEST.

tables : mara .

type-pools: SLIS.

&----


*& Include YASEC_ALV_TEST_TOP

&----


types : begin of st_mara ,

matnr like mara-matnr ,

mtart like mara-mtart ,

matkl like mara-matkl ,

pstat like mara-pstat ,

NTGEW LIKE MARA-NTGEW ,

end of st_mara .

data : it_tab type standard table of st_mara ,

it_tab1 type SLIS_T_FIELDCAT_ALV,

wa_tab type st_mara,

wa_tab1 like line of it_tab1,

grid1 TYPE REF TO cl_gui_alv_grid.

data : is_varient TYPE disvariant.

DATA: gt_events type slis_t_event,

it_list_top_of_page TYPE slis_t_listheader,

wa_list_top_of_page LIKE LINE OF it_list_top_of_page,

wa_events LIKE LINE OF gt_events,

gd_prntparams type slis_print_alv.

initialization .

wa_tab1-fieldname = 'MATNR'.

wa_tab1-tabname = 'MARA'.

  • WA_TAB1-ref_fieldname ='MATNR'.

WA_TAB1-ref_tabname = 'MARA'.

*WA_TAB1-SELTEXT_L = 'MATERIAL'.

APPEND WA_TAB1 TO IT_TAB1.

wa_tab1-fieldname = 'MTART'.

wa_tab1-tabname = 'MARA'.

*WA_TAB1-SELTEXT_L = 'MTART'.

APPEND WA_TAB1 TO IT_TAB1.

wa_tab1-fieldname = 'MATKL'.

wa_tab1-tabname = 'MARA'.

*WA_TAB1-SELTEXT_L = 'MATKL'.

APPEND WA_TAB1 TO IT_TAB1.

wa_tab1-fieldname = 'PSTAT'.

wa_tab1-tabname = 'MARA'.

*WA_TAB1-SELTEXT_L = 'PSTAT'.

APPEND WA_TAB1 TO IT_TAB1.

wa_tab1-fieldname = 'NTGEW'.

wa_tab1-tabname = 'MARA'.

*WA_TAB1-SELTEXT_L = 'NTGEW'.

APPEND WA_TAB1 TO IT_TAB1.

start-of-selection.

select matnr mtart matkl pstat NTGEW

from mara into table it_tab up to 10 rows .

perform f_is_varient.

PERFORM f_it_list_top_of_page .

PERFORM TOP_OF_PAGE.

perform build_events.

perform build_print_params.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = 'END_OF_LIST'

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = it_tab1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

I_SAVE = 'X'

IS_VARIANT = is_varient

IT_EVENTS = gt_events

  • IT_EVENT_EXIT = gt_events

IS_PRINT = gd_prntparams

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 10

  • I_SCREEN_START_LINE = 10

  • I_SCREEN_END_COLUMN = 60

  • I_SCREEN_END_LINE = 30

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = it_tab

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 BUILD_EVENTS

&----


  • Build events table

----


form build_events.

data: ls_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = gt_events[].

read table gt_events with key name = slis_ev_top_of_page

into ls_event.

if sy-subrc = 0.

move 'TOP_OF_PAGE' to ls_event-form.

append ls_event to gt_events.

endif.

read table gt_events with key name = slis_ev_end_of_list

into ls_event.

if sy-subrc = 0.

move 'END_OF_LIST' to ls_event-form.

append ls_event to gt_events.

endif.

endform. " BUILD_EVENTS

&----


*& Form BUILD_PRINT_PARAMS

&----


  • Setup print parameters

----


form build_print_params.

gd_prntparams-reserve_lines = '3'. "Lines reserved for footer

gd_prntparams-no_coverpage = 'X'.

endform. " BUILD_PRINT_PARAMS

&----


*& Form END_OF_PAGE

&----


form TOP_OF_PAGE.

  • data: listwidth type i,

  • ld_pagepos(10) type c,

  • ld_page(10) type c.

  • write: sy-uline(50).

  • skip.

  • write:/40 'Page:', sy-pagno .

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_list_top_of_page

i_logo = 'ENJOYSAP_LOGO'.

endform.

&----


*& Form END_OF_LIST

&----


form END_OF_LIST.

data: listwidth type i,

ld_pagepos(10) type c,

ld_page(10) type c.

skip.

write:/40 'Page:', sy-pagno .

write 😕 'this is the end of list'.

  • CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

  • EXPORTING

    • it_list_commentary = it_list_top_of_page

  • i_logo = 'ENJOYSAP_LOGO' .

endform.

form f_is_varient.

is_varient-report = 'varient'.

is_varient-username = 'nikesh'.

is_varient-text = 'anytext'.

endform.

FORM f_it_list_top_of_page .

wa_list_top_of_page-typ = 'H'.

wa_list_top_of_page-info = 'PROGRAM ON ALV'.

APPEND wa_list_top_of_page TO it_list_top_of_page.

ENDFORM.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Nikesh,

Have a look at this sample code.

&----


*& Report ZFM_ALV_LOGO

*&

&----


*&

*&

&----


REPORT ZFM_ALV_LOGO.

DATA ITAB LIKE TABLE OF mara.

TYPE-POOLS SLIS.

***********DECLARATIONS********************************

DATA LIST_TOP TYPE SLIS_T_LISTHEADER.

DATA LIST_LINE TYPE SLIS_LISTHEADER.

DATA EVENTS TYPE SLIS_T_EVENT.

DATA FORMNAME_E_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.

DATA PTESTRUN(1).

DATA REPNAME LIKE SY-REPID.

CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

DATA LAYOUT TYPE SLIS_LAYOUT_ALV.

*************INITIALIZATION**************************

INITIALIZATION.

REPNAME = SY-REPID.

PERFORM BUILD_EVENTTAB USING EVENTS[].

CLEAR LIST_LINE.

LIST_LINE-TYP = 'H'.

LIST_LINE-INFO = SY-TITLE.

APPEND LIST_LINE TO LIST_TOP.

CLEAR LIST_LINE.

LIST_LINE-TYP = 'S'.

LIST_LINE-KEY = 'PROGRAM NAME'.

LIST_LINE-INFO = SY-REPID.

APPEND LIST_LINE TO LIST_TOP.

CLEAR LIST_LINE.

LIST_LINE-TYP = 'S'.

LIST_LINE-KEY = 'USER'.

LIST_LINE-INFO = SY-UNAME.

APPEND LIST_LINE TO LIST_TOP.

CLEAR LIST_LINE.

LIST_LINE-TYP = 'S'.

LIST_LINE-KEY = 'DATE'.

LIST_LINE-INFO = SY-DATUM.

APPEND LIST_LINE TO LIST_TOP.

CLEAR LIST_LINE.

LIST_LINE-TYP = 'S'.

LIST_LINE-KEY = 'TIME'.

LIST_LINE-INFO = sy-uzeit.

APPEND LIST_LINE TO LIST_TOP.

*******************************************************

SELECT * FROM mara INTO TABLE ITAB.

*******************************************************

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = REPNAME

I_STRUCTURE_NAME = 'mara'

IT_EVENTS = EVENTS[]

TABLES

T_OUTTAB = ITAB.

*****FORM FOR TOP OF PAGE******************

FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

I_LOGO = 'ENJOYSAP_LOGO'

IT_LIST_COMMENTARY = LIST_TOP.

ENDFORM.

*****************************************************

****************FORM EVENT***********************

FORM BUILD_EVENTTAB USING P1_EVENTS TYPE SLIS_T_EVENT.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = P1_EVENTS.

READ TABLE P1_EVENTS WITH KEY NAME = FORMNAME_TOP_OF_PAGE

INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO P1_EVENTS.

ENDIF.

ENDFORM.

*****************************************************

Reward if Useful.

Regards,

Chitra

5 REPLIES 5

Former Member
0 Kudos

Hi Nikesh,

Have a look at this sample code.

&----


*& Report ZFM_ALV_LOGO

*&

&----


*&

*&

&----


REPORT ZFM_ALV_LOGO.

DATA ITAB LIKE TABLE OF mara.

TYPE-POOLS SLIS.

***********DECLARATIONS********************************

DATA LIST_TOP TYPE SLIS_T_LISTHEADER.

DATA LIST_LINE TYPE SLIS_LISTHEADER.

DATA EVENTS TYPE SLIS_T_EVENT.

DATA FORMNAME_E_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND'.

DATA PTESTRUN(1).

DATA REPNAME LIKE SY-REPID.

CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

DATA LAYOUT TYPE SLIS_LAYOUT_ALV.

*************INITIALIZATION**************************

INITIALIZATION.

REPNAME = SY-REPID.

PERFORM BUILD_EVENTTAB USING EVENTS[].

CLEAR LIST_LINE.

LIST_LINE-TYP = 'H'.

LIST_LINE-INFO = SY-TITLE.

APPEND LIST_LINE TO LIST_TOP.

CLEAR LIST_LINE.

LIST_LINE-TYP = 'S'.

LIST_LINE-KEY = 'PROGRAM NAME'.

LIST_LINE-INFO = SY-REPID.

APPEND LIST_LINE TO LIST_TOP.

CLEAR LIST_LINE.

LIST_LINE-TYP = 'S'.

LIST_LINE-KEY = 'USER'.

LIST_LINE-INFO = SY-UNAME.

APPEND LIST_LINE TO LIST_TOP.

CLEAR LIST_LINE.

LIST_LINE-TYP = 'S'.

LIST_LINE-KEY = 'DATE'.

LIST_LINE-INFO = SY-DATUM.

APPEND LIST_LINE TO LIST_TOP.

CLEAR LIST_LINE.

LIST_LINE-TYP = 'S'.

LIST_LINE-KEY = 'TIME'.

LIST_LINE-INFO = sy-uzeit.

APPEND LIST_LINE TO LIST_TOP.

*******************************************************

SELECT * FROM mara INTO TABLE ITAB.

*******************************************************

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = REPNAME

I_STRUCTURE_NAME = 'mara'

IT_EVENTS = EVENTS[]

TABLES

T_OUTTAB = ITAB.

*****FORM FOR TOP OF PAGE******************

FORM TOP_OF_PAGE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

I_LOGO = 'ENJOYSAP_LOGO'

IT_LIST_COMMENTARY = LIST_TOP.

ENDFORM.

*****************************************************

****************FORM EVENT***********************

FORM BUILD_EVENTTAB USING P1_EVENTS TYPE SLIS_T_EVENT.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = P1_EVENTS.

READ TABLE P1_EVENTS WITH KEY NAME = FORMNAME_TOP_OF_PAGE

INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

APPEND LS_EVENT TO P1_EVENTS.

ENDIF.

ENDFORM.

*****************************************************

Reward if Useful.

Regards,

Chitra

former_member404244
Active Contributor
0 Kudos

Hi,

check the below code

REPORT zdemo_alvgrid .

TABLES: ekko.

type-pools: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

statu TYPE ekpo-statu,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

meins TYPE ekpo-meins,

netpr TYPE ekpo-netpr,

peinh TYPE ekpo-peinh,

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko.

*ALV data declarations

data: fieldcatalog type slis_t_fieldcat_alv with header line,

gd_tab_group type slis_t_sp_group_alv,

gd_layout type slis_layout_alv,

gd_repid like sy-repid,

gt_events type slis_t_event,

gd_prntparams type slis_print_alv.

************************************************************************

*Start-of-selection.

START-OF-SELECTION.

perform data_retrieval.

perform build_fieldcatalog.

perform build_layout.

perform build_events.

perform build_print_params.

perform display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


form build_fieldcatalog.

  • There are a number of ways to create a fieldcat.

  • For the purpose of this example i will build the fieldcatalog manualy

  • by populating the internal table fields individually and then

  • appending the rows. This method can be the most time consuming but can

  • also allow you more control of the final product.

  • Beware though, you need to ensure that all fields required are

  • populated. When using some of functionality available via ALV, such as

  • total. You may need to provide more information than if you were

  • simply displaying the result

  • I.e. Field type may be required in-order for

  • the 'TOTAL' function to work.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order'.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO Item'.

fieldcatalog-col_pos = 1.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'Status'.

fieldcatalog-col_pos = 2.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'Item change date'.

fieldcatalog-col_pos = 3.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material Number'.

fieldcatalog-col_pos = 4.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'PO quantity'.

fieldcatalog-col_pos = 5.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Order Unit'.

fieldcatalog-col_pos = 6.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-do_sum = 'X'.

fieldcatalog-datatype = 'CURR'.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.

fieldcatalog-seltext_m = 'Price Unit'.

fieldcatalog-col_pos = 8.

append fieldcatalog to fieldcatalog.

clear fieldcatalog.

endform. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


form build_layout.

gd_layout-no_input = 'X'.

gd_layout-colwidth_optimize = 'X'.

gd_layout-totals_text = 'Totals'(201).

  • gd_layout-totals_only = 'X'.

  • gd_layout-f2code = 'DISP'. "Sets fcode for when double

  • "click(press f2)

  • gd_layout-zebra = 'X'.

  • gd_layout-group_change_edit = 'X'.

  • gd_layout-header_text = 'helllllo'.

endform. " BUILD_LAYOUT

&----


*& Form DISPLAY_ALV_REPORT

&----


  • Display report using ALV grid

----


form display_alv_report.

gd_repid = sy-repid.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

i_callback_user_command = 'USER_COMMAND'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

  • it_special_groups = gd_tabgroup

it_events = gt_events

is_print = gd_prntparams

i_save = 'X'

  • is_variant = z_template

tables

t_outtab = it_ekko

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.

endform. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


form data_retrieval.

select ebeln ebelp statu aedat matnr menge meins netpr peinh

up to 10 rows

from ekpo

into table it_ekko.

endform. " DATA_RETRIEVAL

----


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

----


  • FORM USER_COMMAND *

----


  • --> R_UCOMM *

  • --> RS_SELFIELD *

----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

  • Check function code

CASE r_ucomm.

WHEN '&IC1'.

  • Check field clicked on within ALVgrid report

IF rs_selfield-fieldname = 'EBELN'.

  • Read data table, using index of row user clicked on

READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.

  • Set parameter ID for transaction screen field

SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.

  • Sxecute transaction ME23N, and skip initial data entry screen

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDFORM.

&----


*& Form BUILD_EVENTS

&----


  • Build events table

----


form build_events.

data: ls_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = gt_events[].

read table gt_events with key name = slis_ev_end_of_page

into ls_event.

if sy-subrc = 0.

move 'END_OF_PAGE' to ls_event-form.

append ls_event to gt_events.

endif.

read table gt_events with key name = slis_ev_end_of_list

into ls_event.

if sy-subrc = 0.

move 'END_OF_LIST' to ls_event-form.

append ls_event to gt_events.

endif.

endform. " BUILD_EVENTS

&----


*& Form BUILD_PRINT_PARAMS

&----


  • Setup print parameters

----


form build_print_params.

gd_prntparams-reserve_lines = '3'. "Lines reserved for footer

gd_prntparams-no_coverpage = 'X'.

endform. " BUILD_PRINT_PARAMS

&----


*& Form END_OF_PAGE

&----


form END_OF_PAGE.

data: listwidth type i,

ld_pagepos(10) type c,

ld_page(10) type c.

write: sy-uline(50).

skip.

write:/40 'Page:', sy-pagno .

endform.

&----


*& Form END_OF_LIST

&----


form END_OF_LIST.

data: listwidth type i,

ld_pagepos(10) type c,

ld_page(10) type c.

skip.

write:/40 'Page:', sy-pagno .

endform.

reward if helpful.

Regards,

Nagaraj

Former Member
0 Kudos

hi nikesh check this code

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 = 'A'.

wa_header-info = 'Purchase Requistion Report'.

APPEND wa_header TO t_header.

CLEAR wa_header.

  • Date

wa_header-typ = 'A'.

wa_header-info = '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 itab1 LINES ld_lines.

ld_linesc = ld_lines.

CONCATENATE 'Total No. of Records : ' ld_linesc

INTO t_line SEPARATED BY space.

*T_LINE = 'Requisation Report,'.

wa_header-typ = 'A'.

wa_header-info = t_line.

APPEND wa_header TO t_header.

CLEAR: wa_header, t_line.

t_line ='Its my Report:'.

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 = 'HCL_LOGO'.

Former Member
0 Kudos

hi

good

go through this code hope this ll help you to display the logo in your alv output.

Look at the sample code to display LOGO.

**********************

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = i_repid

  • i_callback_user_command = 'USER_COMMAND_PERNR'

it_fieldcat = header

is_layout = gt_layout

i_callback_top_of_page = 'TOP-OF-PAGE1'

i_grid_title = xyz

it_sort = gt_sort[]

i_default = 'X'

i_save = 'U'

is_variant = gt_variant

it_events = gt_events

tables

t_outtab = t_output.

clear t_output.

*****************

----


  • Form TOP-OF-PAGE1

----


form top-of-page1.

data: header type slis_t_listheader,

wa type slis_listheader. "infield like wa-info, nline type n.

  • TITLE AREA

wa-typ = 'S'.

wa-info = text-h04.

append wa to header.

wa-typ = 'S'.

write sy-datum to wa-info mm/dd/yyyy.

concatenate text-h03 wa-info into wa-info separated by space.

append wa to header.

wa-typ = 'S'.

concatenate text-h02 sy-uname into wa-info separated by space.

append wa to header.

wa-typ = 'S'.

concatenate text-h01 sy-repid into wa-info separated by space.

append wa to header.

********" LOGO

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = header

i_logo = 'ENJOYSAP_LOGO'.

*********" LOGO

endform.

Here in TOP-OF-PAGE form it will show you the Prog name,Date, User Name.

Just you need to give the text in it.

You can refer the below link also.

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

reward point if helpful.

thanks

mrutyun^

Former Member
0 Kudos

Hi

use in this way

  • Your own company logo can go here if it has been saved (OAOR)

  • If the logo is larger than the size of the headings in gt_page,

  • the window will not show full logo and will have a scroll bar. Thus,

  • it is a good idea to have a standard ALV header if you are going to

  • use logos in your top of page.

&----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_page

i_logo = 'ENJOYSAP_LOGO'.

ENDFORM. "top_of_page

i wil send u my program by seaing that you can find it

&----


*& Report ZTEST_ALV_LOGO

*&

&----


*&

*&

&----


REPORT ztest_alv_logo.

TYPE-POOLS : slis.

*ALV Formatting tables /structures

DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.

DATA: gt_events TYPE slis_t_event.

DATA: gs_layout TYPE slis_layout_alv.

DATA: gt_page TYPE slis_t_listheader.

DATA: gs_page TYPE slis_listheader.

DATA: v_repid LIKE sy-repid.

*ALV Formatting work area

DATA: w_fieldcat TYPE slis_fieldcat_alv.

DATA: w_events TYPE slis_alv_event.

DATA: gt_bsid TYPE TABLE OF bsid WITH HEADER LINE.

INITIALIZATION.

PERFORM build_events.

PERFORM build_page_header.

START-OF-SELECTION.

*perform build_comment. "top_of_page - in initialization at present

SELECT * FROM bsid INTO TABLE gt_bsid UP TO 10 ROWS.

*perform populate_for_fm using '1' '3' 'BUKRS' '8' 'GT_BSID' 'Whee'.

*USING = Row, Column, Field name, display length, table name, heading

*OR

PERFORM build_fieldcat.

gs_layout-zebra = 'X'.

*top of page event does not work without I_callback_program

v_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

i_structure_name = 'BSID'

  • i_background_id = 'ALV_BACKGROUND'

i_grid_title = 'This is the grid title'

  • I_GRID_SETTINGS =

is_layout = gs_layout

it_fieldcat = gt_fieldcat[]

it_events = gt_events[]

TABLES

t_outtab = gt_bsid.

************************************************************************

  • Form..............: populate_for_fm

  • Description.......: Populates fields for function module used in ALV

************************************************************************

FORM populate_for_fm USING p_row

p_col

p_fieldname

p_len

p_table

p_desc.

w_fieldcat-row_pos = p_row. "Row Position

w_fieldcat-col_pos = p_col. "Column Position

w_fieldcat-fieldname = p_fieldname. "Field name

w_fieldcat-outputlen = p_len. "Column Lenth

w_fieldcat-tabname = p_table. "Table name

w_fieldcat-reptext_ddic = p_desc. "Field Description

w_fieldcat-input = '1'.

APPEND w_fieldcat TO gt_fieldcat.

CLEAR w_fieldcat.

ENDFORM. " populate_for_fm

&----


*& Form build_events

&----


FORM build_events.

DATA: ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = gt_events.

READ TABLE gt_events

WITH KEY name = slis_ev_user_command

INTO ls_event.

IF sy-subrc = 0.

MOVE slis_ev_user_command TO ls_event-form.

APPEND ls_event TO gt_events.

ENDIF.

READ TABLE gt_events

WITH KEY name = slis_ev_top_of_page

INTO ls_event.

IF sy-subrc = 0.

MOVE slis_ev_top_of_page TO ls_event-form.

APPEND ls_event TO gt_events.

ENDIF.

ENDFORM. " build_events

&----


*& Form USER_COMMAND

&----


  • When user command is called it uses 2 parameters. The itab

  • passed to the ALV is in whatever order it currently is on screen.

  • Therefore, you can read table itab index rs_selfield-tabindex to get

  • all data from the table. You can also check r_ucomm and code

  • accordingly.

&----


FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

READ TABLE gt_bsid INDEX rs_selfield-tabindex.

  • error checking etc.

SET PARAMETER ID 'KUN' FIELD gt_bsid-kunnr.

CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.

ENDFORM. "user_command

&----


*& Form top_of_page

&----


  • Your own company logo can go here if it has been saved (OAOR)

  • If the logo is larger than the size of the headings in gt_page,

  • the window will not show full logo and will have a scroll bar. Thus,

  • it is a good idea to have a standard ALV header if you are going to

  • use logos in your top of page.

&----


FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_page

i_logo = 'ENJOYSAP_LOGO'.

ENDFORM. "top_of_page

&----


*& Form build_fieldcat

&----


*Many and varied fields are available here. Have a look at documentation

*for FM REUSE_ALV_LIST_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE

----


FORM build_fieldcat.

w_fieldcat-fieldname = 'BUDAT'.

w_fieldcat-seltext_m = 'Dte pst'.

w_fieldcat-ddictxt(1) = 'M'.

  • Can change the position of fields if you do not want them in order

  • of the DDIC or itab

  • w_fieldcat-row_pos = '1'.

  • w_fieldcat-col_pos = '10'.

APPEND w_fieldcat TO gt_fieldcat.

CLEAR w_fieldcat.

ENDFORM. " build_fieldcat

&----


*& Form build_page_header

&----


  • gt_page is used in top of page (ALV subroutine - NOT event)

  • *H = Header, S = Selection, A = Action

----


FORM build_page_header.

  • For Headers, Key is not printed and is irrelevant. Will not cause

  • a syntax error, but is not used.

gs_page-typ = 'H'.

gs_page-info = 'Header 1'.

APPEND gs_page TO gt_page.

gs_page-typ = 'H'.

gs_page-info = 'Header 2'.

APPEND gs_page TO gt_page.

  • For Selections, the Key is printed (bold). It can be anything up to 20

  • bytes. It gets printed in order of code here, not by key value.

gs_page-typ = 'S'.

gs_page-key = 'And the winner is:'.

gs_page-info = 'Selection 1'.

APPEND gs_page TO gt_page.

gs_page-typ = 'S'.

gs_page-key = 'Runner up:'.

gs_page-info = 'Selection 2'.

APPEND gs_page TO gt_page.

  • For Action, Key is also irrelevant.

gs_page-typ = 'A'.

gs_page-info = 'Action goes here'.

APPEND gs_page TO gt_page.

ENDFORM. " build_page_header

REWARD IF USEFULL