04-21-2006 8:06 AM
HI Group,
when I am creating ALV templet for the reports I created header and footers.In both I created some information like
in Header:
Report
date
time
these information I need in the same line ,when I am using concatenate statement separated by space it is not leaving the space in between the space I need to keep 2 tab spaces in between each field,I also used CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,but it is also not working.In the footer also I need to create user name on left hand edge and page number on the right hand edge .Please suggest
I am using this code
TABLES: MARAV.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_marav,
matnr like marav-matnr,
maktx like marav-maktx,
matkl like marav-matkl,
ntgew like marav-ntgew,
gewei like marav-gewei,
END OF t_marav.
DATA: it_marav TYPE STANDARD TABLE OF t_marav INITIAL SIZE 0,
wa_marav TYPE t_marav.
DATA: gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
data: v_spaces(10) value ' '.
*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.
************************************************************************
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
perform build_events.
perform build_print_params.
&----
*& Form BUILD_FIELDCATALOG
&----
Build Fieldcatalog for ALV Report
----
form build_fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material number'.
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 = 'MAKTX'.
fieldcatalog-seltext_m = 'Material Des'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATKL'.
fieldcatalog-seltext_m = 'Material group '.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NTGEW'.
fieldcatalog-seltext_m = 'Net weight'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'GEWEI'.
fieldcatalog-seltext_m = 'weight unit '.
fieldcatalog-col_pos = 4.
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.
data: GT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT LIKE LINE OF GT_EVENTS .
CLEAR: WA_EVENT.
WA_EVENT-NAME = 'END_OF_PAGE'.
WA_EVENT-FORM = 'FOOTER' .
APPEND WA_EVENT TO GT_EVENTS.
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_html_end_of_list = 'END_OF_LIST_HTML'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
is_variant = z_template
tables
t_outtab = it_marav
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 matnr maktx matkl ntgew gewei
up to 10 rows
from marav
into table it_marav.
endform. " DATA_RETRIEVAL
&----
*& Form top-of-page
&----
text
----
Form top-of-page.
DATA SEPARATOR(10) VALUE space.
*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,
v_date(20) type c.
Title
wa_header-typ = 'H'.
wa_header-info = 'Southern Water'.
append wa_header to t_header.
clear wa_header.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO v_date.
Title
wa_header-typ = 'S'.
wa_header-key = 'Report '.
Concatenate sy-repid 'Date : '
v_date into wa_header-info
SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
wa_header-info = sy-repid.
append wa_header to t_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'Report Des '.
wa_header-info = 'ABAP Report templet'.
append wa_header to t_header.
clear wa_header.
*
*
wa_header-typ = 'S'.
wa_header-key = 'SYS ID : '.
wa_header-info = sy-sysid.
append wa_header to t_header.
clear wa_header.
*
wa_header-typ = 'S'.
wa_header-key = 'Client '.
wa_header-info = sy-mandt.
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.
wa_header-typ = 'S'.
wa_header-key = 'Run Time '.
CONCATENATE sy-uzeit(2) '.'
sy-uzeit+4(2) '.'
sy-uzeit+2(2) INTO wa_header-info.
append wa_header to t_header.
clear wa_header.
wa_header-typ = 'S'.
wa_header-key = 'User ID '.
wa_header-info = sy-uname.
append wa_header to t_header.
clear wa_header.
*
Total No. of Records Selected
describe table it_marav 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 = 'logo.gif'.
*
endform. "top-of-page
FORM end_of_list_html USING end TYPE REF TO cl_dd_document.
DATA: ls_text TYPE sdydo_text_element,
l_grid TYPE REF TO cl_gui_alv_grid,
f(14) TYPE c VALUE 'SET_ROW_HEIGHT'.
data: v_footer type sdydo_text_element.
data: v_pagno type n.
v_pagno = sy-pagno.
adds test (via variable)
CALL METHOD end->add_text
EXPORTING
text = ls_text
sap_emphasis = 'strong'.
concatenate sy-uname 'Report' v_pagno into v_footer SEPARATED BY v_spaces. "c_tab.
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
condense v_footer.
CALL METHOD end->add_text
EXPORTING
text = v_footer.
ENDFORM. "end_of_list_html.
04-21-2006 8:14 AM
try like below
DATA SEPARATOR VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
CONCATENATE SPACE ONE TWO THREE INTO NAME
SEPARATED BY SEPARATOR.
04-21-2006 8:18 AM
Hi Hymavati,
I tried this its not working.
even concatenate separated by space also not working.
Also I would like to know how to write text in the
middle.
04-21-2006 8:25 AM
u can handle top_of_page and end_of_list with simple write statements instead of fn module reuse_alv_commentary_write.
for that u need to pass print_params.
fill the reserve_lines parameter of variable print_params of type slis_print_alv and pass this variable print_params to is_print in the reuse_alv_list_display.
note: if u r using reuse_alv_grid_display, then u can see top of page and end of list contents only in print preview.
04-21-2006 8:31 AM
Hi Hymavati,
Can you please give me little bit clear.where do I need to pass this parameters in my code.
04-21-2006 8:38 AM
LS_PRINT TYPE sls_print_alv,
LS_PRINT-RESERVE_LINES = 3.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = ' '
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT =
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
<b> IS_PRINT = LS_PRINT</b>
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB =
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.
PASS VALUE TO IS_PRINT AS ABOVE ALONG WITH THE OTHER VALUES U SENT
NOW IN TOP_OF_PAGE FORM, U CAN SIMPLY USE WRITE STATEMENTS.
Message was edited by: Hymavathi Oruganti
04-21-2006 9:25 AM
Hi ,
When I am trying this occuring the error as
' sls_print_alv' is unknown.
04-21-2006 9:36 AM
Hi Group,
Can any body help me how to add logo and footers for this code.
REPORT ZTEMPLET .
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,
gd_layout type slis_layout_alv.
data: v_lines type i.
data : BEGIN OF it_marav occurs 100,
matnr like marav-matnr,
maktx like marav-maktx,
matkl like marav-matkl,
ntgew like marav-ntgew,
gewei like marav-gewei,
END OF it_marav.
select matnr maktx matkl ntgew gewei
up to 10 rows
from marav
into table it_marav.
x_events-name = 'TOP_OF_PAGE'.
x_events-form = 'TOP_OF_PAGE'.
append x_events to it_events.
clear x_events.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'IT_MARAV'
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 it_marav lines v_lines.
call function 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
is_layout = gd_layout
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENTS
TABLES
t_outtab = IT_MARAV[]
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.
WRITE:/ 'Report', 30 SY-REPID, 40 SY-DATUM.
04-21-2006 10:08 AM
hi it is
<b>SLIS_PRINT_ALV</b> not 'sls' SLIS is the type pool.
to print logo, u need to use reuse_alv_commentary_write,
i_logo.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = heading.
note: 'ENJOYSAP_LOGO ' SHOULD EXIST IN APP SERVER, OR ELSE USING TCODE 'OAER' U NEDD TO UPLOAD. FOR THAT PROCEDURE, THERE ARE MANY POSTS IN THE FORUM, PLS SEARCH.
FOOTER CAN BE PRINTED BY HANDLING EVENT AND 'END_OF_LIST'
AND WITH WRITE STATEMENTS AS I MENTIONED IN PREVIOUS POST