This report takes another report as input, and captures the output of that report. The output is then converted to PDF and saved to a local file. This shows how to use some of the PDF function modules, as well as an easy way to create PDF files. Source Code Listing report zabap_2_pdf. *-- Enhancements: only allow to be run with variant. Then called *-- program will be transparent to users *-- TABLES tables: tsp01. *-- STRUCTURES data: mstr_print_parms like pri_params, mc_valid(1) type c, mi_bytecount type i, mi_length type i, mi_rqident like tsp01-rqident. *-- INTERNAL TABLES data: mtab_pdf like tline occurs 0 with header line, mc_filename like rlgrap-filename. *-- SELECTION SCREEN parameters: p_repid like sy-repid, " Report to execute p_linsz like sy-linsz default 132, " Line size p_paart like sy-paart default 'X_65_132'. " Paper Format start-of-selection. concatenate 'c:\' p_repid '.pdf' into mc_filename. *-- Setup the Print Parmaters call function 'GET_PRINT_PARAMETERS' exporting authority= space copies = '1' cover_page = space data_set = space department = space destination = space expiration = '1' immediately = space in_archive_parameters = space in_parameters = space layout = space mode = space new_list_id = 'X' no_dialog= 'X' user = sy-uname importing out_parameters = mstr_print_parms valid = mc_valid exceptions archive_info_not_found = 1 invalid_print_params = 2 invalid_archive_params = 3 others = 4. *-- Make sure that a printer destination has been set up *-- If this is not done the PDF function module ABENDS if mstr_print_parms-pdest = space. mstr_print_parms-pdest = 'LOCL'. endif. *-- Explicitly set line width, and output format so that *-- the PDF conversion comes out OK mstr_print_parms-linsz = p_linsz. mstr_print_parms-paart = p_paart. submit (p_repid) to sap-spool without spool dynpro spool parameters mstr_print_parms via selection-screen and return. *-- Find out what the spool number is that was just created perform get_spool_number using sy-repid sy-uname changing mi_rqident. *-- Convert Spool to PDF call function 'CONVERT_ABAPSPOOLJOB_2_PDF' exporting src_spoolid= mi_rqident no_dialog = space dst_device = mstr_print_parms-pdest importing pdf_bytecount = mi_bytecount tables pdf = mtab_pdf exceptions err_no_abap_spooljob = 1 err_no_spooljob = 2 err_no_permission = 3 err_conv_not_possible = 4 err_bad_destdevice = 5 user_cancelled = 6 err_spoolerror = 7 err_temseerror = 8 err_btcjob_open_failed = 9 err_btcjob_submit_failed = 10 err_btcjob_close_failed = 11 others = 12. call function 'DOWNLOAD' exporting bin_filesize = mi_bytecount filename = mc_filename filetype = 'BIN' importing act_filename = mc_filename tables data_tab = mtab_pdf. *---------------------------------------------------------------------* * FORM get_spool_number * *---------------------------------------------------------------------* * Get the most recent spool created by user/report * *---------------------------------------------------------------------* * --> F_REPID * * --> F_UNAME * * --> F_RQIDENT * *---------------------------------------------------------------------* form get_spool_number using f_repid f_uname changing f_rqident. data: lc_rq2name like tsp01-rq2name. concatenate f_repid+0(8) f_uname+0(3) into lc_rq2name separated by '_'. select * from tsp01 where rq2name = lc_rq2name order by rqcretime descending. f_rqident = tsp01-rqident. exit. endselect. if sy-subrc ne 0. clear f_rqident. endif. endform." get_spool_number
This man is too old to remember everything in his brain. Right now, he needs a place to write down what he has studied.
標籤
4GL
(1)
人才發展
(10)
人物
(3)
太陽能
(4)
心理
(3)
心靈
(10)
文學
(31)
生活常識
(14)
光學
(1)
名句
(10)
即時通訊軟體
(2)
奇狐
(2)
爬蟲
(1)
音樂
(2)
產業
(5)
郭語錄
(3)
無聊
(3)
統計
(4)
新聞
(1)
經濟學
(1)
經營管理
(42)
解析度
(1)
遊戲
(5)
電學
(1)
網管
(10)
廣告
(1)
數學
(1)
機率
(1)
雜趣
(1)
證券
(4)
證券期貨
(1)
ABAP
(15)
AD
(1)
agentflow
(4)
AJAX
(1)
Android
(1)
AnyChart
(1)
Apache
(14)
BASIS
(4)
BDL
(1)
C#
(1)
Church
(1)
CIE
(1)
CO
(38)
Converter
(1)
cron
(1)
CSS
(23)
DMS
(1)
DVD
(1)
Eclipse
(1)
English
(1)
excel
(5)
Exchange
(4)
Failover
(1)
Fedora
(1)
FI
(57)
File Transfer
(1)
Firefox
(3)
FM
(2)
fourjs
(1)
Genero
(1)
gladiatus
(1)
google
(1)
Google Maps API
(2)
grep
(1)
Grub
(1)
HR
(2)
html
(23)
HTS
(8)
IE
(1)
IE 8
(1)
IIS
(1)
IMAP
(3)
Internet Explorer
(1)
java
(4)
JavaScript
(22)
jQuery
(6)
JSON
(1)
K3b
(1)
ldd
(1)
LED
(3)
Linux
(117)
Linux Mint
(4)
Load Balance
(1)
Microsoft
(2)
MIS
(2)
MM
(51)
MSSQL
(1)
MySQL
(27)
Network
(1)
NFS
(1)
Office
(1)
OpenSSL
(1)
Oracle
(126)
Outlook
(3)
PDF
(6)
Perl
(60)
PHP
(33)
PL/SQL
(1)
PL/SQL Developer
(1)
PM
(3)
Postfix
(2)
postfwd
(1)
PostgreSQL
(1)
PP
(50)
python
(5)
QM
(1)
Red Hat
(4)
Reporting Service
(28)
ruby
(11)
SAP
(234)
scp
(1)
SD
(16)
sed
(1)
Selenium
(3)
Selenium-WebDriver
(5)
shell
(5)
SQL
(4)
SQL server
(8)
sqlplus
(1)
SQuirreL SQL Client
(1)
SSH
(2)
SWOT
(3)
Symantec
(2)
T-SQL
(7)
Tera Term
(2)
tip
(1)
tiptop
(24)
Tomcat
(6)
Trouble Shooting
(1)
Tuning
(5)
Ubuntu
(37)
ufw
(1)
utf-8
(1)
VIM
(11)
Virtual Machine
(2)
VirtualBox
(1)
vnc
(3)
Web Service
(2)
wget
(1)
Windows
(19)
Windows
(1)
WM
(6)
Xvfb
(2)
youtube
(1)
yum
(2)
2013年1月28日 星期一
SAP : Save Report Output to a PDF File
http://www.erpgenie.com/sap/abap/code/abap51.htm
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言