COMMIT_WORK in FM, SO_DOCUMENT_SEND_API1
Hi,
I use this FM to send e-mail in VA01 for a certain output type. I passed a parameter, COMMIT_WORK with an 'X'. But then when creating sales order upon saving, i got an update terminate. Studying the dump error, it is an error of COMMIT_IN_POSTING. The error explains that is is the invalid commit_work in an update function module. This function module is SO_DOCUMENT_SEND_API1. When I tried to delete the parameter, COMMIT_WORK, i can save the order but then cannot send the e-mail when executing the output type to send e-mail. But the message to be sent is still no entry in queue when checking in transaction SOST.
Please help me in analyzing the cause.
remove commit and use this code:
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
[Send external email from within ABAP program |http://wiki.sdn.sap.com/wiki/x/-dc]
Similar Messages
-
SO_DOCUMENT_SEND_API1 and Business Workplace
Hello gurus,
I'm using the FM SO_DOCUMENT_SEND_API1 to send emails (massively) with a pdf file as attachment. Unfortunately, I can't see the email in the outbox of my business workplace . Nevertheless all the recipients get the emails without problems. The sy-subrc after calling the FM is 0. Everything seems to go fine except for the missing entries in my outbox .
Any help will be appreciated.
Thank you,
Jaime
P.D. This is the way how I'm calling the FM:
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = wa_doc_data
put_in_outbox = 'X'
sender_address = in_sender_address
sender_address_type = in_sender_addres_type
commit_work = 'X'
importing
sent_to_all = w_sent_all
tables
packing_list = it_packing_list
contents_bin = it_attachment_int
contents_txt = it_message_body_int
receivers = it_email_receivers_int
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.
case sy-subrc.
when 0.
* Todo bien!
when 1.
raise too_many_receivers.
when 2.
raise document_not_sent.
when 3.
raise document_type_not_exist.
when 4.
raise operation_no_authorization.
when 5.
raise parameter_error.
when 6.
raise x_error.
when 7.
raise enqueue_error.
when others.
raise unknown_error.
endcase.Hello.
please find the code below it will be more help ful to you
DATA :
IT_PACKING_LIST TYPE TABLE OF SOPCKLSTI1,
IT_CONTENTS_TXT TYPE TABLE OF SOLISTI1,
IT_RECEIVERS TYPE TABLE OF SOMLRECI1,
WA_DOCUMENT TYPE SODOCCHGI1,
WA_PACKING_LIST TYPE SOPCKLSTI1,
WA_RECEIVERS TYPE SOMLRECI1,
WA_CONTENTS_TXT TYPE SOLISTI1,
IT_OTF TYPE table of ITCOO,
T_html_raw type table of ITCOO,
T_SENDER TYPE SO_REC_EXT,
T_ADSMTP_LINE TYPE SZADR_ADSMTP_LINE,
T_SENDER_TYP TYPE SOEXTRECI1-ADR_TYP,
T_pdf_xstring type xstring,
Tt_lines type table of tline,
wa_lines type tline,
T_pdf_len type i,
it_docs TYPE STANDARD TABLE OF docs,
L_SMTP_ADDR type AD_SMTPADR,
MID(20) type c,
wa_buffer TYPE string.
*Importing the MAil Address from the Memory id
*Pass the OTF data to the Internal Table
IT_OTF = job_output_info-OTFDATA.
If not IT_OTF is INITIAL.
*Convert the OTF data to ASCII
Call function 'CONVERT_OTF'
exporting
format = 'ASCII'
importing
bin_filesize = T_pdf_len
bin_file = T_pdf_xstring " binary file
tables
otf = IT_OTF
lines = tt_lines
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
others = 5.
if sy-subrc = 0.
*PAss the ASCII data to the Body Of the Mail
loop at tt_lines into wa_lines.
wa_CONTENTS_TXT = wa_lines-tdline.
append wa_contents_txt to it_contents_txt.
clear wa_contents_txt.
endloop.
*Mail headder information **
WA_DOCUMENT-OBJ_NAME = 'SMARTFORM'.
WA_DOCUMENT-OBJ_LANGU = SY-LANGU.
WA_DOCUMENT-OBJ_DESCR = 'Interest Calculation' .
WA_DOCUMENT-SENSITIVTY = 'F'.
If email exist.
WA_RECEIVERS-RECEIVER = ur email addrees
WA_RECEIVERS-REC_TYPE = 'U'.
WA_RECEIVERS-COM_TYPE = 'INT'.
WA_RECEIVERS-NOTIF_DEL = 'X'.
WA_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND WA_RECEIVERS TO IT_RECEIVERS.
T_SENDER = SY-UNAME.
T_SENDER_TYP = 'INT'.
*Passing the data to the Context Table
Document Attachement information **
CLEAR WA_PACKING_LIST-TRANSF_BIN.
WA_PACKING_LIST-TRANSF_BIN = SPACE.
WA_PACKING_LIST-HEAD_START = 1.
WA_PACKING_LIST-HEAD_NUM = 0.
WA_PACKING_LIST-BODY_START = 1.
WA_PACKING_LIST-obj_name = 'Interest Calculation Letter'.
DESCRIBE TABLE IT_CONTENTS_TXT LINES WA_PACKING_LIST-BODY_NUM.
WA_PACKING_LIST-DOC_size = WA_PACKING_LIST-BODY_NUM * 255.
WA_PACKING_LIST-BODY_NUM = WA_PACKING_LIST-BODY_NUM.
WA_PACKING_LIST-DOC_TYPE = 'RAW'.
APPEND WA_PACKING_LIST TO IT_PACKING_LIST.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOCUMENT
PUT_IN_OUTBOX = 'X'.
SENDER_ADDRESS = T_SENDER
SENDER_ADDRESS_TYPE = 'B'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = IT_PACKING_LIST
CONTENTS_TXT = IT_CONTENTS_TXT
RECEIVERS = IT_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.
Thanks, -
Multiple pdf attachments from server folder using SO_DOCUMENT_SEND_API1
Dears,
I am trying to build a program able to send an email with multiple pdf attachments.
The files are stored in a folder in SAP server.
I am able to generate a pdf file from a spool and sucessfully attach it to the email using:
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = v_bin_filesize
TABLES
otf = job_output_info-otfdata
doctab_archive = it_docs
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
IF sy-subrc = 0.
LOOP AT it_lines.
TRANSLATE it_lines USING ' ~'.
CONCATENATE gd_buffer it_lines INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att_aux = gd_buffer.
APPEND it_mess_att_aux.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDIF.
Internal table it_mess_att_aux is the parameter contents_bin of FM SO_DOCUMENT_SEND_API1.
I have now 2 files on a server folder which I would like to include as well.
I am reading the content of the pdf files in following way:
DATA: gd_buffer TYPE string,
OPEN DATASET lv_fileserver FOR INPUT IN BINARY MODE.
IF sy-subrc <> 0.
MESSAGE e257(zmsgsd) WITH lv_fileserver.
ELSE.
CLEAR: it_mess_att_aux[], gd_buffer.
DO.
READ DATASET lv_fileserver INTO gd_buffer.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND gd_buffer TO it_mess_att_aux.
ENDDO.
APPEND LINES OF it_mess_att_aux TO it_mess_att.
I do not understand the purpose of the statement:
TRANSLATE it_lines USING ' ~'.
in this context. Could anyone explain it?
All the files are attached to email with the desired name but corrupted and with the wrong size.
Can anyone help me build the logic to attach a pdf file from server in a email?
Thank you in advance,
Kind Regards,
João Cabritahi , try this ,it is working fine .
DATA: i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
* wa_doc_chng LIKE sodocchgi1,
i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
* i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_tline TYPE TABLE OF tline WITH HEADER LINE,
i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
wa_doc_chng LIKE sodocchgi1,
v_lines_txt TYPE i,
l_lines TYPE I VALUE '20'.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = int_tab_otf_final
lines = int_pdf_tab.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*****************soc ranjan***************************
* IF full_path IS INITIAL.
* CALL METHOD cl_gui_frontend_services=>file_save_dialog
* EXPORTING
** WINDOW_TITLE =
** DEFAULT_EXTENSION = 'PDF'
** DEFAULT_FILE_NAME =
* file_filter = 'Portable Document Format (.pdf)' " for restricting saving file only as pdf
* CHANGING
* filename = file_name
* path = file_path
* fullpath = full_path
* IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.
* ENDIF.
******************eoc ranjan*****************
*break-point.
CONCATENATE full_path git_select_option-pernr INTO path SEPARATED BY '_'.
CONCATENATE path 'PDF' INTO path SEPARATED BY '.'.
** **************************for downloading*********************************
* CALL FUNCTION 'GUI_DOWNLOAD'
* EXPORTING
* bin_filesize = bin_filesize
* filename = path
* filetype = 'BIN'
* IMPORTING
* filelength = file_size
* TABLES
* data_tab = int_pdf_tab.
* 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 : lop , el , sl , cl .
* ******************addeddd later by ranjan 21.04.2011
DATA : desc TYPE char40 ,
desc1 TYPE char100 .
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = int_pdf_tab
t_target_tab = i_record
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
IF sy-subrc <> 0.
WRITE : / 'Error in conversion of pdf lines'(015).
ENDIF.
APPEND LINES OF i_record TO i_objbin.
*Creation of the entry for the compressed attachment
DESCRIBE TABLE i_objbin LINES bin_filesize.
i_objtxt = 'Hi'.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = 'Pls find the attached salary slip ' .
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = ' '.
APPEND i_objtxt.
i_objtxt = 'Regards: '.
APPEND i_objtxt.
i_objtxt = 'Corporate HR '.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES L_LINES.
READ TABLE i_objtxt INDEX L_LINES.
wa_doc_chng-doc_size = ( L_LINES - 1 ) * 255 + STRLEN( i_objtxt ).
*Creating the entry for the compressed document
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = L_LINES.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
***CLEAR: i_objpack .
***i_objpack-transf_bin = ' '.
**i_objpack-head_start = 1.
**i_objpack-head_num = 0.
**i_objpack-body_start = 1.
**i_objpack-body_num = L_LINES.
**i_objpack-doc_type = 'TXT'.
**i_objpack-obj_descr = desc1 .
**APPEND i_objpack.
*CLEAR: i_objhead .
*i_objhead = DESC.
*APPEND i_objhead.
*break-point .
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = bin_filesize.
i_objpack-obj_name = 'Employee Payslip'.
i_objpack-obj_descr = 'Employee Payslip'.
i_objpack-doc_size = bin_filesize * 255 .
i_objpack-doc_type = 'PDF'.
APPEND i_objpack.
CONCATENATE 'Salary Slip of Month' p_month INTO desc SEPARATED BY ' ' .
*DESCRIBE TABLE i_objtxt LINES v_lines_txt.
*READ TABLE i_objtxt INDEX v_lines_txt.
****wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 375 + STRLEN( i_objtxt ).
wa_doc_chng-obj_name = 'Payslip'.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_descr = desc.
wa_doc_chng-sensitivty = 'F'.
wa_doc_chng-doc_size = v_lines_txt * 255.
CLEAR i_objpack.
DATA: l_usrid_long TYPE pa0105-usrid_long.
DATA : emessage(70) TYPE c.
CLEAR : l_usrid_long.
SELECT SINGLE usrid_long
FROM pa0105
INTO l_usrid_long
WHERE pernr = git_pa0001-pernr
AND subty = '0010'.
*break-point.
IF sy-subrc EQ 0.
i_reclist-receiver = l_usrid_long.
i_reclist-rec_type = 'U'.
i_reclist-com_type = 'INT'.
APPEND i_reclist.
ELSE.
WRITE:/ 'No email id is maintained for this personnel number' , git_pa0001-pernr.
ENDIF.
IF NOT i_reclist[] IS INITIAL.
***************************************for senders id *************************************
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
sender_address = 'xys'
sender_address_type = 'SMTP'
commit_work = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
* SENDER_ID =
TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
SO_DOCUMENT_SEND_API1 - Filename extension
Hi Experts,
I am using FM SO_DOCUMENT_SEND_API1 to send an excel attachment. I am passing filename 'UPDATE_LOGS' in packing list but when I check in SO01(Outbook) file name for extension is UPDATE_LOGS_YYMMDDHHMMSS.xls".
How to I correct this.Heres the code I am using.
*----Attachment details....
DESCRIBE TABLE p_attach.
lwa_doc_data-doc_size = ( sy-tfill - 1 ) * 255 + STRLEN( lwa_attach ).
lwa_doc_data-obj_langu = sy-langu.
lwa_doc_data-obj_name = 'SAPRPT'.
lwa_doc_data-obj_descr = 'BOM Component Update ~ Explosion Type'(t07).
lwa_doc_data-sensitivty = 'F'.
*-----Message Body & Packing List
lwa_message = 'Please find attached a list Updated Explosion Type'(t04).
APPEND lwa_message TO lt_message.
CLEAR lwa_packing_list.
REFRESH lt_packing_list.
lwa_packing_list-transf_bin = space.
lwa_packing_list-head_start = 1.
lwa_packing_list-head_num = 0.
lwa_packing_list-body_start = 1.
DESCRIBE TABLE lt_message LINES lwa_packing_list-body_num.
lwa_packing_list-doc_type = 'RAW'.
APPEND lwa_packing_list TO lt_packing_list.
*-----Create attachment notification
lwa_packing_list-transf_bin = 'X'.
lwa_packing_list-head_start = 1.
lwa_packing_list-head_num = 1.
lwa_packing_list-body_start = 1.
DESCRIBE TABLE p_attach LINES lwa_packing_list-body_num.
lwa_packing_list-doc_type = 'xls'.
lwa_packing_list-obj_name = c_filename.
lwa_packing_list-obj_descr = c_filename.
CONCATENATE c_filename sy-datum INTO lwa_packing_list-obj_name.
lwa_packing_list-doc_size = lwa_packing_list-body_num * 255.
APPEND lwa_packing_list TO lt_packing_list.
*---Add recivers
LOOP AT p_adr6 INTO wa_adr6.
CLEAR lwa_receiver.
REFRESH lt_receiver.
CONDENSE wa_adr6-smtp_addr.
lwa_receiver-receiver = wa_adr6-smtp_addr.
lwa_receiver-rec_type = 'U'.
lwa_receiver-com_type = 'INT'.
APPEND lwa_receiver TO lt_receiver.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = lwa_doc_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 = lt_packing_list
OBJECT_HEADER =
contents_bin = p_attach
contents_txt = lt_message
CONTENTS_HEX =
OBJECT_PARA =
OBJECT_PARB =
receivers = lt_receiver
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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
MESSAGE i000 WITH 'Log sent via email!!!'(m03).
ENDIF.
Thanks,
ChirantanThanks, however, if I change those setting, it could potentially have adverse effects on other jobs. Our BASIS team says I can't change 'em.
FYI from SCOT, drilling into the email "node" will present a pop up window. The "Set" push button for internet (under the Supported address types) displays the values of "Output formats for SAP Documents" that are available.
I have changed the settings for:
SAPscript/Smart Forms
ABAP List
Business Object/Link
Raw Text
there, but does not accomplish what I'm trying to do. And, that was only to test - I can't modify the settings on the production box.
I'm of the opinion that it is not possible to use a user defined file extension with the FM.
Thanks,
Allen -
Problem in mailing smartforms output using SO_DOCUMENT_SEND_API1
Hi all,
Iam using the function module SO_DOCUMENT_SEND_API1 to email purchase order through driver program.
the code goes like this:
first iam calling the function module of smartform
CALL FUNCTION lv_fm_name
where iam passing the desired paramets.
from where iam taking the otfdata returned from the fm
like:
IMPORTING
job_output_info = w_return
where w_return is declared as TYPE ssfcrescl.
then iam writing this code
i_otf[] = w_return-otfdata[].
DELETE w_return-otfdata WHERE tdprintcom = '//'.
READ TABLE i_otf WITH KEY tdprintcom = 'EP'.
my_tabix = sy-tabix + 1.
INSERT lines of w_return-otfdata INTO i_otf INDEX my_tabix.
then iam calling the fm
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_len_in
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 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.
then converting it to 255 using
DATA: gd_buffer TYPE string.
DATA: w_cnt TYPE i,
i_record LIKE solix OCCURS 0 WITH HEADER LINE.
LOOP AT i_tline.
TRANSLATE i_tline USING ' ~'.
CONCATENATE gd_buffer i_tline INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
i_record-line = gd_buffer.
APPEND i_record.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
the to test whether its converting into pdf iam using the fm
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = 'C:\TESTPDF.PDF'
filetype = 'BIN'
TABLES
data_tab = i_record.
then calling my main fm
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = 'X'
sender_address = sender
sender_address_type = 'INT'
commit_work = 'X'
TABLES
packing_list = it_packing_list
object_header = w_objhead
CONTENTS_BIN = I_OBJBIN
contents_txt = i_objtxt
contents_hex = i_objbin
receivers = it_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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
all the parametrs for the above fm are passed correctly like populating it_packing_list,w_objhead, i_objtxt, i_objbin,it_receivers.iam using this fm because i need to pass sender email id.
the first problem iam facing is when iam using the fm gui_download iam not able to view the smartform
the error is "adobe reader could not open "test.pdf" as it is not supported etc..."
second is same problem iam facing while trying to open the attachment in pdf which is emailed to reciever.
i think there is some problem in converting 132 to 255 characters.
can some one please help on this.(might be a problem where iam passing DO
i_record-line = gd_buffer.)
thanks in advance.
regards
sunilCALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = <b>255 "132</b>
IMPORTING
bin_filesize = v_len_in
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 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.
I guess it will solve your problem.
CLose the thread if your question is answered.
Regards,
SaiRam -
E-mail error : SO_DOCUMENT_SEND_API1
Hi,
After running F110 transaction, spools are getting generated with Remittance Advises Notes which are using Scripts.
Requriement is Take each spool and covert into PDF and send it to Vendor email id.
Iam using FMs CONVERT_OTFSPOOLJOB_2_PDF and SO_DOCUMENT_SEND_API1.
When while running the program Iam getting the following Error in FM SO_DOCUMENT_SEND_API1
'System error when accessing Knowledge Provider'.
Please gudie me regarding this.Hi Krishna,<br>
<br>
Iam using following code. Iam getting error in mail FM with RC=6. Is there any bug in my prog.<br><br>
<pre>parameters : p_mail type AD_SMTPADR.
select-options : s_spool for TSP01-RQIDENT.
start-of-selection.
loop at s_spool.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = s_spool-low
no_dialog = ' '
IMPORTING
pdf_bytecount = lv_numbytes
btc_jobname = lv_jobname
btc_jobcount = lv_jobcount
TABLES
pdf = lt_pdf
EXCEPTIONS
err_no_otf_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_dstdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
//Transfer the 132 bit strings to 255 bit strings.
LOOP AT lt_pdf.
TRANSLATE lt_pdf USING ' ~'.
CONCATENATE lv_buffer lt_pdf INTO lv_buffer.
ENDLOOP.
REFRESH lt_objbin.
CLEAR lw_objbin.
DO.
lw_objbin = lv_buffer.
APPEND lw_objbin TO lt_objbin.
SHIFT lv_buffer LEFT BY 255 PLACES.
IF lv_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
//Creating the Subject for the email
lv_doc_chng-obj_name = sy-repid.
lv_doc_chng-obj_descr = 'Remittance Advice'.
lv_doc_chng-sensitivty = 'O'.
WRITE sy-datum TO lv_date USING EDIT MASK '__/__/____'.
WRITE sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
CONCATENATE lv_doc_chng-obj_descr '_'
lv_date '_'
lv_time INTO lv_doc_chng-obj_descr.
//Email Body
CLEAR lw_objtxt.
lw_objtxt = 'Remittance Advice'.
APPEND lw_objtxt TO lt_objtxt.
CLEAR lw_objtxt.
CONCATENATE 'Date:' lv_date INTO lw_objtxt SEPARATED BY space.
"Date
APPEND lw_objtxt TO lt_objtxt.
CLEAR lw_objtxt.
CONCATENATE 'Time:' lv_time INTO lw_objtxt SEPARATED BY space.
"Time
APPEND lw_objtxt TO lt_objtxt.
DESCRIBE TABLE lt_objtxt LINES lv_tab_lines.
CLEAR lw_objtxt.
READ TABLE lt_objtxt
INTO lw_objtxt
INDEX lv_tab_lines.
//Fill the Size of the Document
lv_doc_chng-doc_size = ( lv_tab_lines - 1 ) * 255 +
STRLEN( lw_objtxt ).
//Create the entry for the Compressed document for Header.
REFRESH lt_objpack.
CLEAR lw_objpack.
lw_objpack-head_start = 1.
lw_objpack-head_num = 0.
lw_objpack-body_start = 1.
lw_objpack-body_num = lv_tab_lines.
lw_objpack-doc_type = 'RAW'.
APPEND lw_objpack TO lt_objpack.
//Get the size of the Actual PDF Document
CLEAR lv_tab_lines.
DESCRIBE TABLE lt_objbin LINES lv_tab_lines.
lw_objhead = lv_doc_chng-obj_descr.
APPEND lw_objhead TO lt_objhead.
//Create the entry for the Compressed document for the PDF
CLEAR lw_objpack.
lw_objpack-transf_bin = 'X'.
lw_objpack-head_start = 1.
lw_objpack-head_num = 1.
lw_objpack-body_start = 1.
lw_objpack-body_num = lv_tab_lines.
lw_objpack-doc_type = 'PDF'.
lw_objpack-obj_name = 'ATTACHMENT'.
APPEND lw_objpack TO lt_objpack.
//Create the Recipient's Data
CLEAR lw_reclist.
REFRESH lt_reclist.
lw_reclist-receiver = p_mail.
lw_reclist-rec_type = 'U'.
APPEND lw_reclist TO lt_reclist.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = lv_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
receivers = lt_reclist
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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.</pre><br><br>
Regards <br>
Krishna
Edited by: Matt on Aug 14, 2009 5:11 PM - fixed formatting -
Problem with SO_DOCUMENT_SEND_API1
Using below code i want to send email body(t_body) as well html attachment(so_ali), But am receiving only attachment,
email body is missing, plz suggest where is the mistake in my code ASAP.
Thanks a lot in advance
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 = 'Sairam'.
APPEND plist.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 1.
plist-doc_type = real_type.
DESCRIBE TABLE so_ali LINES plist-body_num.
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.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 1.
plist-doc_type = 'RAW'.
wa_body-line = 'This is first line of email'.
append wa_body to t_body.
wa_body-line = 'This is second line of email'.
append wa_body to t_body.
DESCRIBE TABLE t_body LINES plist-body_num.
Get the size.
READ TABLE t_body into wa_body INDEX plist-body_num.
plist-doc_size = ( plist-body_num - 1 ) * line_size
+ STRLEN( wa_body ).
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 = emailid
Subject.
document_data-obj_descr = 'Subject '.
Send the email.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = document_data
sender_address = v_name
sender_address_type = 'SMTP'
commit_work = 'X'
TABLES
packing_list = plist
contents_bin = so_ali
contents_txt = t_body
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.Hi,
For email body please pass transf_bin as blank. plist is basically like a header information which contains the details of the data you are sending in the email, both body and attachment. When the transf_bin field is X it is interpreted as info on attachment .. when space it is info on body.
Also you have to pass the number of lines in the email body in the field plist-body_num.
plist-transf_bin = 'X'. -> need to make this blank
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 1.
plist-doc_type = 'RAW'.
wa_body-line = 'This is first line of email'.
append wa_body to t_body.
wa_body-line = 'This is second line of email'.
append wa_body to t_body. -
Using FM "SO_DOCUMENT_SEND_API1" to send mail without attachment
Hi,
What are the parameters to be passed and their values
to send a mail using SO_DOCUMENT_SEND_API1
EXPORT PARAMETERS :
document_data = ?
sender_address = sy-userid
sender_address_type = 'INT'
commit_work = 'X'
TABLES :
packing_list = ?
contents_bin = ?
The content of the mail is not being displayed in the mail.
Thanks in advance.
Regards,HarikaHi Harika,
Check below piece of code.
*& Form mail_body
* text
* --> p1 text
* <-- p2 text
FORM mail_body.
DATA: l_l1 TYPE i.
CONSTANTS: lc_0 VALUE '0',
lc_1 VALUE '1',
lc_raw(3) TYPE c VALUE 'RAW'.
REFRESH: i_objtxt[],
i_objpack[].
CLEAR: wa_objtxt.
SORT i_fail BY type.
* MAIL BODY
* Customer Number
CONCATENATE text-t18
w_kunnr
INTO wa_objtxt
SEPARATED BY space.
APPEND wa_objtxt TO i_objtxt.
CLEAR wa_objtxt. "blank line
APPEND wa_objtxt TO i_objtxt.
* Complete Payment Doc Nos
READ TABLE i_fail WITH KEY type = c_comp
TRANSPORTING NO FIELDS
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_objtxt = text-t16.
APPEND wa_objtxt TO i_objtxt.
CLEAR: wa_fail, wa_objtxt.
APPEND wa_objtxt TO i_objtxt.
MOVE: text-t23 TO wa_objtxt,
text-t24 TO wa_objtxt+17(5),
text-t25 TO wa_objtxt+22(6),
text-t26 TO wa_objtxt+40(18).
APPEND wa_objtxt TO i_objtxt.
CLEAR wa_objtxt.
LOOP AT i_fail INTO wa_fail WHERE type EQ c_comp.
DIVIDE wa_fail-disper BY 100.
MOVE: wa_fail-belnr TO wa_objtxt,
wa_fail-buzei TO wa_objtxt+17(5),
wa_fail-wrbtr TO wa_objtxt+22(16),
wa_fail-disper TO wa_objtxt+40(18).
APPEND wa_objtxt TO i_objtxt.
CLEAR: wa_fail, wa_objtxt.
ENDLOOP.
ENDIF.
* Partial Payment Doc Nos
READ TABLE i_fail WITH KEY type = c_part
TRANSPORTING NO FIELDS
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_objtxt = text-t17.
APPEND wa_objtxt TO i_objtxt.
CLEAR wa_fail.
CLEAR: wa_objtxt.
APPEND wa_objtxt TO i_objtxt.
MOVE: text-t23 TO wa_objtxt,
text-t24 TO wa_objtxt+17(5),
text-t25 TO wa_objtxt+22(6),
text-t26 TO wa_objtxt+40(18).
APPEND wa_objtxt TO i_objtxt.
CLEAR wa_objtxt.
LOOP AT i_fail INTO wa_fail WHERE type EQ c_part.
DIVIDE wa_fail-disper BY 100.
MOVE: wa_fail-belnr TO wa_objtxt,
wa_fail-buzei TO wa_objtxt+17(5),
wa_fail-wrbtr TO wa_objtxt+22(16),
wa_fail-disper TO wa_objtxt+40(18).
APPEND wa_objtxt TO i_objtxt.
CLEAR: wa_fail, wa_objtxt.
ENDLOOP.
ENDIF.
* MAIL BODY-LENGTH
DESCRIBE TABLE i_objtxt LINES l_l1.
CLEAR wa_objpack-transf_bin.
wa_objpack-head_start = lc_1.
wa_objpack-head_num = lc_0.
wa_objpack-body_start = lc_1.
wa_objpack-body_num = l_l1.
wa_objpack-doc_type = lc_raw.
APPEND wa_objpack TO i_objpack.
*SUBJECT
CLEAR wa_doc_chng.
wa_doc_chng-obj_name = text-t15.
wa_doc_chng-obj_descr = text-t15.
ENDFORM. " mail_body
*& Form send_mail
* text
FORM send_mail.
CONSTANTS: lc_c TYPE so_escape VALUE 'C',
lc_mode(3) TYPE c VALUE 'INT'.
CLEAR: wa_reclist, i_reclist[].
*Recipient list
wa_reclist-receiver = text-t14. "DL
wa_reclist-rec_type = lc_c.
APPEND wa_reclist TO i_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = c_x
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = i_objpack
* OBJECT_HEADER =
* CONTENTS_BIN =
contents_txt = i_objtxt
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = i_reclist
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.
* ENDIF.
IF sy-subrc IS INITIAL.
*Send mail immediately
SUBMIT rsconn01 USING SELECTION-SET lc_mode AND RETURN.
CALL FUNCTION 'SO_DEQUEUE_UPDATE_LOCKS'.
ELSE.
RAISE mail_not_sent.
ENDIF.
ENDFORM. " send_mail
Thanks,
Vinod. -
SO_DOCUMENT_SEND_API1 not working in ECC 5.0
I am using this FM to send email . Everything executes, No exceptions raised, But no email either.
Same FM works in 4.7.
Any suggestion.
Thanks..hi,
1) Check whether rec_type parameter is populated correctly or not. It has to be populated with different values based on the user to which you have to send the mail.
ex: SAP Inbox, External mail id
With FM SO_DOCUMENT_SEND_API1
you have to set following params to use an email-adress
receiver-receiver = email-adress.
receiver-rec_type = 'U'.
2) In the parameters of this FM, set commit_work = 'X'.
3) Settings done by Basis
If any of these is not done correctly, mail can not be sent.
Regards,
Sailaja. -
Problem using FM SO_DOCUMENT_SEND_API1
hi gurus,
I'm having a hard time trying to get the right result using FM SO_DOCUMENT_SEND_API1 to send and attachment with email.
I collected a number of lines (8252 lines !) into an internal table defines as followed :
DATA : wt_report TYPE TABLE OF SOLISTI1 WITH HEADER LINE.
Now I would like to send the content of each line as email attachement as EITHER .xls OR .txt files. (for now I get an email with attachment but canno view the content of the email)
Here is my code :
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = ws_doc_data
PUT_IN_OUTBOX = 'x'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
SENDER_ID =
tables
packing_list = it_packing_list <----
what is this supposed to contain ??
OBJECT_HEADER =
CONTENTS_TXT = wt_report <------ Here is my itab with 8252 lines
CONTENTS_HEX = wt_report
OBJECT_PARA =
OBJECT_PARB =
receivers = wt_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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thank you so much for help, <removed_by_moderator>
C.K.
Edited by: Julius Bussche on Jul 8, 2008 4:36 PMhi check this....
REPORT ZMAIL.
TABLES: ekko.
PARAMETERS: p_email TYPE somlreci1-receiver .
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
wa_ekpo TYPE t_ekpo.
TYPES: BEGIN OF t_charekpo,
ebeln(10) TYPE c,
ebelp(5) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.
DATA: wa_charekpo TYPE t_charekpo.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
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,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
*START_OF_SELECTION
START-OF-SELECTION.
Retrieve sample data from table ekpo
PERFORM data_retrieval.
Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
perform populate_email_message_body.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example .xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp aedat matnr
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekpo.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
Build data table for .xls document
FORM build_xls_data_table.
data: ld_store(50) type c. "Leading zeros
CONSTANTS: con_cret(5) TYPE c VALUE '0D', "OK for non Unicode
con_tab(5) TYPE c VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR' INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT it_ekpo INTO wa_charekpo.
*Modification to retain leading zeros
inserts code for excell REPLACE command into ld_store
=REPLACE("00100",1,5,"00100")
concatenate '=REPLACE("' wa_charekpo-ebelp '",1,5,"'
wa_charekpo-ebelp '")' into ld_store .
concatenate ld_store into .xls file instead of actual value(ebelp)
CONCATENATE wa_charekpo-ebeln ld_store wa_charekpo-aedat wa_charekpo-matnr INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables pit_message
pit_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.
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[] = pit_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.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test ekpo records'.
APPEND it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY -
Problem using function SO_DOCUMENT_SEND_API1,
Dear All,
I used this function for attach the txt file and send the e-mail to relate user.
Now, My output file print out all the data in the same line.
how i can split the data line by line ?
below is my coding.
Please kindly to help me.
Regards,
Luke
PERFORM send_file_as_email_attachment
TABLES it_mess_bod
it_mess_att
USING P_TITLE
'FIX'
gd_attachment_name
gd_attachment_desc
p_FROM
'INT'
CHANGING gd_error
gd_reciever.
*& Form send_file_as_email_attachment
text
-->IT_MESSAGE text
-->IT_ATTACH text
-->P_MTITLE text
-->P_FORMAT text
-->P_FILENAME text
-->P_ATTDESCRIPTION text
-->P_SENDER_ADDRESS text
-->P_SENDER_ADDRES_TYPE text
-->P_ERROR text
-->P_RECIEVER text
FORM send_file_as_email_attachment TABLES it_message
it_attach
USING p_email
USING 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.
LOOP AT itab_mailto.
t_receivers-receiver = itab_mailto-smtp_addr.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
t_receivers-copy = ''.
APPEND t_receivers.
ENDLOOP.
LOOP AT S_CC.
t_receivers-receiver = S_CC-low.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
t_receivers-copy = '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_attachmentHi,
Try This ....
DATA: l_tab_lines TYPE i,
l_error TYPE string.
CONSTANTS : l_c_name(13) TYPE c VALUE 'HC Error File', "#EC NOTEXT
l_c_255(255) TYPE c VALUE '255',
l_c_txt(3) TYPE c VALUE 'TXT'.
DATA: lt_reclist TYPE STANDARD TABLE OF somlreci1, "Recipients
lt_objpack TYPE STANDARD TABLE OF sopcklsti1,
lt_objhead TYPE STANDARD TABLE OF solisti1,
lt_objtxt TYPE STANDARD TABLE OF solisti1, "Body of EMail
lt_objbin TYPE STANDARD TABLE OF solisti1."Attachment of EMail
DATA: l_wa_doc_chng TYPE sodocchgi1, "attributes of document to send
l_wa_reclist LIKE LINE OF lt_reclist,
l_wa_objpack LIKE LINE OF lt_objpack,
l_wa_obj LIKE LINE OF lt_objhead.
Begin of Insert CHRK941885
DATA :
l_hex LIKE solix,
lt_contents_hex LIKE STANDARD TABLE OF solix ,
conv TYPE REF TO cl_abap_conv_out_ce,
l_buffer TYPE xstring,
l_hexa(510) type x.
End of Insert CHRK941885
Fill attachment contents: body of email message
CONCATENATE 'Click on attachment to view the extract file :'(t01)
l_c_name INTO l_wa_obj-line SEPARATED BY space.
APPEND l_wa_obj TO lt_objtxt. CLEAR l_wa_obj.
APPEND l_wa_obj TO lt_objtxt. CLEAR l_wa_obj.
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
Information about the email body data
CLEAR l_wa_objpack-transf_bin. "Attachment not binary
l_wa_objpack-head_start = 1.
l_wa_objpack-head_num = 0.
l_wa_objpack-body_start = 1.
l_wa_objpack-body_num = l_tab_lines * l_c_255.
l_wa_objpack-doc_type = 'TXT'.
APPEND l_wa_objpack TO lt_objpack.
CLEAR :l_wa_objpack.
Move error records to the file, semi-colon delimited
LOOP AT e_error INTO g_error.
CONCATENATE g_error-pernr ';'
g_error-nachn ';'
g_error-vorna ';'
g_error-werks ';'
g_error-persg ';'
g_error-eligr ';'
g_error-msg INTO l_error.
APPEND l_error TO lt_objbin.
ENDLOOP.
Document type is TXT
l_wa_objpack-doc_type = l_c_txt.
APPEND object_header.
CALL FUNCTION 'SO_RAW_TO_RTF'
TABLES
objcont_old = lt_objbin
objcont_new = lt_objbin.
Begin of Insert CHRK941885
LOOP AT lt_objbin into l_error.
conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'B').
CALL METHOD conv->write( data = l_error ).
l_buffer = conv->get_buffer( ).
move l_buffer to l_hexa.
move l_hexa to l_hex-line.
APPEND l_hex to lt_contents_hex.
ENDLOOP.
End of Insert CHRK941885
File name for attachment
l_wa_obj = l_c_name.
APPEND l_wa_obj TO lt_objhead.
CLEAR l_wa_obj.
DESCRIBE TABLE lt_objbin LINES l_tab_lines.
Creation of the entry for the compressed attachment
l_wa_objpack-transf_bin = 'X'.
l_wa_objpack-head_start = 1.
l_wa_objpack-head_num = 1.
l_wa_objpack-body_start = 1.
l_wa_objpack-obj_name = l_c_name.
l_wa_objpack-obj_descr = l_c_name.
l_wa_objpack-body_num = l_tab_lines.
l_wa_objpack-doc_size = l_tab_lines * l_c_255.
APPEND l_wa_objpack TO lt_objpack.
CLEAR l_wa_objpack.
Completing the recipient list
LOOP AT s_email.
l_wa_reclist-receiver = s_email-low.
l_wa_reclist-express = 'X'.
l_wa_reclist-rec_type = 'U'.
APPEND l_wa_reclist TO lt_reclist.
CLEAR l_wa_reclist.
ENDLOOP.
Document to send
MOVE 'Health Risk Assessment Batch extract'(h01)
TO l_wa_doc_chng-obj_descr.
Send mail as a confidential
l_wa_doc_chng-sensitivty = 'P'.
Send the document
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = l_wa_doc_chng
put_in_outbox = ' '
commit_work = 'X'
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin " Comment CHRK941885
contents_txt = lt_objtxt
contents_hex = lt_contents_hex " Insert CHRK941885
receivers = lt_reclist
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 s000(oo) WITH 'Email sent to recipients'(s12).
To refresh SAP Work Office so that mail can be recieved immediataly.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = ''
AND RETURN.
ELSE.
MESSAGE e000(oo) WITH 'Problem sending Email.'(e02).
ENDIF. -
Problem in FM SO_DOCUMENT_SEND_API1
Dear All
I am using FM SO_DOCUMENT_SEND_API1 to send excel attachment in a mail.
The data is coming correctly but data in one column is coming in distorted format with lot of spaces that are not given at any point. I used 'CONDENSE' in all fields but it didnt help.
Kindly advice where can be the problem or any alternative FM.
Thanks in advance.
Regards
Dineshhi,
use the procedure given below it will definately solve your problem:
*Firstly export the data to memory using the FM LIST_FROM_MEMORY.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc 0.
MESSAGE e000(su) WITH text-001.
ENDIF.
then i converted it into ASCII using LIST_TO_ASCI,
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_xlstab
listobject = t_listobject
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE e003(yuksdbfzs).
ENDIF.
This gives the data in ASCII format separated by '|' and the header has '-', dashes. If you use this internal table directly without any proccesing in SO_NEW_DOCUMENT_ATT_SEND_API1, then you will not get a good excel sheet attachment. To overcome this limitation, i used cl_abap_char_utilities=>newline and cl_abap_char_utilities=>horizontal_tab to add horizontal and vertical tabs to the internal table, replacing all occurences of '|' with
cl_abap_char_utilities=>horizontal_tab.
Set the doc_type as 'XLS', create the body and header using the packing_list and pass the data to be downloaded to SO_NEW_DOCUMENT_ATT_SEND_API1 as contents_bin.
This will create an excel attachment.
Sample code for formatting the data for the attachment in excel format.
u2022 Format the data for excel file download
LOOP AT t_xlstab INTO wa_xlstab .
DESCRIBE TABLE t_xlstab LINES lw_cnt.
CLEAR lw_sytabix.
lw_sytabix = sy-tabix.
u2022 If not new line then replace '|' by tabs
IF NOT wa_xlstab EQ cl_abap_char_utilities=>newline.
REPLACE ALL OCCURRENCES OF '|' IN wa_xlstab
WITH cl_abap_char_utilities=>horizontal_tab.
MODIFY t_xlstab FROM wa_xlstab .
CLEAR wa_xlstab.
wa_xlstab = cl_abap_char_utilities=>newline.
IF lw_cnt NE 0 .
lw_sytabix = lw_sytabix + 1.
u2022 Insert new line for the excel data
INSERT wa_xlstab INTO t_xlstab INDEX lw_sytabix.
lw_cnt = lw_cnt - 1.
ENDIF.
CLEAR wa_xlstab.
ENDIF.
ENDLOOP.
Sample code for creating attachment and sending mail:
FORM send_mail .
u2022 Define the attachment format
lw_doc_type = 'XLS'.
u2022 Create the document which is to be sent
lwa_doc_chng-obj_name = 'List'.
lwa_doc_chng-obj_descr = w_subject. "Subject
lwa_doc_chng-obj_langu = sy-langu.
u2022 Fill the document data and get size of message
LOOP AT t_message.
lt_objtxt = t_message-line.
APPEND lt_objtxt.
ENDLOOP.
DESCRIBE TABLE lt_objtxt LINES lw_tab_lines.
IF lw_tab_lines GT 0.
READ TABLE lt_objtxt INDEX lw_tab_lines.
lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
lwa_doc_chng-obj_langu = sy-langu.
lwa_doc_chng-sensitivty = 'F'.
ELSE.
lwa_doc_chng-doc_size = 0.
ENDIF.
u2022 Fill Packing List For the body of e-mail
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lw_tab_lines.
lt_packing_list-doc_type = 'RAW'.
APPEND lt_packing_list.
u2022 Create the attachment (the list itself)
DESCRIBE TABLE t_xlstab LINES lw_tab_lines.
u2022 Fill the fields of the packing_list for creating the attachment:
lt_packing_list-transf_bin = 'X'.
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 0.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lw_tab_lines.
lt_packing_list-doc_type = lw_doc_type.
lt_packing_list-obj_name = 'Attach'.
lt_packing_list-obj_descr = w_docdesc.
lt_packing_list-doc_size = lw_tab_lines * 255.
APPEND lt_packing_list.
u2022 Fill the mail recipient list
lt_reclist-rec_type = 'U'.
LOOP AT t_recipient_list.
lt_reclist-receiver = t_recipient_list-address.
APPEND lt_reclist.
ENDLOOP.
u2022 Finally send E-Mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = lwa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = lw_sent_to_all
TABLES
packing_list = lt_packing_list
object_header = lt_objhead
contents_bin = t_xlstab
contents_txt = lt_objtxt
receivers = lt_reclist
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.
Hope it will help you
Regards
Rahul sharma -
Sending mails to Internal SAP ID using SO_DOCUMENT_SEND_API1!!
Hi
I was trying to send mail using fm SO_DOCUMENT_SEND_API1 but why problem is the internal table that needs to be passed has (contets bin ) has only 255 chars ...
but my data sets are huge and i need to send all of them in mail..so the remaining data is not getting reflected in the excel file....
whats the way out?
CONTENTS_BIN STRUCTURE SOLISTI1 OPTIONAL
Points for sure
Regards
GunjanHi,
*& Report ZTESTMAIL *
REPORT ZTESTMAIL .
tables: bseg.
parameters: p_email type somlreci1-receiver default
'[email protected]'.
data: it_message type standard table of solisti1 initial size 0
with header line.
data: it_attach type standard table of solisti1 initial size 0
with header line.
DATA: begin of int_bseg occurs 0,
zuonr like bseg-zuonr,
end of int_bseg.
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,
gd_error type sy-subrc,
gd_reciever type sy-subrc.
*START_OF_SELECTION
start-of-selection.
Retrieve sample data from table ekpo
perform data_retrieval.
Populate table with detaisl to be entered into .xls file
*perform build_xls_data_table.
*END-OF-SELECTION
end-of-selection.
Populate message body text
perform populate_email_message_body.
Send file by email as .xls speadsheet
perform send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Assignment Date after 2 days'
'XLS'
'filename'
changing gd_error
gd_reciever.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
select zuonr from bseg into corresponding fields of int_bseg.
endselect.
DATA: begin of int_bseg1 occurs 0,
zuonr1 like bseg-zuonr,
end of int_bseg1.
loop at int_bseg.
int_bseg1-zuonr1 = int_bseg-zuonr.
endloop.
endform. " DATA_RETRIEVAL
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
form send_file_as_email_attachment tables pit_message
pit_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.
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[] = pit_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.
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
object_header = t_object_header
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.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
form initiate_mail_execute_program.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
endform. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
refresh it_message.
it_message = 'Assignment Date is coming After 2 Days Please check doc.'.
append it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY
Reward if helpfull
Regards,
Nandha -
Excel attachment using SO_DOCUMENT_SEND_API1
Hi
I am using FM SO_DOCUMENT_SEND_API1 to send .XLS attachment from ABAP program.
I am using following code to calculate the size.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_size = t_packing_list-body_num * 255.
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
(I have posted only relevant code)
This was working fine in 4.7. But since upgrade to 6.0, the attachment is transferred only half the actual size.
i.e. if my internal table shows 4 records, the attachment in the mail shows only 2 records.
What can be done in this case. A simple solution would be to multiply the size by 2.
t_packing_list-doc_size = t_packing_list-body_num * 255 * 2.
This works, but does seem like a work around.
What could be the reason for this and what should be the solution?Hi,
I am also using 6.0 and similar logic is working fine to calculate the size. I think there must be some problem some where else in the code. Can you put your code that you have used.
Thanks & Regards
Rocky -
FAX Sazpscript using SO_DOCUMENT_SEND_API1
Hi,
Im using SO_DOCUMENT_SEND_API1 FM to sned the sapscript thru fax...
I have just a question about the FROM and TO fields on the cover of the fax...
Currently my output has no value on the said fileds... I want to put values on those fields... How am I going to do that?
Thanks a lot!check this link for all your querries
Re: SAPScript to email and fax
Please Check this one:
SAP Script->PDF->Email
have alook at this code also
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = mi_rqident
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.
then call FM after populating attachment data
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
also u can chk sample programe.
Refer to the code in the following link:
http://www.sapdev.co.uk/reporting/rep_spooltopdf.htm
do reward if helpful
Maybe you are looking for
-
Upload transaction data for transactions like KSU2/KSU5,KB31N
We are trying to upload transaction data for transactions like KSU2/KSU5,KB31N etc using batch data processing within LSMW. We are facing couple of problems as mentioned:<br /> We have to upload data, which has a single header record with 200-300 lin
-
Files added to server take time to show for other users
Various users add files to server and other users with folder access cannot see files for sometimes up to 2 hours before the files appear. It is not a rights issues as when the file final appear in the directory they can access the file and use.
-
Problems Installing Mountain Lion (Can't Download Additional Content)
I have tried to install Mountain Lion like 5 time and I always get a Message saying that "Can't Download Additional Content" and I cant get pass throught it. What Can I do to install it. I have deleted my Hard Drive like 5 times for the process.
-
Installing Elements 12 from Purchased CD
Should I uninstall the trial version of Elements 12 before installing my purchased version from CD?
-
NLS_LANG that supports both Japanese and Spanish
Hi All, I need to insert Japanese scripts into my custom table. So I did setup the NLS_LANG to support the Japanese scripts as American_America.JA16SJIS. The japanese data got inserted into the table. Now, the spanish characters, which i have shows u