Spool to pdf size
hy yall,
i'm trying to convert to pdf a spool (really big, more than 10000 pages...), but can't succed
DATA spool LIKE tsp01-rqident.
MOVE st_tspoolreq-rqident TO spool.
CLEAR spool.
spool = 13613.
CALL FUNCTION 'RSPO_GET_TYPE_SPOOLJOB'
EXPORTING
rqident = spool
IMPORTING
is_otf = otf
EXCEPTIONS
can_not_access = 1
OTHERS = 2.
IF sy-subrc <> 0.
ELSEIF otf EQ 'X'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spool
IMPORTING
pdf_bytecount = pbyte
TABLES
pdf = t_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.
ELSE. " Generar PDF de Abap
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spool
IMPORTING
pdf_bytecount = pbyte
TABLES
pdf = t_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 EQ 0.
inside CONVERT_OTFSPOOLJOB_2_PDF
i have toolarge = 'X'.
how can i manage it?
is there a limit of number of page that can be process?
no way even with the standard. when i try to convert other spool (less than 20 pages) i don't have problem...so i think the trouble might be the size or the number of page. It's possibile to divide the spool in many packages the print the package?
Similar Messages
-
URGENT ----- Problem in converting spool to pdf .
Error - File cannot be opened because of no pages ......
Hi experts,
I am passing internal table contents to spool --> then spool to pdf -
> then mail sending.
Everything is fine but only error is in the receiving mail the above error is coming.
given the code...
<b>I think the error is in converting into pdf function module</b>
<b>Help me to solve this problem as it is very urgent</b>
include data_declare. " pasted down
select * from kna1 into table itab up to 50 rows.
CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
EXPORTING
dest = 'LP01'
immediate_print = 'X'
IMPORTING
handle = handle
SPOOLID = spoolid.
loop at itab.
concatenate itab-kunnr itab-name1 itab-land1 into text separated by
space.
CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
EXPORTING
handle = handle
text = text.
endloop.
CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'
EXPORTING
handle = handle.
Convert Spool to PDF **********************************
<b>CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = 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.</b>
Processing Mail Sending ************************************
DATA: p_email LIKE somlreci1-receiver,
p_sender LIKE somlreci1-receiver,
sub(40).
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = text-002.
it_mess_bod = text-001.
APPEND it_mess_bod.
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
MOVE 'Orders Rejeced on' TO sub.
WRITE: sy-datum DD/MM/YYYY TO sub+27(10).
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
TABLES it_mess_bod
it_mess_att
USING
p_email
sub "text-009
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
CHANGING gd_error
gd_reciever.
ENDFORM. " process_email
*& Form send_file_as_email_attachment
text
-->P_IT_MESS_BOD text
-->P_IT_MESS_ATT text
-->P_TEXT_009 text
-->P_1058 text
-->P_GD_ATTACHMENT_NAME text
-->P_GD_ATTACHMENT_DESC text
<--P_GD_ERROR text
<--P_GD_RECIEVER text
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-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
CLEAR gt_mail.
SELECT SINGLE * FROM zmail INTO gt_mail
WHERE grpnr = '1'.
IF NOT gt_mail-mail1 IS INITIAL.
t_receivers-receiver = gt_mail-mail1.
APPEND t_receivers.
ENDIF.
IF NOT gt_mail-mail2 IS INITIAL.
t_receivers-receiver = gt_mail-mail2.
APPEND t_receivers.
ENDIF.
IF NOT gt_mail-mail3 IS INITIAL.
t_receivers-receiver = gt_mail-mail3.
APPEND t_receivers.
ENDIF.
IF NOT gt_mail-mail4 IS INITIAL.
t_receivers-receiver = gt_mail-mail4.
APPEND t_receivers.
ENDIF.
LOOP AT gt_mail.
t_receivers-receiver = gt_mail-mailid..
APPEND t_receivers.
ENDLOOP.
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. " send_file_as_email_attachment
Data Declaration ************************************
DATA : handle LIKE sy-tabix.
data itab like kna1 occurs 0 with header line.
data: text(50) type c.
data: spoolid type TSP01-RQIDENT.
DATA : gt_listobject LIKE abaplist OCCURS 10 .
DATA : gt_objcont LIKE soli OCCURS 10 WITH HEADER LINE.
DATA : gt_objcont1 LIKE soli OCCURS 10 WITH HEADER LINE.
DATA : gt_objhead LIKE soli OCCURS 10 WITH HEADER LINE.
DATA : gt_att_head LIKE soli OCCURS 10 WITH HEADER LINE.
DATA : gt_receivers LIKE soos1 OCCURS 10 WITH HEADER LINE.
DATA : gt_packing_list LIKE soxpl OCCURS 10 WITH HEADER LINE.
DATA : gt_so_ali LIKE soli OCCURS 100 WITH HEADER LINE.
DATA : gt_so_ali1 LIKE soli OCCURS 100 WITH HEADER LINE.
DATA : gt_document_data LIKE sood1.
DATA: lineno TYPE i , length TYPE i , size TYPE i.
DATA: gt_message LIKE soli OCCURS 10 WITH HEADER LINE,
gt_message1 LIKE soli OCCURS 10 WITH HEADER LINE.
DATA: gt_scheme LIKE ztrc_scheme OCCURS 0 WITH HEADER LINE,
gt_mail LIKE zmail_prov OCCURS 0 WITH HEADER LINE.
gt_mail LIKE zmail." occurs 0 with header line.
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'.
DATA: check TYPE c,
days TYPE i.
<b></b><b></b><b></b>Hi Prashant,
Thanks for your reply. Really it is very useful one.
In this, the output list is getting populated into spool and to pdf.
But my requirement sending the internal table contents to spool directly without dispalying in the output list.
I did the program like the above mentioned one already. But my requirement is not that one.
Regards
chakradhar -
Convert spool to pdf and send in email sometimes attachment duplicated.
Hi all, I have a process that creates a spool, converts it to a pdf and then attaches it to an email. My problem is that sometimes, the same attachment is duplicated.
The process seems to work fine in debug mode (the attachment changes for each loop) but when I run it in the background, every few emails, it will duplicate an attachment.
I have noticed that the size of the pdf seems to change properly but that the content of the pdf does not match. So, it is like it gets the correct size of the pdf but not the body.
This is code that a consultant wrote and I am pretty new to abap/sap. I have changed some of the code because it was trying to handle an endless loop (I figured it should not have to handle (be in) an endless loop). I changed that code and it is working but this previous issue still exists. Thanks for your help.
*& Form PROCESS_EMPLOYEE
FORM process_employee .
* process appraisal only
IF it_final[] IS NOT INITIAL .
* READ DISTRIBUTION LIST *
REFRESH : it_email, it_idlient.
*Sort by supervisor
SORT it_final[] BY supervisor.
LOOP AT it_final INTO wa_final .
APPEND wa_final TO it_final1 .
AT END OF supervisor .
* Perform to create the PDF from the Output
report = 'zhr_pm_appemail'.
PERFORM create_pdf using report.
** Perform to email the PDF attachment
** to the supervisor and the Mailing list
subject = 'Performance Appraisals'.
PERFORM process_email using subject.
REFRESH it_final1 .
CLEAR it_final1 .
CLEAR wa_final .
FREE MEMORY ID 'MEM'.
ENDAT .
ENDLOOP.
ENDIF.
ENDFORM. " PROCESS_EMPLOYEE
*& Form CREATE_PDF
FORM create_pdf using report.
DATA: spoolno TYPE tsp01-rqident.
DATA : p_repid TYPE sy-repid .
DATA: v_len TYPE i , v_len1 TYPE i .
DATA: v_temp(8) TYPE c .
DATA: p_uname TYPE sy-uname .
DATA: it_tsp01 TYPE STANDARD TABLE OF tsp01 WITH HEADER LINE .
* DATA: it_pdf TYPE tline OCCURS 0 WITH HEADER LINE .
TABLES: tsp01.
DATA: var TYPE c .
*-- STRUCTURES
DATA:
lc_rq2name TYPE tsp01-rq2name.
DATA:
mstr_print_parms TYPE pri_params,
mc_valid(1) TYPE c,
mi_bytecount TYPE i,
mi_length TYPE i,
mi_rqident TYPE tsp01-rqident.
*-- INTERNAL TABLES
DATA:
mtab_pdf TYPE tline OCCURS 0 WITH HEADER LINE,
mc_filename TYPE rlgrap-filename.
*-- SELECTION SCREEN
DATA:
p_linsz TYPE sy-linsz VALUE 80, " Line size
p_paart TYPE sy-paart VALUE 'X_65_80'. " Paper Format
p_uname = sy-uname .
var = var + 1.
p_repid = report.
* START-OF-SELECTION .
concatenate p_repid+0(9)
p_uname+0(3)
into mc_filename
separated by '_'.
translate mc_filename to upper case.
*-- 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
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.
IF sy-subrc = 0 .
*--Make sure that a printer destination has been set up. If this is not done the PDF module abends.
*-- 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.
EXPORT it_final1 it_email p_email1 p_sender p_date vl_nmth
TO MEMORY ID 'MEM' .
IF report = 'zhr_pm_appandprogemail'.
SUBMIT zhr_pm_appandprogemail TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS mstr_print_parms
VIA SELECTION-SCREEN AND RETURN.
ENDIF.
IF report = 'zhr_pm_appemail'.
SUBMIT zhr_pm_appemail TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS mstr_print_parms
VIA SELECTION-SCREEN AND RETURN.
ENDIF.
ENDIF.
*Find out what the spool number is that was just created
perform get_spool_number using p_repid p_uname changing mi_rqident.
*converting the spool request into 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 = 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.
* call function 'DOWNLOAD'
* exporting
* bin_filesize = mi_bytecount
* filename = mc_filename
* filetype = 'BIN'
* importing
* act_filename = mc_filename
* tables
* data_tab = it_mess_att.
CHECK sy-subrc = 0.
* Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf INTO wa_pdf.
TRANSLATE wa_pdf USING ' ~'.
CONCATENATE v_gd_buffer wa_pdf INTO v_gd_buffer.
CLEAR wa_pdf .
ENDLOOP.
TRANSLATE v_gd_buffer USING '~ '.
DO.
it_mess_att = v_gd_buffer.
APPEND it_mess_att.
SHIFT v_gd_buffer LEFT BY 255 PLACES.
IF v_gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " CREATE_PDF
* FORM get_spool_nunber *
* Get the most recent spool created by user/report *
form get_spool_number using f_repid
f_uname changing f_rqident.
data:
lc_rq2name TYPE rlgrap-filename.
concatenate f_repid+0(6)
f_repid+7(3)
f_uname+0(3)
into lc_rq2name.
* separated by '_'.
translate lc_rq2name to upper case.
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
*& Form SEND_MAIL
FORM send_email USING p_email subject.
REFRESH it_mess_bod.
* Default subject matter
gd_subject = text-019 ."'Subject'.
gd_attachment_desc = text-020 ."'Performance Appraisal'.
IF subject = 'Performance Appraisals and Progression I'.
gd_attachment_desc = 'PerfAppAndProg'.
ENDIF.
IF subject = 'Performance Appraisals'.
gd_attachment_desc = 'PerfAppraisal'.
ENDIF.
* 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 .pdf
PERFORM send_file_as_email_attachment
TABLES it_mess_bod
it_mess_att
USING p_email
subject
'PDF'
gd_attachment_desc
gd_attachment_desc
p_sender
gd_sender_type
CHANGING gd_error
gd_reciever.
ENDFORM. " SEND_MAIL
* FORM process_email *
FORM process_email using subject.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1 subject.
* perform send_email using p_email2.
ENDFORM. "process_email
*& 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.
CLEAR : ld_email , ld_mtitle , ld_format , ld_attdescription ,
ld_attfilename , ld_sender_address , ld_sender_address_type ,
w_doc_data.
REFRESH: t_packing_list.
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.
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.
LOOP AT it_email.
* Add the recipients email address
t_receivers-receiver = it_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
ENDLOOP.
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_HEX = 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.
IF sy-subrc = 0.
PERFORM update_infotype_0019 .
ENDIF.
* Populate zerror return code
* ld_error = sy-subrc.
** stop .
* READ TABLE t_receivers WITH KEY retrn_code = '0' .
* IF sy-subrc = 0 .
* v_update_flag = '1' .
* EXPORT v_update_flag TO MEMORY ID 'MEM2' .
* ENDIF .
** Populate zreceiver return code
* LOOP AT t_receivers.
* ld_receiver = t_receivers-retrn_code.
* ENDLOOP.
ENDFORM. "send_file_as_email_attachment
*& Form GET_NEXT_MONTH
FORM get_next_month .
CLEAR v_month .
v_month = vl_nmth+4(2).
REFRESH it_t247 .
CLEAR it_t247 .
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
langu = 'E'
month = v_month
IMPORTING
t247 = it_t247.
CLEAR v_mon_text .
v_mon_text = it_t247-ltx .
ENDFORM. " GET_NEXT_MONTH
Edited by: Katie Doody on Feb 24, 2010 12:30 AMThank you for your response, this has allowed me to identify the problem. It is when I create the spool by using the code below. If I add a wait after this, the program works successfully. Is there another way to write the data to create a spool within my initial program rather than doing the submit? Could it be that it is putting data in memory?
SUBMIT zhr_pm_appandprogemail TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS mstr_print_parms
VIA SELECTION-SCREEN AND RETURN.
*& Report ZHR_PM_APPANDPROGEMAIL
REPORT ZHR_PM_APPANDPROGEMAIL
NO STANDARD PAGE HEADING
LINE-SIZE 80
LINE-COUNT 65(8).
* MESSAGE-ID zhr.
* INTERNAL TABLES DECLARATION
DATA: it_pdf TYPE tline OCCURS 0 ." WITH HEADER LINE .
* WORK AEA DECLARATION
DATA: wa_pdf TYPE tline .
* Spool to PDF conversions
*DATA: "gd_spool_nr TYPE tsp01-rqident,
* gd_destination TYPE rlgrap-filename,
* gd_bytecount TYPE tst01-dsize,
DATA:v_update_flag TYPE c . "flag for updating infotype 41 last appraisal date
DATA: v_gd_buffer TYPE string.
DATA: BEGIN OF it_final1 OCCURS 0 ,
supervisor TYPE persno ,
pernr TYPE persno ,
ename TYPE pa0001-ename ,
subgroup TYPE persk ,
stext TYPE t503t-ptext ,
lastapp TYPE dats ,
lastjob TYPE dats ,
email TYPE ztype,
darxx(5) TYPE c,
progression(1) TYPE c,
supervisor_desc(50) TYPE c,
END OF it_final1 .
DATA: t_packing_list TYPE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents TYPE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers TYPE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment TYPE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header TYPE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data TYPE sodocchgi1 .
DATA: gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: v_flag TYPE c VALUE '1' .
DATA: BEGIN OF it_final OCCURS 0 ,
subgroup TYPE persk ,
supervisor TYPE persno ,
pernr TYPE persno ,
ename TYPE pa0001-ename ,
stext TYPE t503t-ptext ,
lastapp TYPE dats ,
lastjob TYPE dats ,
email TYPE ztype,
progression(1) TYPE c,
supervisor_desc(50) TYPE c,
END OF it_final .
DATA:it_t247 TYPE STANDARD TABLE OF t247 WITH HEADER LINE .
DATA: it_email TYPE STANDARD TABLE OF zemail WITH HEADER LINE.
*VARIABLE DECLARATION
DATA: p_date TYPE sy-datum , "excution date
vl_date TYPE sy-datum ,
p_email1 TYPE somlreci1-receiver , "receiver
p_sender TYPE somlreci1-receiver . "sender
DATA: w_recsize TYPE i.
DATA: gd_recsize TYPE i.
DATA : vl_nmth TYPE sy-datum.
DATA: v_month(2) TYPE n .
DATA: v_mon_text TYPE t247-ltx .
*START OF SELECTION
START-OF-SELECTION .
REFRESH t_receivers.
IMPORT it_final1 it_email p_email1 p_sender p_date vl_nmth FROM MEMORY ID 'MEM'.
PERFORM get_next_month .
LOOP AT it_final1 .
IF it_final1-progression IS NOT INITIAL.
MOVE-CORRESPONDING it_final1 TO it_final .
APPEND it_final .
CLEAR it_final .
* Add the recipients email address
t_receivers-receiver = it_final1-email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
ENDIF.
ENDLOOP .
PERFORM write_output .
*END OF SELECTION
END-OF-SELECTION .
*& Form WRITE_OUTPUT
FORM write_output .
DATA: l_date(14) TYPE c ,
l_date_temp(14) TYPE c ,
v_date(10) TYPE c ,
v_date1(20) TYPE c ,
v_date1_temp(20) TYPE c ,
f_date(10) TYPE c.
DATA: lv_stext TYPE t503t-ptext .
CLEAR : v_date, v_date1.
CONCATENATE p_date+4(02) p_date+6(02) p_date+0(04)'.' INTO v_date.
CONCATENATE v_mon_text p_date+0(4) INTO l_date_temp SEPARATED BY space.
CONCATENATE l_date_temp '.' INTO l_date.
CONCATENATE v_mon_text vl_nmth+6(2) INTO v_date1_temp SEPARATED BY space.
CONCATENATE v_date1_temp ',' INTO v_date1_temp.
CONCATENATE v_date1_temp vl_nmth(4) INTO v_date1_temp SEPARATED BY space.
CONCATENATE v_date1_temp '.' INTO v_date1.
CONDENSE l_date .
FORMAT INTENSIFIED ON.
SKIP 4.
WRITE:/(80) text-001 CENTERED . "'METROPOLITAN UTILITIES DISTRICT'.
WRITE:/(80) text-002 CENTERED . "'OMAHA NEBR.'.
SKIP 2.
WRITE:/(80) text-003 CENTERED . "'Inter-Departmental Communication'.
FORMAT INTENSIFIED OFF.
WRITE :/(80) v_date CENTERED using edit mask '__/__/____'. " v_date.
SKIP 2.
WRITE: /10 text-004. "'SUBJECT: Performance Appraisals and Progression Increase'.
SKIP 1.
WRITE: /10 text-005, it_final1-supervisor_desc. "'TO: Supervisor'.
SKIP 1.
WRITE: /10 text-006. "'FROM: Anne M. Undajon, Director of Compensation and Benefits'.
SKIP 2.
WRITE:/10 text-007 . "'Listed below are the employees in your area who are due a '.
WRITE:/10 text-008 ,l_date. "'Performance Appraisal during the month of ',l_date.'. "v_mon_text , P_date+0(4)
WRITE:/10 text-009 . "'These employees are also eligible for a progression increase.
WRITE:/10 text-010 . "' A performance appraisal form can be found on-line in the MUD '.
WRITE:/10 text-011 . "'template section. The Performance Appraisal is to be completed '
WRITE:/10 text-012 . "'and discussed with the employee by the immediate supervisor.'
SKIP 2.
WRITE:/10 text-013. "Signed forms should be returned to the Human Resource Department by '.
WRITE:/10 v_date1.
SKIP 2 .
SORT it_final[] BY subgroup .
LOOP AT it_final .
CLEAR: lv_stext .
lv_stext = it_final-stext.
AT NEW subgroup .
TRANSLATE lv_stext TO UPPER CASE .
WRITE:/(80) lv_stext CENTERED .
SKIP 2 .
WRITE: 10 text-014 . "'Employee name' .
WRITE: 32 text-015 . "'Job Date' .
WRITE :44 text-016 . "'Last Appraisal' .
WRITE :59 text-021 . "'Employee' .
WRITE :/10 '--------------------' , 32'----------', 44 '--------------', 59 '--------'.
ENDAT .
WRITE:/10 it_final-ename .
WRITE: 32 it_final-lastjob using edit mask '__/__/____'.
CONCATENATE it_final-lastapp+4(02) it_final-lastapp+6(02) it_final-lastapp+0(04) INTO f_date.
WRITE :44 f_date using edit mask '__/__/____'.
SHIFT it_final-pernr left deleting leading '0'.
WRITE : 59 it_final-pernr.
SKIP 2 .
ENDLOOP.
SKIP 4.
WRITE :10 text-017. "'Anne M. Undajon'.
FORMAT INTENSIFIED ON.
WRITE:/10 text-018. "'Director of Compensation & Benefits'.
FORMAT INTENSIFIED OFF.
ENDFORM. " WRITE_OUTPUT
*& Form GET_NEXT_MONTH
FORM get_next_month .
CLEAR v_month .
v_month = vl_nmth+4(2).
REFRESH it_t247 .
CLEAR it_t247 .
CALL FUNCTION 'IDWT_READ_MONTH_TEXT'
EXPORTING
langu = 'E'
month = v_month
IMPORTING
t247 = it_t247.
CLEAR v_mon_text .
v_mon_text = it_t247-ltx .
ENDFORM. " GET_NEXT_MONTH
Edited by: Katie Doody on Feb 24, 2010 4:07 PM -
Spool to PDF Conversion in ECC6 from Report running in Background
Hi Friends,
Iam working in ECC6, I have created one Classical report with line size of 295 which is running in Background and spool is generating.
But my requirement is I have to send this spool to email through PDF Attachment.
Here i have to convert Spool of line size 295 to PDF format. and then using FM give mail to respective email ids.
Here is the code i have written for your refference:
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
endif.
1. 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. " G
2. 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. " OBTAIN_SPO
3. CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
dst_device = 'ZLOCL'
PDF_DESTINATION = 'X'
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. " CONVERT_SPOOL_TO_PDF
4. FORM PROCESS_EMAIL .
DESCRIBE TABLE it_mess_att LINES gd_recsize.
*DESCRIBE TABLE it_pdf_output LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
ENDFORM. " P
5. 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 = 'Attachnament'.
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 PDF format
PERFORM send_file_as_email_attachment
TABLES it_mess_bod
it_mess_att
it_pdf_output
USING p_email1
'PDF Document Attached'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
CHANGING gd_error
gd_reciever.
ENDFORM. " SEND_EMAIL
6. 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,
send_mail LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1.
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.
LOOP AT p_email1.
t_receivers-receiver = p_email1-low.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
ENDLOOP.
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. " SEND_FILE_AS_EMAIL_ATTACHMENT
But when iam executing the report in Background mail is coming to respective email ids but when i opened that attachment which is in PDF is not opening, giving error as below:
"Could not parsed Attachment.PDF!"
and file size is less oringinallly file size should be 125 KB buit in mail it is coming only 3 KB.
When i executed FM CONVERT_ABAPSPOOLJOB_2_PDF in foreground, its working fine for that Spool id.
Any suggestions from u friends.
regards,
Sekhar.Hi when ur running tha application in background pass the below parameters .
DATA:
w_form_name TYPE tdsfname VALUE 'Zpramu_TEST',
w_fmodule TYPE rs38l_fnam,
w_cparam TYPE ssfctrlop,
w_outoptions TYPE ssfcompop,
W_bin_filesize TYPE i, " Binary File Size
w_FILE_NAME type string,
w_File_path type string,
w_FULL_PATH type string.
Internal tables declaration
Internal table to hold the OTF data
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
Internal table to hold OTF data recd from the SMARTFORM
t_otf_from_fm TYPE ssfcrescl,
Internal table to hold the data from the FM CONVERT_OTF
T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
This function module call is used to retrieve the name of the Function
module generated when the SMARTFORM is activated
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_form_name
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = w_fmodule
EXCEPTIONS
no_form = 1
no_function_module = 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.
Calling the SMARTFORM using the function module retrieved above
GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
format of the output
w_cparam-no_dialog = 'X'.
w_cparam-preview = space. " Suppressing the dialog box
" for print preview
w_cparam-getotf = 'X'.
Printer name to be used is provided in the export parameter
OUTPUT_OPTIONS
w_outoptions-tddest = 'LP01'.
CALL FUNCTION w_fmodule
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = w_cparam
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
output_options = w_outoptions
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = t_otf_from_fm
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 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.
t_otf[] = t_otf_from_fm-otfdata[].
Function Module CONVERT_OTF is used to convert the OTF format to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = W_bin_filesize
BIN_FILE =
TABLES
otf = T_OTF
lines = T_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.
To display File SAVE dialog window
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 = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_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.
Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_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'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = T_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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Problem in converting spool to pdf
Hi Experts,
I want an internal table to be converted to the PDF. For this RSPO_OPEN_SPOOLREQUEST, RSPO_WRITE_SPOOLREQUEST and RSPO_CLOSE_SPOOLREQUEST to create the spool. However, somehow the table tsp01 does not gets updated as a result i could not convert the data to PDF. Can any one help me how this problem could be solved.
Thank.
Warm Regards,
Harshad.Hi,
you can refer this sample code.
DATA: t_otfdata_tab LIKE ITCOO OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'CLOSE_FORM'
TABLES
OTFDATA = t_otfdata_tab
fill the exceptions..
IF SY-SUBRC = 0.
ENDIF.
then pass the t_otfdata_tab to this function module..
CONSTANTS: c_pdf(03) VALUE 'PDF'.
PDF File size
DATA: w_file_size TYPE I.
Internal Table to hold Form contents in PDF format
DATA: t_pdfdata_tab LIKE tline OCCURS 0 WITH HEADER LINE.
for converting. the output format from OTF to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT eq c_pdf
IMPORTING
BIN_FILESIZE = w_file_size
TABLES
OTF eq t_otfdata_tab
LINES eq t_pdfdata_tab
EXCEPTIONS...
use these links, hope it will be useful to you....
Problem in converting spool to PDF file
Problem in converting the spool to PDF.
Thanks and Regards,
Ahamed. -
Problem in converting spool to PDF file
Hi guys,
My spool contains Russian characters which are shown as one special char in pdf file. I guess the russian char. are not recognized by pdf.
I convert the spool to pdf using following FM
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = wa_spool-spool
no_dialog = ' '
IMPORTING
pdf_bytecount = v_numbytes
pdf_spoolid = v_pdfspoolid
btc_jobname = v_jobname
btc_jobcount = v_jobcount
TABLES
pdf = pdf.
Then i download the file using FM:
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
bin_filesize = v_numbytes
filename = v_return1
filetype = 'BIN'
TABLES
data_tab = pdf
Help me....
Point will be rewarded on helpful answers.
Regards,
GURUHI
use my code
it will do the entire job
*& Report Z8VM_SPOOL2PDF *
report z8vm_spool2pdf .
**---- Author : vivekanand meghmala
**---- Purpose : Create Single PDF file with outputs of
**---- Multiple Spools.
**---- Create Date: July 05th, 2006
**---- Analyst : Vivek Maheshwari
**---- Tables
tables : tsp01.
**---- Select Options for Multiple spools
select-options :
s_spool for tsp01-rqident obligatory.
**---- Parameters for File Path.
parameters :
p_file type localfile default 'C:combined.pdf' obligatory.
**---- Get the Spool Requests entered in Select-options for Spools.
data : i_tsp01 like tsp01 occurs 0 with header line.
**---- Work Areas and Variables
data: wa_eof type soli, "----- End of File Work Area
v_file type string, "----- String
v_size type i, "----- Size
v_lines type i. "----- Lines in Internal Table
**---- Internal Table for Spool Details and PDF and Document Details
data : i_spool_table type table of soli,
i_spool_total type table of soli with header line,
i_otf type table of itcoo with header line,
i_doc like table of docs,
i_pdf like table of tline.
**---- Move File name to Variable
v_file = p_file.
**---- Clear and Refresh Internal Tables before first use
clear i_tsp01. refresh i_tsp01.
clear i_spool_table. refresh i_spool_table.
clear i_spool_total. refresh i_spool_total.
**---- Get Spool ID Details from TSP01
select * from tsp01 into table i_tsp01 where rqident in s_spool.
**---- Sort Table in Ascending order based on Spool Id
sort i_tsp01 by rqident.
**---- Get information about Multiple spools
loop at i_tsp01.
**---- Get Multiple Spool information
call function 'RSPO_RETURN_SPOOLJOB'
exporting
rqident = i_tsp01-rqident
tables
buffer = i_spool_table
exceptions
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
others = 8.
if sy-subrc = 0.
endif.
**---- Get the Last line index (Number of Lines)
describe table i_spool_table lines v_lines.
**---- Clear Work Area for End of File (EOF) and read
**---- End of File String into it and Delete it
clear wa_eof.
read table i_spool_table index v_lines into wa_eof.
delete i_spool_table index v_lines.
**---- Collect All individual Spool Details into one internal table.
append lines of i_spool_table to i_spool_total.
at last.
**---- Append End of File information to Internal table
**---- Containing information about all the invidual spools -
**---- Thus forming one single spool
append wa_eof to i_spool_total.
endat.
endloop.
**---- Clear OTF tables before initial use
clear i_otf. refresh i_otf.
**---- Fill in the OTF internal table
loop at i_spool_total.
clear i_otf.
i_otf = i_spool_total.
append i_otf.
endloop.
**---- Convert the OTF information to PDF.
call function 'CONVERT_OTF_2_PDF'
exporting
use_otf_mc_cmd = 'X'
importing
bin_filesize = v_size
tables
otf = i_otf
doctab_archive = i_doc
lines = i_pdf
exceptions
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
others = 3.
if sy-subrc <> 0.
message i002(sy) with 'Cannot convert to PDF, exiting....'.
leave program.
endif.
**---- Download PDF file thus formed onto frontend
call method cl_gui_frontend_services=>gui_download
exporting
filename = v_file
filetype = 'BIN'
changing
data_tab = i_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
not_supported_by_gui = 22
error_no_gui = 23
others = 24.
if sy-subrc <> 0.
message i002(sy) with 'Cannot download PDF, exiting....'.
leave program.
endif. -
Convert spool to PDF and send as email attachment
When i try to convert SAP spool to PDF and send it as email attachment, size of PDF document becomes large as compared to size of the PDF cocument i download using the same spool.
I am using following FMs.
CONVERT_ABAPSPOOLJOB_2_PDF to convert spool to PDF
and
SO_NEW_DOCUMENT_ATT_SEND_API1 to send email with attchment.
some times size of attchment exceeds 2MB and email results in error in SAP connect (SOST).
Any idea on how to compress the PDF attchment??
ThanksHi Venkat,
Can you plesae assist me.
I have a requirement to convert spool to pdf
send an email to users
issue is that attachement is big cant go through
I have used compress, but when I open the pdf file error that file was not correclty decoded
please assist, anyone -
Send spool as PDF, error in opening PDF- Could not find the XObject '00014'
Hi
I am sendind a spool as PDF and when opening the PDF I am getting error saying Could not find the XObject named 00014.
Please let me know how I can see the PDF contents proerly.
Regards
BalaHi Bala
Check the sample which can be useful for you.
Pseudo code for sending PDF attachment:
TABLES: tsp01.
TYPES: BEGIN OF t_spool,
Rqident TYPE tsp01-rqident,
END OF t_spool.
DATA: i_spool TYPE STANDARD TABLE OF t_spool,
Wa_spool TYPE t_spool.
SELECT rqident FROM tsp01
INTO TABLE i_spool
WHERE rqowner = sy-uname.
SORT i_spool DESCENDING BY rqident.
LOOP AT i_spool INTO wa_spool.
ENDLOOP.
YPES: l_ty_tab_pdf TYPE tline OCCURS 0.
DATA: l_pdf TYPE l_ty_tab_pdf,
l_spool TYPE tsp01-rqident.
Type for binary attachment table.
TYPES: l_ty_tab_objbin TYPE solisti1 OCCURS 0.
DATA: l_objbin TYPE l_ty_tab_objbin.
l_spool = wa_spool-rqident.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = l_spool
no_dialog = ' '
TABLES
pdf = l_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.
WRITE: / 'error', sy-subrc.
ENDIF.
**/ Convert the PDF format to the table type required for the attachment.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = l_pdf
t_target_tab = l_objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE: / 'error', sy-subrc.
ENDIF.
TABLES: soli.
DATA: v_email TYPE soli-line. Managers Email
DATA: l_adrnr LIKE kna1-adrnr. Address Number
DATA: l_objky TYPE nast-objky. Object Key
DATA: l_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
DATA: l_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: l_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
DATA: l_doc_chng LIKE sodocchgi1.
DATA: l_objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: l_tab_lines LIKE sy-tabix.
CONSTANTS: k_true TYPE boolean_flg VALUE 'X'.
DATA: l_mail TYPE somlreci1-receiver.
l_mail = v_email.
Creation of the document to be sent as File Name
l_doc_chng-obj_name = 'SENDFILE'.
Mail Subject
l_doc_chng-obj_descr =l_text-001.
Here text-001 will contains Compensation Review Statement for Employee Name
Here we can concatenate employee first name and last name to l_text-001.
Completing the recipient list
l_reclist-receiver = l_mail. Manager Email Address
l_reclist-rec_type = 'U'.
APPEND l_reclist.
Mail Contents
l_objtxt = text-002.
APPEND l_objtxt.
Calculate email size in bytes
DESCRIBE TABLE l_objtxt LINES l_tab_lines.
READ TABLE l_objtxt INDEX l_tab_lines.
l_doc_chng-doc_size = (l_tab_lines - 1 ) * 255 + STRLEN( l_objtxt ).
Creation of the entry for the compressed document for the email text
CLEAR l_objpack-transf_bin.
l_objpack-head_start = 1.
l_objpack-head_num = 0.
l_objpack-body_start = 1.
l_objpack-body_num = l_tab_lines.
l_objpack-doc_type = 'RAW'.
APPEND l_objpack.
Creation of the document attachment
(Assume that the data in OBJBIN is in BMP format)
DESCRIBE TABLE l_objbin LINES l_tab_lines.
l_objhead = text-001.
APPEND l_objhead.
CLEAR l_objpack.
Creation of the entry for the compressed/attached document
l_objpack-transf_bin = k_true.
l_objpack-head_start = 1.
l_objpack-head_num = 1.
l_objpack-body_start = 1.
l_objpack-body_num = l_tab_lines.
l_objpack-doc_type = 'PDF'.
l_objpack-obj_name = text-005.
l_objpack-obj_descr = text-001.
l_objpack-doc_size = l_tab_lines * 255.
APPEND l_objpack. "/ .
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = l_doc_chng
put_in_outbox = 'X'
TABLES
packing_list = l_objpack
object_header = l_objhead
contents_bin = l_objbin
contents_txt = l_objtxt
receivers = l_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
WRITE: / 'unsuccessful', sy-subrc.
ELSE.
WRITE: / 'successful'.
ENDIF.
*Take note it is a requirement to do a commit work for the email to go into transaction
SOST.
COMMIT WORK.
Regards,
Sree -
Conversion of spool to pdf format in landscape mode
Hi All,
I have a requirement where I need to print the output from a spool request in SAP to a pdf page .
The page has to be in landscape format. Is it possible to create a pdf page which is always in landscape format?
I am using FM convert abapspool 2pdf for conversion of spool to pdf.
Does this require any setting from BASIS end?
Any ideas/thoughts are welcome..
Thanks -
Harmeet Singh.hi 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,
p_sender LIKE somlreci1-receiver,
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 appikonda -
Convert Screen(spool) to PDF file sending mail with attach file
Hi :
I'd like convert spool list to pdf and sending file...
so, I read thread about spool convert to PDF before,
and know how to convert Spool to PDF file and send mail with attach file.
but I have a problem.
my solution as:
step 1. Call function: "CONVERT_ABAPSPOOLJOB_2_PDF"
step 2. Call function: "SO_NEW_DOCUMENT_ATT_SEND_API1"
then, I got a mail with attached PDF file, but the PDF file display limited 255 line.( SO_NEW_DOCUMENT_ATT_SEND_API1 limited)
I want to showing word is wider that 255.
and then I find a manual method as:
After program finished.
Function Menu -> system -> List -> Send
use Prog: "Create Document and Send"
I use this prog sending mail and attached file ,
PDF file do <b>NOT</b> have 255 word limit !
finally. my question is, If I want sending mail as Prog: "Create Document and Send", how to do?
which Function I have to use?...
Please help me, Thanks!Hi,
Check this sample code of sending spool as attachment to an email address..
Parameters.
PARAMETERS: p_email(50) LOWER CASE.
PARAMETERS: p_spool LIKE tsp01-rqident.
Data declarations.
DATA: plist LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: document_data LIKE sodocchgi1.
DATA: so_ali LIKE soli OCCURS 100 WITH HEADER LINE.
DATA: real_type LIKE soodk-objtp.
DATA: sp_lang LIKE tst01-dlang.
DATA: line_size TYPE i VALUE 255.
DATA: v_name LIKE soextreci1-receiver.
DATA rec_tab LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
Get the spool data.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = p_spool
first_line = 1
last_line = 0
desired_type = ' '
IMPORTING
real_type = real_type
sp_lang = sp_lang
TABLES
buffer = so_ali
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'Error'.
LEAVE LIST-PROCESSING.
ENDIF.
Prepare the data.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 0.
plist-body_num = 0.
plist-doc_type = 'RAW'.
plist-obj_descr = 'Test ALV'.
APPEND plist.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 1.
DESCRIBE TABLE so_ali LINES plist-body_num.
plist-doc_type = real_type.
Get the size.
READ TABLE so_ali INDEX plist-body_num.
plist-doc_size = ( plist-body_num - 1 ) * line_size
+ STRLEN( so_ali ).
APPEND plist.
Move the receiver address.
MOVE: p_email TO rec_tab-receiver,
'U' TO rec_tab-rec_type.
APPEND rec_tab.
IF NOT sp_lang IS INITIAL.
document_data-obj_langu = sp_lang.
ELSE.
document_data-obj_langu = sy-langu.
ENDIF.
v_name = sy-uname.
Send the email.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = document_data
sender_address = v_name
sender_address_type = 'B'
TABLES
packing_list = plist
contents_bin = so_ali
receivers = rec_tab
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.
IF sy-subrc <> 0.
MESSAGE e208(00) WITH 'Error'.
ENDIF.
COMMIT WORK.
Send the email immediately.
SUBMIT rsconn01
WITH mode = 'INT'
AND RETURN.
Thanks,
Naren -
Hi,
How can i convert a spool into a pdf format and fill the atributes of the PDF document with title, author, subject and keywords from abap?
Kind regards,
H. HendriksCheck the Below code ......
REPORT ZMAILOUTPUT
MESSAGE-ID ZZ.
* CONSTANTS *
CONSTANTS : C_X(1) TYPE C VALUE 'X', " For constant value
C_OTF(3) TYPE C VALUE 'OTF', " For format
C_U(1) TYPE C VALUE 'U'. " Mail Option
* VARIABLES *
DATA : V_RQIDENT TYPE TSP01-RQIDENT, " For Spool Number
V_RQCLIENT TYPE TSP01-RQCLIENT, " For Client
V_RQO1NAME TYPE TSP01-RQO1NAME, " For Object name
V_SPOOL TYPE TSP01-RQIDENT, " For Spool Number
V_SPOOL1 TYPE TSP01-RQIDENT. " For Spool Number
* FLAGS *
DATA : F_SPOOL TYPE C.
* INTERNAL TABLES *
* Internal table for sending mails
DATA: IT_PDF LIKE TLINE OCCURS 10 WITH HEADER LINE,
IT_XI_PDF LIKE TLINE OCCURS 0 WITH HEADER LINE,
IT_HTML LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
IT_XI_TEMP LIKE BAPIQCMIME OCCURS 0 WITH HEADER LINE,
IT_XI_MIME(255) TYPE C OCCURS 0 WITH HEADER LINE.
* For sending mail
DATA: IT_OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
* Internal table for Single List with Column Length 255
DATA : IT_OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
* Internal table for Single List with Column Length 255
DATA : IT_OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
* Internal table for Structure of the API Recipient List
DATA : IT_RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
* Structure of the API Recipient List
DATA: X_DOC_CHNG LIKE SODOCCHGI1.
* Internal table for storing the variants
DATA : BEGIN OF IT_VARIANT1 OCCURS 0,
VARIANT LIKE VARID-VARIANT,
END OF IT_VARIANT1.
* Internal table to store variants for the programs
DATA: IT_VARIANT2 LIKE IT_VARIANT1 OCCURS 0 WITH HEADER LINE.
* Internal table for storing the selected values
DATA IT_RETURN TYPE DDSHRETVAL OCCURS 0 WITH HEADER LINE.
* Internal table for storing the mail-ids
DATA : BEGIN OF IT_MAILID OCCURS 0,
KOKRS LIKE CSKS-KOKRS,
KOSTL LIKE CSKS-KOSTL,
DATBI LIKE CSKS-DATBI,
TELX1 LIKE CSKS-TELX1,
END OF IT_MAILID.
* Internal table for storing the mail-ids
DATA : IT_MAILID1 LIKE IT_MAILID OCCURS 0 WITH HEADER LINE.
* SELECTION SCREEN *
DATA : V_CHAR TYPE CHAR50.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_EMAIL FOR V_CHAR NO INTERVALS
LOWER CASE
NO-DISPLAY.
SELECT-OPTIONS: S_EMAIL1 FOR V_CHAR NO INTERVALS
LOWER CASE
NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-028.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : P_C1 AS CHECKBOX.
SELECTION-SCREEN COMMENT 3(66) TEXT-026 FOR FIELD P_C1.
SELECTION-SCREEN END OF LINE.
PARAMETERS : P_SET LIKE TSP1D-PAPART MATCHCODE OBJECT ZH_TSP1D.
SELECTION-SCREEN SKIP 1.
PARAMETERS : P_VARA1 TYPE RS38M-SELSET.
SELECTION-SCREEN END OF BLOCK A1.
SELECTION-SCREEN BEGIN OF BLOCK A2 WITH FRAME TITLE TEXT-029.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : P_C2 AS CHECKBOX.
SELECTION-SCREEN COMMENT 3(56) TEXT-027 FOR FIELD P_C1.
SELECTION-SCREEN END OF LINE.
PARAMETERS : P_SET1 LIKE TSP1D-PAPART MATCHCODE OBJECT ZH_TSP1D.
SELECTION-SCREEN SKIP 1.
PARAMETERS : P_VARA2 TYPE RS38M-SELSET.
SELECTION-SCREEN END OF BLOCK A2.
* AT SELECTION SCREEN ON VALUE REQUEST
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARA1.
* For fetching the variants available for the program
PERFORM FETCH_VARIANTS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARA2.
* For fetching the variants available for the program
PERFORM FETCH_VARIANTS1.
* AT SELECTION SCREEN
AT SELECTION-SCREEN.
* For Validation
PERFORM VALIDATION.
* START OF SELECTION *
START-OF-SELECTION.
* To get the output data and mail
PERFORM FETCH_DATA.
* END OF SELECTION *
END-OF-SELECTION.
IF F_SPOOL = C_X.
MESSAGE E000 WITH 'Spool Not Generated'(060).
ENDIF.
*& Form fetch_data
* To get the output data and mail
FORM FETCH_DATA .
* To send the output to spool
PERFORM GENERATE_SPOOL.
ENDFORM. " fetch_data
*& Form generate_spool
* To send the output to spool
FORM GENERATE_SPOOL .
DATA: L_PARAMS LIKE PRI_PARAMS,
L_DAYS(1) TYPE N VALUE 2,
L_COUNT(3) TYPE N VALUE 1,
L_VALID TYPE C,
L_VALID1 TYPE C,
L_PARAMS1 LIKE PRI_PARAMS.
DATA: L_DEVICE TYPE USR01-SPLD.
*Get the printer name for the user
SELECT SINGLE SPLD INTO L_DEVICE FROM USR01 WHERE BNAME = SY-UNAME.
IF L_DEVICE IS INITIAL.
L_DEVICE = 'LOCL'.
ENDIF.
* For report-1
IF P_C1 = 'X'.
* Setting the print parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
DESTINATION = L_DEVICE
COPIES = L_COUNT
LIST_NAME = SY-UNAME
LIST_TEXT = 'SUBMIT ... TO SAP-SPOOL'(008)
RELEASE = C_X
NEW_LIST_ID = C_X
EXPIRATION = L_DAYS
* LINE_SIZE = 255
* LINE_COUNT = 65
LAYOUT = p_set
SAP_COVER_PAGE = SPACE
COVER_PAGE = SPACE
RECEIVER = 'SAP*'(010)
DEPARTMENT = 'System'(011)
NO_DIALOG = C_X
IMPORTING
OUT_PARAMETERS = L_PARAMS
VALID = L_VALID.
IF L_VALID <> SPACE.
CLEAR V_SPOOL.
* Fetch the spool number b4 submit
PERFORM FETCH_RECENT_SPOOL USING V_SPOOL.
* Submitting the program to spool
SUBMIT RKAEP000 TO SAP-SPOOL
USING SELECTION-SET P_VARA1
SPOOL PARAMETERS L_PARAMS
WITHOUT SPOOL DYNPRO
AND RETURN.
CLEAR V_SPOOL1.
* Fetch the spool number after submit
PERFORM FETCH_RECENT_SPOOL USING V_SPOOL1.
IF V_SPOOL = V_SPOOL1.
F_SPOOL = C_X.
IF P_C2 IS INITIAL.
STOP.
ENDIF.
ELSE.
* Checking the format ( ABAP/OTF)
PERFORM FORMAT_CHECK TABLES S_EMAIL.
ENDIF.
ELSE.
MESSAGE E000 WITH 'Problem in print settings'(003).
STOP.
ENDIF.
ENDIF.
* For Report-2
IF P_C2 = 'X'.
* Setting the print parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
DESTINATION = L_DEVICE
COPIES = L_COUNT
LIST_NAME = SY-UNAME
LIST_TEXT = 'SUBMIT ... TO SAP-SPOOL'(008)
RELEASE = C_X
NEW_LIST_ID = C_X
EXPIRATION = L_DAYS
* LINE_SIZE = 200
* LINE_COUNT = 65
LAYOUT = p_set1
SAP_COVER_PAGE = SPACE
COVER_PAGE = SPACE
RECEIVER = 'SAP*'(010)
DEPARTMENT = 'System'(011)
NO_DIALOG = C_X
IMPORTING
OUT_PARAMETERS = L_PARAMS1
VALID = L_VALID1.
IF L_VALID1 <> SPACE.
CLEAR V_SPOOL.
* Fetch the spool number b4 submit
PERFORM FETCH_RECENT_SPOOL USING V_SPOOL.
* Submitting the program to spool
SUBMIT GP3DIEHXY88SNFJ0391V7KF9EK7050 TO SAP-SPOOL
USING SELECTION-SET P_VARA2
SPOOL PARAMETERS L_PARAMS1
WITHOUT SPOOL DYNPRO
AND RETURN.
CLEAR V_SPOOL1.
* Fetch the spool number after submit
PERFORM FETCH_RECENT_SPOOL USING V_SPOOL1.
IF V_SPOOL = V_SPOOL1.
MESSAGE E000 WITH 'Spool Not Generated'(060).
STOP.
ENDIF.
* Checking the format ( ABAP/OTF)
PERFORM FORMAT_CHECK TABLES S_EMAIL1.
ELSE.
MESSAGE E000 WITH 'Problem in print settings'(003).
STOP.
ENDIF.
ENDIF.
ENDFORM. " generate_spool
*& Form fetch_recent_spool
* Fetch the recent spool number generated
FORM FETCH_RECENT_SPOOL USING P_V_SPOOL TYPE TSP01-RQIDENT .
DATA: L_USER LIKE TSP01-RQ2NAME.
CLEAR : V_RQIDENT,
V_RQCLIENT,
V_RQO1NAME.
L_USER = SY-UNAME.
* Get latest Spool No
SELECT SINGLE RQIDENT
RQCLIENT
RQO1NAME
INTO (V_RQIDENT , V_RQCLIENT , V_RQO1NAME)
FROM TSP01
WHERE RQCRETIME = ( SELECT MAX( RQCRETIME )
FROM TSP01
WHERE RQ2NAME EQ L_USER
AND RQFINAL EQ '.' ).
IF SY-SUBRC = 0 .
P_V_SPOOL = V_RQIDENT.
ENDIF.
ENDFORM. " fetch_recent_spool
*& Form format_check
* Checking the format ( ABAP/OTF)
FORM FORMAT_CHECK TABLES P_S_EMAIL STRUCTURE S_EMAIL.
DATA : L_OBJTYPE LIKE RSTSTYPE-TYPE.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
AUTHORITY = 'SP01'(019)
CLIENT = V_RQCLIENT
NAME = V_RQO1NAME
PART = 1
IMPORTING
OBJTYPE = L_OBJTYPE
EXCEPTIONS
FB_ERROR = 1
FB_RSTS_OTHER = 2
NO_OBJECT = 3
NO_PERMISSION = 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.
IF L_OBJTYPE(3) = C_OTF.
* Convert OTF Spool to PDF
PERFORM CONVERT_OTF2PDF TABLES P_S_EMAIL.
ELSE.
* Convert ABAP Spool to PDF
PERFORM CONVERT_ABAP2PDF TABLES P_S_EMAIL.
ENDIF.
ENDFORM. " format_check
*& Form convert_otf2pdf
* Convert OTF Spool to PDF
FORM CONVERT_OTF2PDF TABLES P_P_S_EMAIL STRUCTURE S_EMAIL .
CLEAR IT_PDF.
REFRESH IT_PDF.
DATA : L_BYTECOUNT TYPE I.
* Fn. to get the PDF format
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = V_RQIDENT
NO_DIALOG = 'X'
IMPORTING
PDF_BYTECOUNT = L_BYTECOUNT
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.
IF SY-SUBRC = 0.
* For page format
PERFORM PAGE_FORMAT TABLES P_P_S_EMAIL.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " convert_otf2pdf
*& Form convert_abap2pdf
* Convert ABAP Spool to PDF
FORM CONVERT_ABAP2PDF TABLES P_P_S_EMAIL STRUCTURE S_EMAIL.
CLEAR IT_PDF.
REFRESH IT_PDF.
DATA : L_BYTECOUNT TYPE I.
* Fn. to convert to PDF format
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = V_RQIDENT
NO_DIALOG = 'X'
IMPORTING
PDF_BYTECOUNT = L_BYTECOUNT
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.
IF SY-SUBRC = 0.
* For page formatting
PERFORM PAGE_FORMAT TABLES P_P_S_EMAIL.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " convert_abap2pdf
*& Form send_mail
* For sending mail
FORM SEND_MAIL TABLES MAIL STRUCTURE S_EMAIL .
* Structures and internal tables for the send data
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,
OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1,
TAB_LINES LIKE SY-TABIX.
* Data for the status output after sending
DATA: SENT_TO_ALL LIKE SONV-FLAG.
CLEAR: IT_RECLIST, IT_RECLIST[],
IT_OBJTXT , IT_OBJTXT[],
IT_OBJPACK, IT_OBJPACK[],
IT_OBJBIN , IT_OBJBIN[],X_DOC_CHNG.
LOOP AT IT_HTML.
OBJBIN-LINE = IT_HTML-LINE.
APPEND OBJBIN.
CLEAR OBJBIN.
ENDLOOP.
* Create the document which is to be sent
DOC_CHNG-OBJ_NAME = 'List'(012).
DOC_CHNG-OBJ_DESCR = 'Mail'(013).
* Heading
OBJTXT-LINE = 'Mail with pdf attachment'(014).
APPEND OBJTXT.
CLEAR OBJTXT.
* Size
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
* Fill the fields of the packing_list for the main document:
CLEAR OBJPACK-TRANSF_BIN.
* The document needs no header (head_num = 0)
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
* Body
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'(015).
APPEND OBJPACK.
* Create the attachment (the list itself)
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
* Fill the fields of the packing_list for the attachment:
OBJPACK-TRANSF_BIN = 'X'.
* Header
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
* Body
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'PDF'(016).
OBJPACK-OBJ_NAME = 'Attachment'(017).
OBJPACK-OBJ_DESCR = 'Mail with pdf Attachment'(018).
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
*-Fill the mail recipient list
LOOP AT MAIL.
RECLIST-RECEIVER = MAIL-LOW.
RECLIST-REC_TYPE = C_U.
APPEND RECLIST.
CLEAR: RECLIST,
MAIL.
ENDLOOP.
*-Send the document by calling the SAPoffice API1 module for sending
*-documents with attachments
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
PUT_IN_OUTBOX = C_X
COMMIT_WORK = C_X
IMPORTING
SENT_TO_ALL = SENT_TO_ALL
TABLES
PACKING_LIST = OBJPACK
OBJECT_HEADER = OBJHEAD
CONTENTS_BIN = OBJBIN
CONTENTS_TXT = OBJTXT
RECEIVERS = RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
CASE SY-SUBRC .
WHEN 0.
MESSAGE I000 WITH 'Mail has been sent successfully'(006).
WHEN OTHERS.
MESSAGE E000 WITH 'Problem in sending the mail'(023).
ENDCASE.
ENDFORM. " send_mail
*& Form page_format
* For page foramtting
FORM PAGE_FORMAT TABLES EMAIL STRUCTURE S_EMAIL .
DATA : L_LINES TYPE I,
L_TEMP(500) TYPE C,
L_OFFSET TYPE P,
L_LINESLEN(2) TYPE P,
L_MIMELEN(2) TYPE P,
L_TABIX LIKE SY-TABIX.
CLEAR : IT_XI_PDF,
IT_XI_TEMP.
REFRESH : IT_XI_PDF,
IT_XI_TEMP.
IT_XI_PDF[] = IT_PDF[].
* Reformat the line to 255 characters wide (--code from SAP--)
CLEAR: L_TEMP, L_OFFSET, IT_XI_TEMP.
DESCRIBE TABLE IT_XI_PDF LINES L_LINES.
DESCRIBE FIELD IT_XI_PDF LENGTH L_LINESLEN IN CHARACTER MODE.
DESCRIBE FIELD IT_XI_TEMP LENGTH L_MIMELEN IN CHARACTER MODE.
LOOP AT IT_XI_PDF.
L_TABIX = SY-TABIX.
MOVE IT_XI_PDF TO L_TEMP+L_OFFSET.
IF L_TABIX = L_LINES.
L_LINESLEN = STRLEN( IT_XI_PDF ).
ENDIF.
L_OFFSET = L_OFFSET + L_LINESLEN.
IF L_OFFSET GE L_MIMELEN.
CLEAR IT_XI_TEMP.
IT_XI_TEMP = L_TEMP(L_MIMELEN).
APPEND IT_XI_TEMP.
SHIFT L_TEMP BY L_MIMELEN PLACES.
L_OFFSET = L_OFFSET - L_MIMELEN.
ENDIF.
IF L_TABIX = L_LINES.
IF L_OFFSET GT 0.
CLEAR IT_XI_TEMP.
IT_XI_TEMP = L_TEMP(L_OFFSET).
APPEND IT_XI_TEMP.
ENDIF.
ENDIF.
ENDLOOP.
CLEAR : IT_XI_MIME,
IT_XI_MIME[].
LOOP AT IT_XI_TEMP.
IT_XI_MIME(255) = IT_XI_TEMP-LINE.
APPEND IT_XI_MIME.
CLEAR IT_XI_MIME.
ENDLOOP.
* Final Data
CLEAR : IT_HTML,
IT_HTML[].
IT_HTML[] = IT_XI_MIME[].
* For sending mail
PERFORM SEND_MAIL TABLES EMAIL.
ENDFORM. " page_format
*& Form fetch_variants
* For fetching the variants available for the program
FORM FETCH_VARIANTS .
DATA : L_PROGRAM LIKE RS38M-PROGRAMM VALUE 'RKAEP000',
L_VARA1 TYPE DFIES-FIELDNAME VALUE 'P_VARA1'.
CLEAR : IT_VARIANT1,
IT_VARIANT1[].
* Get variants
PERFORM GET_VARIANTS TABLES IT_VARIANT1
USING L_PROGRAM.
* F4 Help
IF NOT IT_VARIANT1[] IS INITIAL.
PERFORM GET_F4_HELP TABLES IT_VARIANT1
USING L_VARA1
CHANGING P_VARA1.
ELSE.
MESSAGE E000 WITH 'No variants available for report1'(054).
ENDIF.
ENDFORM. " fetch_variants
*& Form validation
* For Validation
FORM VALIDATION .
DATA : L_PRO1 LIKE RS38M-PROGRAMM VALUE 'RKAEP000',
L_PRO2 LIKE RS38M-PROGRAMM VALUE 'GP3DIEHXY88SNFJ0391V7KF9EK7050',
L_C1,
L_C2.
* If both check-box are unchecked
IF P_C1 IS INITIAL
AND P_C2 IS INITIAL.
MESSAGE E000 WITH 'Check any one check-box'(049).
ENDIF.
* If checked without varaint
IF NOT P_C1 IS INITIAL AND P_VARA1 IS INITIAL.
MESSAGE E000 WITH 'Please give any one of the variant for report1'(055).
ENDIF.
* If checked without varaint
IF NOT P_C2 IS INITIAL AND P_VARA2 IS INITIAL.
MESSAGE E000 WITH 'Please give any one of the variant for report2'(061).
ENDIF.
* Reading the variant and fetching the mail-ids
IF P_C1 = C_X.
L_C1 = '1'.
CLEAR : S_EMAIL,
S_EMAIL[].
PERFORM READ_VARIANTS TABLES IT_MAILID
S_EMAIL
USING P_VARA1
L_PRO1
L_C1.
IF S_EMAIL[] IS INITIAL.
MESSAGE E000 WITH 'No Id available for given Cost report1'(066).
ELSE.
SORT S_EMAIL BY LOW.
DELETE ADJACENT DUPLICATES FROM S_EMAIL COMPARING LOW.
ENDIF.
ENDIF.
* Reading the variant and fetching the mail-ids
IF P_C2 = C_X.
CLEAR : S_EMAIL1,
S_EMAIL1[].
L_C2 = '2'.
PERFORM READ_VARIANTS TABLES IT_MAILID1
S_EMAIL1
USING P_VARA2
L_PRO2
L_C2.
IF S_EMAIL1[] IS INITIAL.
MESSAGE E000 WITH 'No Id available for given Cost report2'(067).
ELSE.
SORT S_EMAIL1 BY LOW.
DELETE ADJACENT DUPLICATES FROM S_EMAIL1 COMPARING LOW.
ENDIF.
ENDIF.
ENDFORM. " validation
*& Form GET_VARIANTS
* Fetching Variants
FORM GET_VARIANTS TABLES P_IT_VARIANT STRUCTURE IT_VARIANT1
USING P_V_PROGRAM TYPE RS38M-PROGRAMM.
SELECT VARIANT
FROM VARID
INTO TABLE P_IT_VARIANT
WHERE REPORT = P_V_PROGRAM.
ENDFORM. " GET_VARIANTS
*& Form GET_F4_HELP
* text
FORM GET_F4_HELP TABLES P_IT_VARIANT1 STRUCTURE IT_VARIANT1
USING P_L_VARA1 LIKE DFIES-FIELDNAME
CHANGING P_P_VARA LIKE P_VARA1.
* Fn. for Pop-Up
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = P_L_VARA1
VALUE_ORG = 'S'
DISPLAY = ' '
TABLES
VALUE_TAB = P_IT_VARIANT1
RETURN_TAB = IT_RETURN
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
IF SY-SUBRC = 0.
P_P_VARA = IT_RETURN-FIELDVAL.
ELSE.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " GET_F4_HELP
*& Form FETCH_VARIANTS1
* text
FORM FETCH_VARIANTS1 .
DATA : V_PROGRAM1 LIKE RS38M-PROGRAMM VALUE 'GP3DIEHXY88SNFJ0391V7KF9EK7050',
L_VARA2 TYPE DFIES-FIELDNAME VALUE 'P_VARA2'.
CLEAR : IT_VARIANT2,
IT_VARIANT2[].
* Get Variants
PERFORM GET_VARIANTS TABLES IT_VARIANT2
USING V_PROGRAM1.
* F4 Help
IF NOT IT_VARIANT2[] IS INITIAL.
PERFORM GET_F4_HELP TABLES IT_VARIANT2
USING L_VARA2
CHANGING P_VARA2.
ELSE.
MESSAGE E000 WITH 'No variants available for report2'(050).
ENDIF.
ENDFORM. " FETCH_VARIANTS1
*& Form read_variants
* Reading the variant and fetching the mail-ids
FORM READ_VARIANTS TABLES P_IT_MAILID STRUCTURE IT_MAILID
P_S_EMAIL STRUCTURE S_EMAIL
USING P_P_VARA1 LIKE P_VARA1
P_L_PRO1 LIKE RS38M-PROGRAMM
P_L_C1 TYPE C.
DATA : L_TEMP(44),
IT_VALUTAB LIKE RSPARAMS OCCURS 0 WITH HEADER LINE.
RANGES : R_COCEN FOR CSKS-KOSTL.
* Function Module to get the variant contents
CALL FUNCTION 'RS_VARIANT_CONTENTS'
EXPORTING
REPORT = P_L_PRO1
VARIANT = P_P_VARA1
TABLES
VALUTAB = IT_VALUTAB
EXCEPTIONS
VARIANT_NON_EXISTENT = 1
VARIANT_OBSOLETE = 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.
CLEAR : R_COCEN,
R_COCEN[].
LOOP AT IT_VALUTAB WHERE SELNAME = 'KOSTL'
OR SELNAME = '_C-CCTR'.
* Getting the range of cost centers
IF IT_VALUTAB-OPTION = 'BT'.
R_COCEN-LOW = IT_VALUTAB-LOW.
* For Conversion Routine
PERFORM CONVERSION USING R_COCEN-LOW.
R_COCEN-HIGH = IT_VALUTAB-HIGH.
* For Conversion Routine
PERFORM CONVERSION USING R_COCEN-HIGH.
R_COCEN-OPTION = 'BT'.
R_COCEN-SIGN = 'I'.
APPEND R_COCEN.
CLEAR R_COCEN.
ENDIF.
* Getting the single cost centers
IF IT_VALUTAB-OPTION = 'EQ'.
R_COCEN-LOW = IT_VALUTAB-LOW.
* For Conversion Routine
PERFORM CONVERSION USING R_COCEN-LOW.
R_COCEN-OPTION = 'EQ'.
R_COCEN-SIGN = 'I'.
APPEND R_COCEN.
CLEAR R_COCEN.
ENDIF.
ENDLOOP.
* If no cost centers
IF NOT R_COCEN[] IS INITIAL.
SELECT KOKRS
KOSTL
DATBI
TELX1
FROM CSKS
INTO TABLE P_IT_MAILID
WHERE KOSTL IN R_COCEN.
IF P_IT_MAILID[] IS INITIAL.
IF P_L_C1 = '1'.
MESSAGE E000 WITH 'No IDs available for report1'(059).
ELSEIF P_L_C1 = '2'.
MESSAGE E000 WITH 'No IDs available for report2'(062).
ENDIF.
ENDIF.
* Deleting the blank entries
DELETE P_IT_MAILID WHERE TELX1 = SPACE.
CLEAR L_TEMP.
READ TABLE P_IT_MAILID INDEX 1.
L_TEMP = P_IT_MAILID-TELX1.
DATA : L_CHECK.
LOOP AT P_IT_MAILID WHERE TELX1 <> L_TEMP.
L_CHECK = C_X.
ENDLOOP.
* For checking the unique ids
IF L_CHECK = C_X.
IF P_L_C1 = '1'.
MESSAGE E000 WITH 'No unique mail-ids for report1'(058).
ELSEIF P_L_C1 = '2'.
MESSAGE E000 WITH 'No unique mail-ids for report2'(065).
ENDIF.
ENDIF.
* Populating the IDs for the cost centers
LOOP AT P_IT_MAILID.
SET LOCALE LANGUAGE SY-LANGU.
TRANSLATE P_IT_MAILID-TELX1 TO LOWER CASE.
SET LOCALE LANGUAGE SPACE .
CONCATENATE P_IT_MAILID-TELX1 '@allergan.com' INTO L_TEMP.
P_S_EMAIL-LOW = L_TEMP.
P_S_EMAIL-SIGN = 'I'.
P_S_EMAIL-OPTION = 'EQ'.
APPEND P_S_EMAIL.
CLEAR P_S_EMAIL.
ENDLOOP.
ELSE.
IF P_L_C1 = '1'.
MESSAGE E000 WITH 'No Cost Center Available for report1'(057).
ELSEIF P_L_C1 = '2'.
MESSAGE E000 WITH 'No Cost Center Available for report2'(063).
ENDIF.
ENDIF.
ENDFORM. " read_variants
*& Form CONVERSION
* For Conversion Routine
FORM CONVERSION USING P_IT_VALUTAB_LOW TYPE C.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = P_IT_VALUTAB_LOW
IMPORTING
OUTPUT = P_IT_VALUTAB_LOW.
ENDFORM. " CONVERSION -
Why is my PDF size from my InDesign export still large?
I'm doing class project that is a four-page, seven-image document with very little text. The project must be submitted as a PDF under 300 KB. However, when I export the document under the smallest file size preset and with the compression rates down to 72 dpi, I get a PDF that is 612 KB.
All my classmates are able to get it under 300 KB, so I'm confused as to why mine is so large. I'm using 5 JPGs and 2 GIFs, and each take up a 5in by 5in square in the document. They are relatively really small pictures (avg. 250 KBS) and I've even re-saved all to be under 100 KB, but the PDF size only drops to around 500 KB I transferred between InDesign CC on Mac and InDesign CS5 on Windows and wonder if that is a concern.Just wanted to share the results, in case someone comes across this forum in the future.
In danegonzalez's four-page InDesign layout, seven black-and-white images were used. Three pages contained two 5" by 5" images accompanied by seven lines of text under each image, and the last page had one image-and-description set of similar sizes. An audit of the PDF done on Acrobat (below) showed that the images made up the majority of the file size.
Since the images had quite a bit of detail, I figured that changing their file type would be the best way to create a more compact PDF and keep the integrity of the images. So I cropped the images to size and saved them as 24-bit PNG files. Even though the PNG files were larger than the originals, it gave nice PDF results. Here is the audit results of the updated PDF after using InDesign's "Smallest File Size" default preset.
I'm glad we were able to resolve this issue. -
PDF Size is huge when inserting an image on every page
Hello,
I've got a little problem when inserting an image in a crystal report and then exporting it to PDF.
We're using Crystal Report XI and we've designed the report with a sub-report that gets an image from a database field and put this image on every page of the report (it's just a logo for every page).
This image is a JPEG file with 32KB size.
The exported report is about 1000 pages and we're dealing with an issue because of that. Sometimes the report won't generate giving a OutOfMemory Exception (altough we've defined MinHeap/MaxHeap to 512M).
We also find this curious :
- A generated pdf report with the image on every page totals 100MB size (we would expect something like 32KB*100pages=32000KB/1024KB=31.25MB ?) : Depending on the number of pages, could give OutOfMemoryError.
- A generated pdf report without the image on every page totals 1.8MB size. : No OutOfMemoryError problem here.
Do you know of any way to optimize this, reducing the pdf size and ?
Thank you very much.
Eduardo Andrade (GEDI, S.A.)Hello Ted Ueda,
Thank you for your answer, I was suspecting that...
Since this is an obvious problem, do you know if there is another way of including an image in the report in a more efficient way ? For instance, include the image, only on the first page and on the rest of the pages just include a link to that image?
I've searched in here : https://wiki.sdn.sap.com/wiki/x/JwBmBQ , but did not find anything close to this...
Thank you.
Best Regards,
Eduardo Andrade -
Smart form: Spool to PDF Conversion more than 100 pages.
Hi folks,
I have an issue with Function Module (FM) CONVERT_ABAPSPOOLJOB_2_PDF when the report to be converted has more than 100 pages.....i have explained this scenario as below
We have been using the FM CONVERT_ABAPSPOOLJOB_2_PDF to convert ABAP report to PDF file and then send this via mail using FM SO_DOCUMENT_SEND_API1.....
PDF conversion using FM CONVERT_ABAPSPOOLJOB_2_PDF works well if the number of report pages is less than 100....i.e the table pdf of the FM will contain the output as expected.....
If the report has more than 100 pages, the the FM CONVERT_ABAPSPOOLJOB_2_PDF will schedule the conversion job as a background job and returns with a SY-subrc eq 0 and the table parameter pdf will ne empty.
Could you suggest me a woorkaround in this situtaion...i.e how do I then get the output of the background job
And any process to convert Spool to PDF if having more than 100 pages.
Thanks in Advance............Pb,
If the report has more than 100 pages, the the FM CONVERT_ABAPSPOOLJOB_2_PDF will schedule the conversion job as a background job and returns with a SY-subrc eq 0 and the table parameter pdf will ne empty
i would suggest you to if pages are more than 100 than you need to send report output to sp01 with spool request number by using fm job_open..job_close..
than from sp01 you can convert pdf by running RSTXPDFT4 in se38.
hope this would solve your problem.
Amit. -
How can I reduce a fotobook pdf size for online printing
Hello aperture,
I have been creating a large customer book (33 x 28 cm) with aperture.
I'm working with RAW datas and the fotobook has got around 150 pages.
My online printing office accepts only PDF X3 2002 datas and I can get this with adobe acrobat X Pro.
I print the book in aperture an save it as an Adobe PDF and than, I can save the datas as a PDF X3:2002. It works perfectly.
My problem is that the online printing office accepts only 2 GB and my pdf, which I've printed with aperture, has got around 7 GB.
What can I do in aperture to reduce the pdf size and get a smaller one?
My aperture settings for Export is: 300 dpi.
Thanks for you help,
Best
AndreaActually in LR4 and Camera Raw 7 in Photoshop CS, you CAN create a downsampled DNG by using the Lossy Compression method of converting to DNG. In the LR 4 Export, select DNG then you have the ability to specify long dimensions or the size in Megapixels. Note, a Lossy DNG isn't un-demosiaced, it's been demosiaced but is still stored in Linear Gamma, so it's like a partially baked file, not a true unbaked raw file.
Note, in Camera Raw 7 when you set up your save dlog, it's a bit different. You select Lossy DNG and then have a dropdown for size presets...
Couple of things about the Lossy DNG, you SHOULD name it to distinguish between the downsampled DNG and your original DNG...you don't want to get into the situation where you overwrite your original. Also note that some things won't work totally as expected. For example, sharpening and noise reduction will be working but on a downsampled file. While the numbers will correlate, the actual effects will be a bit different because it's a downsampled file and more prone to potentially over sharpening. It all works, and the controls will work fine if you work at 100% zoom, but don't expect the high resolution your original file had.
Maybe you are looking for
-
Replace not latin characters from file name.
Dear friends, I tried a lot but even after reading the documentation about all the available CF functions I could not find a way to accomplish this: As you already know from my previous post I'm trying to finish an application which manages multiple
-
It is my understanding that the shipping address info is sent to paypal when using paypal standard as a payment gateway instead of sending the actual billing address. Is there any way to modify the order details layout under the customer order module
-
What is process form data in controller
hello friends, what is process form data in controller? i can not see process form data when i created controller, what is the significance to use process form data in controller?exactly which scenario we can use in our OAF application? as per jdevgu
-
Dynamic link - premiere pro to after effects
Hey, these days, premiere pro's dynamic link suddenly stopped working. I tried many things, like reinstalling premiere pro, allowing everything explicitely in the (windows 7) firewall, changing the names of my project etc. It stopped working means th
-
Intermittent HDMI signal on my Mac Pro late 2013
Brand new Mac Pro. Used for short periods of time for a week with no problems. After these few days, during a little bit longer session of work, I got display problems. Intermittent output signal by HDMI cable with image disappearing from monitor and