‎2007 May 30 8:25 AM
Hi Expert ,
I want Comapny name and Date interval (in selection screen ) in ALV header,
pls give me some code or program .
thanks and regards
abaper
‎2007 May 30 4:23 PM
Hi,
Check this sample code.
REPORT ZALV_DEMO.
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.
tables:vbap.
select-options:s_vbeln for vbap-vbeln.
data:v_l(15) type c,
v_h(15) type c.
SELECT vbeln
posnr
FROM vbap
INTO TABLE itab where vbeln in s_vbeln.
v_l = s_vbeln-low.
v_h = s_vbeln-high.
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.
write: v_l, 'to', v_h.
WRITE: / sy-vline,
(8) 'VBELN'(013) ,
sy-vline,
(8) 'POSNR'(014) ,
sy-vline.
FORMAT COLOR OFF.
ENDFORM. "top_of_page
‎2007 May 31 5:57 AM
hi,
check the sample code.
**Global ALV Data Declarations
type-pools slis.
data: begin of i_alv occurs 0,
matnr type mara-matnr,
end of i_alv.
Miscellanous Data Declarations
data: fieldcat type slis_t_fieldcat_alv,
events type slis_t_event,
list_top_of_page type slis_t_listheader,
top_of_page type slis_formname value 'TOP_OF_PAGE'.
start-of-selection.
perform initialization.
perform get_data.
perform call_alv.
end-of-selection.
***********************************************************************
Form Initialization
***********************************************************************
form initialization.
clear i_alv. refresh i_alv.
perform eventtab_build using events[].
endform.
***********************************************************************
Form Get_Data
***********************************************************************
form get_data.
select matnr into table i_alv
from mara up to 100 rows.
endform.
***********************************************************************
CALL_ALV
***********************************************************************
form call_alv.
data: variant type disvariant.
data: repid type sy-repid.
repid = sy-repid.
variant-report = sy-repid.
variant-username = sy-uname.
perform build_field_catalog.
perform comment_build using list_top_of_page[].
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
i_callback_program = repid
is_variant = variant
it_events = events[]
i_save = 'U'
tables
t_outtab = i_alv.
endform.
***********************************************************************
EVENTTAB_BUILD
***********************************************************************
form eventtab_build using events type slis_t_event.
Registration of events to happen during list display
data: tmp_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = events.
read table events with key name = slis_ev_top_of_page
into tmp_event.
if sy-subrc = 0.
move top_of_page to tmp_event-form.
append tmp_event to events.
endif.
endform.
***********************************************************************
BUILD_FIELD_CATALOG
***********************************************************************
form build_field_catalog.
clear: fieldcat. refresh: fieldcat.
data: tmp_fc type slis_fieldcat_alv.
tmp_fc-reptext_ddic = 'Material'.
tmp_fc-fieldname = 'MATNR'.
tmp_fc-tabname = 'I_ALV'.
tmp_fc-outputlen = 18.
append tmp_fc to fieldcat.
endform.
***********************************************************************
COMMENT_BUILD
***********************************************************************
form comment_build using list_top_of_page type
slis_t_listheader.
data: tmp_line type slis_listheader.
clear tmp_line.
tmp_line-typ = 'H'.
tmp_line-info = 'Here is a line of text'.
append tmp_line to list_top_of_page.
clear tmp_line.
tmp_line-typ = 'S'.
tmp_line-key = 'Key1'.
tmp_line-info = 'Here is a value'.
append tmp_line to list_top_of_page.
clear tmp_line.
tmp_line-typ = 'A'.
tmp_line-key = 'Key2'.
tmp_line-info = 'Here is another value'.
append tmp_line to list_top_of_page.
endform.
***********************************************************************
TOP_OF_PAGE
***********************************************************************
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = list_top_of_page.
endform.
‎2007 May 31 6:24 AM
Hi,
Do like this
data :EVENTS TYPE SLIS_T_EVENT.
PERFORM create_event USING EVENTS[].
g_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = g_repid
i_callback_pf_status_set = 'SET_PF_STATUS'
is_layout = ls_layout
it_fieldcat = it_fieldcat_lst1[]
* it_sort = it_sort_lst
IT_EVENTS = events[]
tables
t_outtab = it_lst1
exceptions
program_error = 1
others = 2.
FORM create_event USING P_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 = P_EVENTS.
READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO P_EVENTS.
ENDIF.
endform. " create_event
*************************
FORM TOP_OF_PAGE.
clear l_string.
l_string = 'MMS Test Report'
.
wa_header-typ = 'H'.
wa_header-info = l_string.
append wa_header to heading." index 1.
data:text(150),
text1(20),
text2(20),
text3(20),
text4(20),
text5(20),
text6(40),
text7(40).
if not so_budat is initial.
text1 = 'Posting Date:'.
text2 = 'from'.
text3 = so_budat-low.
text4 = 'To'.
text5 = so_budat-high.
if not so_budat-high is initial.
*CONCATENATE text1 text2 text3 text4 text5 INTO text SEPARATED BY space
*.
CONCATENATE text1 text3 space text4 space text4
INTO text SEPARATED BY space
.
else.
CONCATENATE text1 text3 INTO text SEPARATED BY space.
endif.
wa_header-typ = 'S'.
wa_header-info = text.
APPEND wa_header TO heading.
CLEAR: text1,text2,text3,text4,text5.
endif.
*
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'MYSAPCOM'
IT_LIST_COMMENTARY = HEADING.
clear heading.
clear l_string.
endform.
Reward Points if it is Useful.
Thanks,
Manjunath MS