11-26-2007 5:24 PM
Hi everebody,
I'm using a custom program [ see below ] ( in which there is the call to the std function SO_DOCUMENT_SEND_API1) to send a PDF attachment to an user's SAPOFFICE: in release 4.6C it works correctly but the same programm in ECC6 it doesn't work correctly. I mean: the mail is sent correctly with the attachment, but when I try to open the attachment this one doesn't open correctly showing a PDF error message.
Any help?
gino bonfiglioli
&----
*& Report Z_UT_CONVERT_SPOOL_PDF
*&
&----
*&
*&
&----
REPORT z_ut_convert_spool_pdf.
TABLES: tsp01.
variabili globali
*data: fm_name type rs38l_fnam,
output_options type ssfcompop,
control_parameters type ssfctrlop,
job_output_info type ssfcrescl,
job_output_options type ssfcresop,
DATA: spoolno LIKE tsp01-rqident,
dir_pdf LIKE rlgrap-filename,
numbytes TYPE i,
pagecount TYPE i,
w_cnt TYPE i,
wk_subrc LIKE sy-subrc,
pdfspoolid LIKE tsp01-rqident,
gd_buffer TYPE string,
pdf LIKE tline OCCURS 100 WITH HEADER LINE,
stampante LIKE usr01-spld,
tot_line TYPE sy-tabix,
tot_line2 TYPE sy-tabix,
start_line TYPE sy-tabix.
tabelle interne per 1a mail
DATA: BEGIN OF it_email OCCURS 100.
INCLUDE STRUCTURE solisti1.
DATA: END OF it_email.
DATA: BEGIN OF email_data.
INCLUDE STRUCTURE sodocchgi1.
DATA: END OF email_data.
DATA: BEGIN OF email_send OCCURS 10.
INCLUDE STRUCTURE somlreci1.
DATA: END OF email_send.
DATA: packing_list TYPE STANDARD TABLE OF sopcklsti1 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
receivers TYPE STANDARD TABLE OF somlreci1 WITH HEADER LINE.
fine tabelle interne per 1a mail
----------------------------------------------------------------------
PARAMETER: p_spool LIKE tsp01-rqident.
----------------------------------------------------------------------
START-OF-SELECTION.
PERFORM conversione_spool_pdf USING wk_subrc.
IF wk_subrc EQ 0.
PERFORM invio_mail.
ENDIF.
&----
*& Form CONVERSIONE_SPOOL_PDF
&----
text
----
-->P_P_SUBRC text
----
FORM conversione_spool_pdf USING p_subrc.
**- Conversione in PDF
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = p_spool
no_dialog = ' '
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
pdf_bytecount = numbytes
pdf_spoolid = pdfspoolid
otf_pagecount = pagecount
btc_jobname = jobname
btc_jobcount = jobcount
TABLES
pdf = 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.
p_subrc = sy-subrc.
ENDFORM. " CONVERSIONE_SPOOL_PDF
&----
*& Form invio_mail
&----
text
----
--> p1 text
<-- p2 text
----
FORM invio_mail .
Transfer the 132-long strings to 255-long strings
LOOP AT pdf.
TRANSLATE pdf USING ' ~'.
CONCATENATE gd_buffer pdf 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.
Testo della mail
CLEAR it_email. REFRESH it_email.
it_email-line = 'Testo della mail'.
APPEND it_email.
Creazione messaggio
email_data-obj_name = 'MESSAGE'.
email_data-obj_descr = 'Conversione spool n.'.
email_data-obj_descr+26 = p_spool.
email_data-obj_langu = 'I'.
email_data-sensitivty = 'F'.
READ TABLE it_mess_att INDEX w_cnt.
email_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_mess_att ).
start_line = 1.
DESCRIBE TABLE it_email LINES tot_line.
packing_list-transf_bin = ' '.
packing_list-doc_type = 'RAW'.
packing_list-head_start = 1.
packing_list-head_num = 0.
packing_list-body_start = 1.
packing_list-body_num = tot_line.
packing_list-obj_langu = sy-langu.
APPEND packing_list.
APPEND LINES OF it_mess_att TO it_email.
CLEAR packing_list.
Riga iniziale = ultima riga messaggio precedente + 1
start_line = tot_line + 1.
DESCRIBE TABLE it_mess_att LINES tot_line.
packing_list-transf_bin = 'X'.
packing_list-head_start = 1.
packing_list-head_num = 1.
packing_list-body_start = 1.
DESCRIBE TABLE it_mess_att LINES packing_list-body_num.
packing_list-doc_type = 'PDF'.
packing_list-obj_descr = 'Allegato PDF.'.
packing_list-doc_size = packing_list-body_num * 255.
packing_list-obj_langu = sy-langu.
APPEND packing_list.
destinatario interno a SAP
receivers-receiver = sy-uname.
receivers-rec_type = 'B'.
receivers-express = 'X'.
APPEND receivers.
destinatario esterno a SAP: deve essere un idirizzo email:
receivers-receiver = 'gino.bonfiglioli@sidigroup.it'.
receivers-rec_type = 'U'.
APPEND receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = email_data
put_in_outbox = 'X'
SENDER_ADDRESS = SY-UNAME
sender_address_type = 'B'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
SENDER_ID =
TABLES
packing_list = packing_list
contents_bin = it_mess_att
contents_txt = it_email
receivers = 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.
errore invio mail
ENDIF.
11-26-2007 5:48 PM
An explicit commit work is needed after the FM call. This has changed since 4.6C.
Albert
11-26-2007 5:28 PM
Hi,
Try to use fm 'SO_NEW_DOCUMENT_ATT_SEND_API1' instead of SO_DOCUMENT_SEND_API1.
Please check documentation of fm SO_DOCUMENT_SEND_API1 in ECC 6.
a®
11-26-2007 5:48 PM
An explicit commit work is needed after the FM call. This has changed since 4.6C.
Albert
11-27-2007 10:11 AM
I tried with the function SO_NEW_DOCUMENT_ATT_SEND_API1 adding it also the flag on field "COMMIT_WORK" but it doesn't work.
Is it possible that a PDF printer isn't defined?
Do I (or my administrator colleague) define from transaction SPAD a PDF printer?
thank you
Gino Bonfiglioli
01-07-2010 2:27 PM