Alv to pdf
hi
could any one please tell me why we
use these twoo statements in converting from alv to pdf
TRANSLATE it_pdf_output USING ' ~'.
TRANSLATE gd_buffer USING '~ '.
Hi,
This is for after converting from spool to pdf you want to send it as mail then you chunk it as 255 length
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
loop at it_pdf_output.
translate it_pdf_output using ' ~'.
concatenate gd_buffer it_pdf_output into gd_buffer.
endloop.
translate gd_buffer using '~ '.
do.
it_mess_att = gd_buffer.
append it_mess_att.
shift gd_buffer left by 255 places.
if gd_buffer is initial.
exit.
endif.
enddo.
Similar Messages
-
can any one tell us how to download ALV to PDF.
Balaji,
Save Report Output to a PDF File
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
Don't forget to reward if useful........ -
ALV to PDF conversion with a page break
Friends,
I have a need where I need to print ALV in PDF format with a page break. Any advice on how to do this ? Is it possible to print in PDF format in ver ECC 6.0 without using OTF conversion routine ?
I tried to create a new device type PDF got an error in the spool when tried to print ?
Thanks,
Abap PMHi,
Check the below links.
[LINK1|https://wiki.sdn.sap.com/wiki/display/Snippets/SaveReportOutputtoaPDFFile]
[LINK2|Convert ABAP Report's Output into PDF Format..;
[LINK3|https://wiki.sdn.sap.com/wiki/display/ABAP/PDF%20Downlaod%20By%20Creating%20Spool%20Request]
Thanks,
Sreekanth -
How can I convert a report/ ALV in PDF format?
Can you tell me how can I convert a report or ALV in PDF format?
Regards,
Subhasishhi ,
check this..
*& Report ZSPOOLTOPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
Alternative way could be to submit another program and store spool
id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
Get spool id from program called above
IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
regards,
venkat. -
Hi Experts,
I am using following code to convert Alv report to pdf format..........can i change the number of output lines shown in the pdf
DATA :
WA_TSTC TYPE TSTC,
WA_TSTCP TYPE TSTCP,
SM30_PARA TYPE TSTCP-PARAM,
IT_PARAM TYPE STANDARD TABLE OF STRING,
WA_PARAM TYPE STRING,
GV_REPORT TYPE SY-REPID,
GV_PARAMS TYPE PRI_PARAMS,
GV_VALID TYPE STRING,
GV_RQIDENT TYPE TSP01-RQIDENT,
GT_RSPARAMS TYPE STANDARD TABLE OF RSPARAMS,
WA_TSP01 TYPE TSP01,
GV_SPOOL TYPE TSP01-RQIDENT,
GV_RQ2NAME TYPE TSP01-RQ2NAME,
PDF_BYTECOUNT TYPE I,
PDF_SPOOLID LIKE TSP01-RQIDENT,
LIST_PAGECOUNT TYPE I,
BTC_JOBNAME TYPE TBTCJOB-JOBNAME,
BTC_JOBCOUNT TYPE TBTCJOB-JOBCOUNT,
BIN_FILE TYPE XSTRING,
GT_PDF TYPE STANDARD TABLE OF TLINE,
GV_BIN_FILESIZE TYPE I, " Binary File Size
GV_FILE_NAME TYPE STRING,
GV_FILE_PATH TYPE STRING,
GV_FULL_PATH TYPE STRING.
" Selection Screen
SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT000.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (23) TEXT001 FOR FIELD P_TCODE.
PARAMETERS P_TCODE TYPE TSTC-TCODE OBLIGATORY.
SELECTION-SCREEN END OF LINE.
"Text
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (70) TEXT002.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK B1.
LOAD-OF-PROGRAM.
TEXT000 = 'Selection Criteria'.
TEXT001 = '@8T@ Transaction Code'.
TEXT002 = '*Enter Tcode->Select Print Option->Execute report->Save PDF File'.
START-OF-SELECTION.
"Fetch Tcode and Report info
PERFORM FETCH_TCODE_REPORT.
"Call Transaction
PERFORM CALL_TRANSACTION.
"Get Spool and Generate PDF
PERFORM GET_SPOOL_TO_PDF.
*& Form FETCH_TCODE_REPORT
* text
* --> p1 text
* <-- p2 text
FORM FETCH_TCODE_REPORT .
DATA :
FLG_TCODE TYPE CHAR1,
CHR1 TYPE CHAR40,
CHR2 TYPE CHAR40.
SELECT SINGLE * FROM TSTC
INTO WA_TSTC WHERE TCODE = P_TCODE
AND PGMNA NE SPACE
AND DYPNO = 1000. "only Standard Report
IF SY-SUBRC = 0.
FLG_TCODE = 'X'.
GV_REPORT = WA_TSTC-PGMNA.
ELSE.
SELECT SINGLE * FROM
TSTCP INTO WA_TSTCP
WHERE TCODE = P_TCODE
AND PARAM NE SPACE.
SPLIT WA_TSTCP-PARAM AT ';' INTO TABLE IT_PARAM.
LOOP AT IT_PARAM INTO WA_PARAM.
IF WA_PARAM CS '-REPORT='.
FLG_TCODE = 'X'.
SPLIT WA_PARAM AT '-REPORT=' INTO CHR1 CHR2.
GV_REPORT = CHR2.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
IF FLG_TCODE IS INITIAL.
MESSAGE 'In Valid Tcode' TYPE 'I' DISPLAY LIKE 'E'.
LEAVE TO TRANSACTION SY-TCODE.
ENDIF.
CALL FUNCTION 'AUTH_CHECK_TCODE'
EXPORTING
TCODE = P_TCODE
EXCEPTIONS
PARAMETER_ERROR = 1
TRANSACTION_NOT_FOUND = 2
TRANSACTION_LOCKED = 3
TRANSACTION_IS_MENU = 4
MENU_VIA_PARAMETER_TRANSACTION = 5
NOT_AUTHORIZED = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
MESSAGE 'No Authorization for Tcode' TYPE 'I' DISPLAY LIKE 'E'.
LEAVE TO TRANSACTION SY-TCODE.
ENDIF.
ENDFORM. " FETCH_TCODE_REPORT
*& Form CALL_TRANSACTION
* text
* --> p1 text
* <-- p2 text
FORM CALL_TRANSACTION .
CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING
OUT_PARAMETERS = GV_PARAMS
VALID = GV_VALID.
IF SY-SUBRC <> 0.
ENDIF.
"Spool Mode, Default will be Spool Only
CLEAR GV_PARAMS-PRIMM.
"Spool Request Name, Pass Report name , Only 1st 12 Chars
GV_RQ2NAME = GV_REPORT.
GV_PARAMS-PLIST = GV_RQ2NAME.
SUBMIT (GV_REPORT) VIA SELECTION-SCREEN
TO SAP-SPOOL
SPOOL PARAMETERS GV_PARAMS
WITHOUT SPOOL DYNPRO
AND RETURN.
IF SY-SUBRC NE 0.
MESSAGE 'Unable to Execute Report' TYPE 'I' DISPLAY LIKE 'E'.
LEAVE TO TRANSACTION SY-TCODE.
ENDIF.
WAIT UP TO 2 SECONDS.
ENDFORM. " CALL_TRANSACTION
*& Form GET_SPOOL_TO_PDF
* text
* --> p1 text
* <-- p2 text
FORM GET_SPOOL_TO_PDF .
DATA :
LV_RQCRETIME TYPE TSP01-RQCRETIME,
LV_RETURNCODE TYPE I.
CONCATENATE SY-DATUM '%' INTO LV_RQCRETIME.
SELECT MAX( RQIDENT ) INTO GV_SPOOL FROM TSP01 WHERE RQCLIENT = SY-MANDT
AND RQ2NAME = GV_RQ2NAME
AND RQOWNER = SY-UNAME
AND RQCRETIME LIKE LV_RQCRETIME.
CHECK SY-SUBRC = 0.
SELECT SINGLE * FROM TSP01
INTO WA_TSP01 WHERE RQIDENT = GV_SPOOL.
IF WA_TSP01 IS INITIAL.
MESSAGE 'No Valid Spool Request Found' TYPE 'I' DISPLAY LIKE 'E'.
LEAVE TO TRANSACTION SY-TCODE.
ENDIF.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = GV_SPOOL
NO_DIALOG = ABAP_FALSE
IMPORTING
PDF_BYTECOUNT = PDF_BYTECOUNT
PDF_SPOOLID = PDF_SPOOLID
BTC_JOBNAME = BTC_JOBNAME
BTC_JOBCOUNT = BTC_JOBCOUNT
TABLES
PDF = GT_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.
CHECK GT_PDF IS NOT INITIAL.
GV_FILE_NAME = P_TCODE.
* To display File SAVE dialog window
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = 'Save Output as PDF' "LV_TITLE
DEFAULT_EXTENSION = 'PDF'
FILE_FILTER = '(*.pdf)|*.pdf|'
DEFAULT_FILE_NAME = GV_FILE_NAME
CHANGING
FILENAME = GV_FILE_NAME
PATH = GV_FILE_PATH
FULLPATH = GV_FULL_PATH
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
* presentation server
CHECK GV_FULL_PATH IS NOT INITIAL.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = GV_BIN_FILESIZE
FILENAME = GV_FULL_PATH
FILETYPE = 'BIN'
TABLES
DATA_TAB = GT_PDF
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC = 0.
MESSAGE 'File Generated Successfully' TYPE 'S'.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GET_SPOOL_TO_PDFHi ,
Try this procedure...
DATA:SSFCTRLOP TYPE SSFCTRLOP.
DATA:SSFCOMPOP TYPE SSFCOMPOP.
DATA:IT_OTF_DATA TYPE SSFCRESCL.
DATA:IT_OTF_FINAL TYPE ITCOO OCCURS 0 WITH HEADER LINE.
DATA:BIN_FILESIZE TYPE I.
DATA:IT_PDFDATA TYPE TABLE OF TLINE.
DATA:IT_PDF TYPE TABLE OF SOLISTI1.
DATA: ST_JOB_OUTPUT_INFO TYPE SSFCRESCL,
ST_DOCUMENT_OUTPUT_INFO TYPE SSFCRESPD,
ST_JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
IT_DOCS TYPE STANDARD TABLE OF DOCS,
IT_LINES TYPE STANDARD TABLE OF TLINE,
V_NAME TYPE STRING,
V_PATH TYPE STRING,
V_FULLPATH TYPE STRING,
V_FILTER TYPE STRING,
V_UACT TYPE I,
V_GUIOBJ TYPE REF TO CL_GUI_FRONTEND_SERVICES,
V_FILENAME TYPE STRING,
V_BIN_FILESIZE TYPE I.
****** PDF
TYPES: T_DOCUMENT_DATA TYPE SODOCCHGI1,
T_PACKING_LIST TYPE SOPCKLSTI1,
T_ATTACHMENT TYPE SOLISTI1,
T_BODY_MSG TYPE SOLISTI1,
T_RECEIVERS TYPE SOMLRECI1,
T_PDF TYPE TLINE.
DATA : W_DOCUMENT_DATA TYPE T_DOCUMENT_DATA,
W_PACKING_LIST TYPE T_PACKING_LIST,
W_ATTACHMENT TYPE T_ATTACHMENT,
W_BODY_MSG TYPE T_BODY_MSG,
W_RECEIVERS TYPE T_RECEIVERS,
W_PDF TYPE T_PDF.
DATA : I_DOCUMENT_DATA TYPE STANDARD TABLE OF T_DOCUMENT_DATA,
I_PACKING_LIST TYPE STANDARD TABLE OF T_PACKING_LIST,
I_ATTACHMENT TYPE STANDARD TABLE OF T_ATTACHMENT,
I_BODY_MSG TYPE STANDARD TABLE OF T_BODY_MSG,
I_RECEIVERS TYPE STANDARD TABLE OF T_RECEIVERS,
I_PDF TYPE STANDARD TABLE OF T_PDF.
DATA : G_SENT_TO_ALL TYPE SONV-FLAG,
G_TAB_LINES TYPE I.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
BIN_FILESIZE = V_BIN_FILESIZE
TABLES
OTF = ST_JOB_OUTPUT_INFO-OTFDATA
DOCTAB_ARCHIVE = IT_DOCS
LINES = IT_LINES
EXCEPTIONS
ERR_CONV_NOT_POSSIBLE = 1
ERR_OTF_MC_NOENDMARKER = 2
OTHERS = 3.
**** ........................GET THE FILE NAME TO STORE....................
CONCATENATE 'Order Vs Billing' '.pdf' INTO V_NAME.
CREATE OBJECT V_GUIOBJ.
CALL METHOD V_GUIOBJ->FILE_SAVE_DIALOG
EXPORTING
DEFAULT_EXTENSION = 'pdf'
DEFAULT_FILE_NAME = V_NAME
FILE_FILTER = V_FILTER
CHANGING
FILENAME = V_NAME
PATH = V_PATH
FULLPATH = V_FULLPATH
USER_ACTION = V_UACT.
IF V_UACT = V_GUIOBJ->ACTION_CANCEL.
EXIT.
ENDIF.
**** ..................................DOWNLOAD AS FILE....................
MOVE V_FULLPATH TO V_FILENAME.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = V_BIN_FILESIZE
FILENAME = V_FILENAME
FILETYPE = 'BIN'
TABLES
DATA_TAB = IT_LINES
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
ENDIF.
if it's helpfur for you.. pls give reward points. -
Hi,
I;m displaying my ALV using SALV classes.But problem is that when i download it in PDF then traffic lights are not getting displayed.
How can we show traffic lights in PDF for an ALV ?
Thanks & Regards,
Vivek GaurHi,
You can set header text for PDF print specifically by use of following method
DATA: lo_cmp_usage type ref to if_wd_component_usage.
DATA: lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
Data: lr_function_settings TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
DATA: lv_header_text type string.
*create an instance of ALV component
lo_cmp_usage = wd_this->wd_cpuse_OVERVIEW_RET_ALV( ).
* if not initialized, then initialize
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
* get ALV component
lr_salv_wd_table = wd_this->wd_cpifc_OVERVIEW_RET_ALV( ).
wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
* get function settings
lr_function_settings ?= wd_this->alv_config_table.
CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_PDF_SETTINGS~SET_HEADER_LEFT_FREETEXT
EXPORTING
VALUE = LV_HEADER_TEXT. " lv_header_text is your pdf pring header
Hope this helps
Regards
Manas Dua -
Reg exporting ALV to PDF in Webdynpro ABAP
Hi All,
I've developed one Webdynpro ABAP portal. There, in one view, I have an ALV for Account Statement. I need to allow this output - as it is - to be Downloaded and Printed as per given Button-choice in PDF Format.
How can I do this? I searched SDN Forum for this. Many an articles are there but, they suggest that data from Internal Table can be exported to PDF. How can we get the data from ALV in one view to internal table?
If there is other way of doing the same, would you please guide me.
Thanks.
Kumar Saurav.Hi Thomas,
Thanks for your guidelines.
In our system, ADS has already been installed. Second, ALV Toolbar is not reqd from Client's side. They need only Print and Download Functionality that too using Button.
Hence, my case came into picture. Further, I have to add Customer Name with address as Header and Net Balance as Footer in my PDF. Therefore I need to fetch all the data that are already in ALV and present it with changed layout.
Please guide me.
Thanks.
Kumar Saurav. -
hi friends,
i want convert the alv report to pdf and mail the same pdf.
have used function REUSE_ALV_LIST_DISPLAY to display alv report.
i am using CONVERT_ABAPSPOOLJOB_2_PDF to convert the alv report to pdf.
now i need to mail the pdf implicitly to the email address.
i have used some function to mail the pdf but it is asking for the path which has to be hard coded.
the path cannot be hard coded.
cant use F4_GETFILENAME or gui_upload to attach the file or to get the path because the pdf has to be sent directly to some email address.
thanks.
regards,
akshay ruia.Please refer the link below.............
Sample Program To Convert Smartform To PDF Document & Mail It To The Concerned As An Attachment.
[http://www.abapmadeeasy.com/2011/02/sap-abap-sample-program-to-convert.html|http://www.abapmadeeasy.com/2011/02/sap-abap-sample-program-to-convert.html]
Regards,
Uttam Agrawal
http://www.abapmadeeasy.com
Edited by: uttamagrawal on Feb 22, 2011 9:19 AM -
Hi Gurus,
I have 17 fields in ALV output ,which is to be converted into PDF report,
in normal layout it is converting only 5 fields into pdf (truncating rest of the fields )
while in landscape layout data is splliting into 2 lines ,and as a result pdf is not coming properly.
is there any way of doing this ,so that all fields can come in single line of PDF without truncating the data.
Please Respond,
Points will be rewarded ,
Regards
TalwinderHi
try by using this FM 'CONVERT_OTF'
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
IMPORTING
bin_filesize = bin_filesize
BIN_FILE =
TABLES
otf = tab_otf_final
lines = pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILE_NAME =
FILE_FILTER =
INITIAL_DIRECTORY =
WITH_ENCODING =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
filename = FILE_NAME
path = FILE_PATH
fullpath = FULL_PATH
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
************downloading the converted PDF data to your local PC*******
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = FULL_PATH
filetype = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
IMPORTING
filelength = file_size
TABLES
data_tab = pdf_tab
FIELDNAMES =
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22
IF sy-subrc 0.
ENDIF. -
Can someone tell me how we can convert an ALV report to PDF and send it as an attachment to the external emial.
Please help me.
Thanks,
Sneha Singh.I wrote a program that you can pass an ALV report and a variant and it will send the results as a PDF or HTML attachment. Here it is...
REPORT ZEMAILREPORT.
DATA: BEGIN OF MAIL_TO OCCURS 0,
SMTP_ADDR LIKE SOLI-LINE.
DATA: END OF MAIL_TO.
DATA: I_ABAPLIST LIKE ABAPLIST OCCURS 0 WITH HEADER LINE.
DATA: I_CONTENT_BIN LIKE W3HTML OCCURS 0 WITH HEADER LINE.
DATA: W_DOC_DATA LIKE SODOCCHGI1.
DATA: W_SENT_TO_ALL LIKE SONV-FLAG.
DATA: W_LINE_SIZE TYPE I.
DATA: I_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
I_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
DATA: W_PDF_BYTECOUNT TYPE I.
DATA: W_SPOOL_ID LIKE TSP01-RQIDENT.
DATA: W_BUFFER TYPE STRING.
*DATA: SPOOL PARAMETERS pri_params.
DATA: W_PRINT_PARAMETERS TYPE PRI_PARAMS,
W_VALID_FLAG(1) TYPE C,
W_LIST_TEXT LIKE PRI_PARAMS-PRTXT.
DATA: I_PDF LIKE TLINE OCCURS 0 WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.
PARAMETERS: P_REPRT LIKE RS38M-PROGRAMM OBLIGATORY.
PARAMETERS: P_VARI LIKE RSVAR-VARIANT OBLIGATORY.
PARAMETERS: P_TITLE LIKE SODOCCHGI1-OBJ_DESCR OBLIGATORY.
PARAMETERS: P_FILNAM LIKE SODOCCHGI1-OBJ_DESCR OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
S_EMAIL FOR MAIL_TO-SMTP_ADDR OBLIGATORY NO INTERVALS.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
PARAMETERS: P_HTML RADIOBUTTON GROUP GF DEFAULT 'X',
P_PDF RADIOBUTTON GROUP GF.
SELECTION-SCREEN END OF BLOCK B3.
START-OF-SELECTION.
IF P_HTML = 'X'.
SUBMIT (P_REPRT) USING SELECTION-SET P_VARI
EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = I_ABAPLIST
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE I000(OO) WITH 'Output for report'
P_REPRT
'not found'.
EXIT.
ENDIF.
CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
EXPORTING
REPORT_NAME =
TEMPLATE_NAME = 'WEBREPORTING_REPORT'
TABLES
HTML = I_CONTENT_BIN
LISTOBJECT = I_ABAPLIST.
ELSE.
W_LIST_TEXT = P_TITLE.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
ARCHIVE_MODE = '1'
NO_DIALOG = 'X'
DESTINATION = SPACE
IMMEDIATELY = 'X'
LIST_TEXT = W_LIST_TEXT
IMPORTING
OUT_PARAMETERS = W_PRINT_PARAMETERS
OUT_ARCHIVE_PARAMETERS = W_ARCHI_PARAMETERS
VALID = W_VALID_FLAG
EXCEPTIONS
INVALID_PRINT_PARAMS = 2
OTHERS = 4.
PERFORM DETERMINE_SPOOL_NAME CHANGING W_PRINT_PARAMETERS-PLIST.
IF SY-SUBRC <> 0.
MESSAGE E000(OO) WITH 'Can not determine print'
'parameters needed for'
'PDF conversion'.
ENDIF.
SUBMIT (P_REPRT) USING SELECTION-SET P_VARI
TO SAP-SPOOL
SPOOL PARAMETERS W_PRINT_PARAMETERS
WITHOUT SPOOL DYNPRO
COVER TEXT P_TITLE
IMMEDIATELY SPACE
KEEP IN SPOOL ' '
AND RETURN.
COMMIT WORK AND WAIT.
PERFORM GET_SPOOL_NUMBER USING W_PRINT_PARAMETERS-PLIST
CHANGING W_SPOOL_ID.
IF W_SPOOL_ID IS INITIAL.
MESSAGE I000(OO) WITH 'Output for report'
P_REPRT
'not found'.
EXIT.
ELSE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = W_SPOOL_ID
NO_DIALOG =
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = W_PDF_BYTECOUNT
PDF_SPOOLID =
LIST_PAGECOUNT =
BTC_JOBNAME =
BTC_JOBCOUNT =
TABLES
PDF = I_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
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
*CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = 134
line_width_dst = 255
TABLES
content_in = i_pdf
content_out = l_attachment
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE s000(0k) WITH 'Conversion Failed'.
EXIT.
ENDIF.
Transfer the 132-long strings to 255-long strings
LOOP AT I_PDF.
TRANSLATE I_PDF USING ' ~'.
CONCATENATE W_BUFFER I_PDF INTO W_BUFFER.
ENDLOOP.
TRANSLATE W_BUFFER USING '~ '.
DO.
I_CONTENT_BIN = W_BUFFER.
APPEND I_CONTENT_BIN.
SHIFT W_BUFFER LEFT BY 255 PLACES.
IF W_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDIF.
ENDIF.
ENDIF.
W_DOC_DATA-OBJ_NAME = 'List'.
W_DOC_DATA-OBJ_DESCR = P_TITLE.
W_DOC_DATA-SENSITIVTY = 'O'.
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
Add the recipient(s) email address
REFRESH I_RECEIVERS.
LOOP AT S_EMAIL.
CLEAR I_RECEIVERS.
I_RECEIVERS-RECEIVER = S_EMAIL-LOW.
I_RECEIVERS-REC_TYPE = 'U'.
I_RECEIVERS-COM_TYPE = 'INT'.
I_RECEIVERS-NOTIF_DEL = 'X'.
I_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND I_RECEIVERS.
ENDLOOP.
CLEAR I_PACKING_LIST.
REFRESH I_PACKING_LIST.
I_PACKING_LIST-TRANSF_BIN = 'X'.
I_PACKING_LIST-HEAD_START = 0.
I_PACKING_LIST-HEAD_NUM = 0.
I_PACKING_LIST-BODY_START = 0.
I_PACKING_LIST-BODY_NUM = 0.
I_PACKING_LIST-DOC_TYPE = 'RAW'.
I_PACKING_LIST-OBJ_DESCR = P_FILNAM.
APPEND I_PACKING_LIST.
I_PACKING_LIST-TRANSF_BIN = 'X'.
I_PACKING_LIST-HEAD_START = 0.
I_PACKING_LIST-HEAD_NUM = 0.
I_PACKING_LIST-BODY_START = 1.
IF P_HTML = 'X'.
I_PACKING_LIST-DOC_TYPE = 'HTM'.
ELSE.
I_PACKING_LIST-DOC_TYPE = 'PDF'.
ENDIF.
DESCRIBE TABLE I_CONTENT_BIN LINES I_PACKING_LIST-BODY_NUM.
CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
IF CL_ABAP_CHAR_UTILITIES=>CHARSIZE > 1. " system is Unicode
W_LINE_SIZE = 510.
ELSE.
W_LINE_SIZE = 255.
ENDIF.
READ TABLE I_CONTENT_BIN INDEX I_PACKING_LIST-BODY_NUM.
IF P_HTML = 'X'.
I_PACKING_LIST-DOC_SIZE = ( I_PACKING_LIST-BODY_NUM - 1 ) * W_LINE_SIZE
+ STRLEN( I_CONTENT_BIN ).
ELSE.
I_PACKING_LIST-DOC_SIZE = W_PDF_BYTECOUNT.
ENDIF.
APPEND I_PACKING_LIST.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_TO_ALL
TABLES
PACKING_LIST = I_PACKING_LIST
CONTENTS_BIN = I_CONTENT_BIN
contents_txt = i_attachment
RECEIVERS = I_RECEIVERS
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
*& Form get_spool_number
text
-->P_REPID text
-->P_UNAME text
-->P_RQIDENT text
FORM GET_SPOOL_NUMBER USING P_SPOOL_NAME
CHANGING P_RQIDENT.
DATA: W_TSP01 LIKE TSP01.
CLEAR: P_RQIDENT.
SELECT * INTO W_TSP01
FROM TSP01 UP TO 1 ROWS
WHERE RQ2NAME = P_SPOOL_NAME
ORDER BY RQCRETIME DESCENDING.
ENDSELECT.
IF SY-SUBRC = 0.
P_RQIDENT = W_TSP01-RQIDENT.
ENDIF.
ENDFORM." get_spool_number
*& Form DETERMINE_SPOOL_NAME
text
<--P_W_SPOOL_NAME text
FORM DETERMINE_SPOOL_NAME CHANGING P_SPOOL_NAME.
CLEAR: P_SPOOL_NAME.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
NR_RANGE_NR = '01'
OBJECT = 'ZSPOOLNAME'
QUANTITY = '1'
SUBOBJECT = ' '
TOYEAR = '0000'
IGNORE_BUFFER = ' '
IMPORTING
NUMBER = P_SPOOL_NAME
QUANTITY =
RETURNCODE =
EXCEPTIONS
INTERVAL_NOT_FOUND = 1
NUMBER_RANGE_NOT_INTERN = 2
OBJECT_NOT_FOUND = 3
QUANTITY_IS_0 = 4
QUANTITY_IS_NOT_1 = 5
INTERVAL_OVERFLOW = 6
BUFFER_OVERFLOW = 7
OTHERS = 8
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DETERMINE_SPOOL_NAME
*Selection-texts
*P_FILNAM Name of attachment
*P_HTML Html
*P_PDF PDF
*P_REPRT Program Name
*P_TITLE Email Subject
*P_VARI Variant Name
*S_EMAIL Email address
*Text symbols
*001 Email address to send report output
*002 Report parameters
*003 Format options -
Skip "Print ALV list" pop up while saving ALV as PDF
Dear experts,
I am converting my ALV list into PDF.
im using
CONVERT_ABAPSPOOLJOB_2_PDF
and
GUI_DOWNLOAD
But it pops up a screen asking the default printer. What parameters do i need to pass to CONVERT_ABAPSPOOLJOB_2_PDF so that I can skip the pop up?
I have already tried passing --
NO_DIALOG = 'X'
DST_DEVICE = 'locl'
Regards,
Sumit.Hi Sumit,
first use:-
CALL FUNCTION 'RSPO_FIND_SPOOL_REQUESTS'
EXPORTING
allclients = '320'
datatype = '*'
has_output_requests = '*'
rq0name = nast-dsnam
rq1name = '*'
rq2name = '*'
rqdest = 'LOCL'
rqowner = sy-uname
TABLES
spoolrequests = it_spool
EXCEPTIONS
no_permission = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE i000 DISPLAY LIKE 'E' WITH text-002.
LEAVE LIST-PROCESSING.
ENDIF.
FORM convert_spool_to_pdf .
READ TABLE it_spool INTO wa_spool INDEX 1.
v_spoolno = wa_spool-rqident.
*Get Spool request attributes
SELECT SINGLE *
FROM tsp01
INTO tsp01
WHERE rqident EQ v_spoolno.
IF sy-subrc <> 0.
MESSAGE i000 DISPLAY LIKE 'E'
WITH text-003 v_spoolno text-034.
LEAVE LIST-PROCESSING.
ENDIF.
v_client = tsp01-rqclient.
v_name = tsp01-rqo1name.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
authority = 'SP01'
client = v_client
name = v_name
part = 1
IMPORTING
objtype = v_objtype
EXCEPTIONS
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE i000(zz) DISPLAY LIKE 'E'
WITH text-003 v_spoolno text-034.
LEAVE LIST-PROCESSING.
ENDIF.
IF v_objtype(3) EQ 'OTF'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = v_spoolno
no_dialog = ' '
TABLES
pdf = it_pdf
EXCEPTIONS
err_no_otf_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 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.
IF sy-subrc <> 0.
ENDIF.
ELSE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = v_spoolno
no_dialog = 'X'
TABLES
pdf = it_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.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDFORM. " convert_spool_to_pdf -
Hi All,
I have to convert my ALV list to PDF format nad I have to down load the format to my desktop.Kindly hep me in coding ??
regards
KKuse the function module CONVERT_ABAPSPOOLJOB_2_PDF to convert the abap list into PDF.
Refer the following link to know more about pdf conversions:
http://www.sapgenie.com/abap/pdf_creation.htm
Regards,
ravi -
Hi all,
How Can I convert an ALV report to PDF document?
thanks.
Regardas.
Marisol.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 -
Convert ALV report into PDF and mail ( Hierarchical List View )
Hi All,
I see many posts of PDF download but none resolve my issue.
I am writing a report in APO SNP which fetches data and displays an alv using REUSE_ALV_HIERSEQ_LIST_DISPLAY as i need to show the result as a Hierarchical sequential list.
I need to provide the functionality of PDF download ( online ) and Email with PDF as attachement ( Background ) for the list output.
I read the post http://www.sapdev.co.uk/reporting/rep_spooltopdf2.htm which provides a sample program and tried to incorporate but the control doesn't come back from the ALV function module.
How do i trigger the spool creation while still showing the output and then send email?
Suggestions and pointers are highly appreciated
Regards,
KDHi.,
Check this wiki: [Convert ALV as PDF Attachment|http://wiki.sdn.sap.com/wiki/display/Snippets/SENDALVGRIDASPDFATTACHMENTTOSAPINBOXUSINGCLASSES]
hope this helps u.,
Thanks & Regards,
Kiran -
Download ALV report to PDF with Lights
Hi,
I have a requirement wherein, when i download ALV report to PDF which has Lights in the first column. My problem is these lights are not displayed instead i get the following in the PDF
PDF o/p:
XOO RED SIGNAL
OXO YELLOW SIGNAL
OOX GREEN SIGNAL
Please let me know how to get the lights in the PDF o/p
Thanks & Regards,
SandhyaHi Sandhya,
U can convert any type of display(SF,ALV) to PDF.....
User Program rstxpdft4 to convert it first the O/P need to be converted into spool.
cheers,
Naveen.
Maybe you are looking for
-
I am having a crash every time I try to load a photo to the beta.
I loaded and edited three photos with no issues and now LR4 crashes each time I try to load a new photo. I saw the mention of lens correction and CA correction, so I turned those off and the program still crashed on loading a photo. The photos I hav
-
HT1848 how to I transfer music from my itunes library to my ipod?
How do I transfer music from my itunes libraray to my ipod?
-
I have set the PP tolerance limits to 1% and $ 2 as absolute limit, however when I do an invoice posting which is beyond either of these limits ( PO $ 100, invoice at $110) the system did not stop me from from posting. What am I missing as far as con
-
How to make case struture be finished
I have program and one part of it works for feedback. When pressure riches some critical value it opens valve(automatic mode). As a result pressure drops back. It can work as well in constant mode: opens valve periodically for some period of time. It
-
Installation Error with DB2 on windows Server 2003 R2
Hi Experts, We are installing ERP 6.0 on DB2 (DBUDB 9.7) Fresh Installation. While Installing ERP 6.0 (ECC6.0 SR3) we are facing an error attached. Can you please suggest us to move Forward. Details : OS : Windows Server 2003 R2 DB2 : DBUDB 9.7 Thank