2009 Mar 19 11:28 PM
Hi Guys
Does anyone have a report which can print directly to the printer when the radio button option is selected .
I want to print the ALV in excel format.
Printer >>>>.
Screeb >>>>>
Regards
P.Eslam
2009 Mar 20 4:09 AM
2009 Mar 20 3:47 AM
Hi,
Don't you want to consider the option of saving the ALV output into an excel sheet through report only, and then printing it from the file? A suggestion...
2009 Mar 20 4:00 AM
Hi Srinvas
No, The report is opening in ALV grid format but I want to print it directly to the printer without any popups or restriction, this will help our accounts because they have so many orders to print.
Regards
P.Eslam
2009 Mar 20 4:04 AM
Sinvas
However It should print like excel neatly but what is happening is it is printing in different fonts
Regards
P.Eslam
2009 Mar 20 4:09 AM
2009 Mar 20 4:12 AM
Hi,
Use FM
FTBU_START_EXCEL
MS_EXCEL_OLE_STANDARD_DAT
Use:
DATA: w_file TYPE rlgrap-filename VALUE 'it_value'.
CALL FUNCTION 'FTBU_START_EXCEL'
EXPORTING
data_name = w_file
data_path_flag = 'T'
*---Start Excel and not Wait
wait = ' '
TABLES
data_tab = <itab>
EXCEPTIONS
no_batch = 1
excel_not_installed = 2
wrong_version = 3
internal_error = 4
invalid_type = 5
cancelled = 6
download_error = 7
OTHERS = 8.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Hope this helps you.
2009 Mar 20 7:11 AM
Hi
I tried with this FM but giving short dump error can anyone explain why pls see the below program for testing.
REPORT Z_ESLP_ZTCODE .
"LINE-SIZE 600 .
TABLES : AGR_TCODES,
AGR_USERS,
TSTCT.
type-pools: slis. "ALV Declarations
CONSTANTS MARK VALUE 'X'.
*Data Declaration
LIFNR, NAME1, STRAS, ORT01, REGIO, PSTLZ, PFACH, LAND1
*----
TYPES: BEGIN OF T_DISP,
AGR_TCODES TYPE AGR_TCODES-TCODE , " Transaction code A
AGR_NAME TYPE AGR_TCODES-AGR_NAME, " Role Name B
AGR_UNAME TYPE AGR_USERS-UNAME, " Short User Name B
TTEXT TYPE TSTCT-TTEXT, " Description Name C
TEXTC TYPE USER_ADDR-NAME_TEXTC, " Long User Name
SPRSL TYPE TSTCT-SPRSL , " Language c
END OF t_disp.
DATA: it_disp TYPE STANDARD TABLE OF t_disp INITIAL SIZE 0,
wa_disp TYPE t_disp.
*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.
DATA:L_PARAMS TYPE PRI_PARAMS,
L_VALID TYPE C.
DATA: w_file TYPE rlgrap-filename VALUE 'it_value'.
SELECTION PARAMETER CRITERIA
SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME.
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: P_TCODE FOR AGR_TCODES-TCODE , "OBLIGATORY, "no-extension no intervals,
U_NAME FOR AGR_USERS-UNAME,
R_NAME FOR AGR_USERS-AGR_NAME .
SELECTION-SCREEN END OF BLOCK BLK1.
SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-002.
SELECTION-SCREEN END OF BLOCK BLK2.
SELECTION-SCREEN END OF BLOCK BLK.
SELECTION-SCREEN BEGIN OF BLOCK radio WITH FRAME.
PARAMETERS :scr RADIOBUTTON GROUP rbg1 ,
pr RADIOBUTTON GROUP rbg1 .
SELECTION-SCREEN END OF BLOCK radio.
************************************************************************
*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.
fieldcatalog-fieldname = 'AGR_UNAME'.
fieldcatalog-seltext_m = 'User'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'TEXTC'.
fieldcatalog-seltext_m = 'Name'.
fieldcatalog-outputlen = 50.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AGR_NAME'.
fieldcatalog-seltext_m = 'Role Name'.
fieldcatalog-outputlen = 15.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AGR_TCODES'.
fieldcatalog-seltext_m = 'Trans Code'.
fieldcatalog-col_pos = 3.
fieldcatalog-outputlen = 15.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'TTEXT'.
fieldcatalog-seltext_m = 'DESCRIPTION'.
fieldcatalog-outputlen = 40.
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).
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_disp
exceptions
program_error = 1
others = 2.
if sy-subrc EQ 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 lfa1 table and populate itab it_lfa1
----
form data_retrieval.
CASE MARK.
WHEN scr.
SELECT AGR_TCODESTCODE AGR_TCODESAGR_NAME AGR_USERSUNAME TSTCTTTEXT USER_ADDR~NAME_TEXTC
INTO TABLE IT_DISP
FROM AGR_TCODES
INNER JOIN AGR_USERS
ON AGR_TCODESAGR_NAME = AGR_USERSAGR_NAME
INNER JOIN USER_ADDR
ON AGR_USERSUNAME = USER_ADDRBNAME
INNER JOIN TSTCT
ON AGR_TCODESTCODE = TSTCTTCODE
where
agr_tcodes~tcode in p_tcode
and
agr_users~uname in u_name
and
agr_tcodes~agr_name in r_name
and
TSTCT~SPRSL EQ 'E'.
WHEN pr.
CALL FUNCTION 'FTBU_START_EXCEL'
EXPORTING
data_name = w_file
data_path_flag = 'T'
*---Start Excel and not Wait
wait = ' '
TABLES
data_tab = it_disp
EXCEPTIONS
no_batch = 1
excel_not_installed = 2
wrong_version = 3
internal_error = 4
invalid_type = 5
cancelled = 6
download_error = 7
OTHERS = 8.
NEW-PAGE PRINT ON PARAMETERS L_PARAMS NO DIALOG.
write : 'print'.
NEW-PAGE PRINT ON.
ENDCASE.
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 = 'Transaction codes by User and Role Name ' .
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_disp lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Transaction 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 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.
2010 Feb 05 3:32 AM