on 02-23-2007 5:05 PM
Hi,
I am write the program for send email with pdf attachment. I have seen lot examples from sdn.sap i am using SO_NEW_DOCUMENT_ATT_SEND_API1 this function module. while executing this function module it is giving the error of dada not sent.( exception 2). Please any one help on this. thanks in advance.
Sending the document
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = maildata
put_in_outbox = ' '
tables
packing_list = mailpack
object_header = mailhead
contents_bin = mailbin
contents_txt = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
if sy-subrc ne 0 .
write:/ 'mail not sent' ,sy-subrc.
else.
write:/ 'mail has been sent' .
endif.
endform.
Hi
FORM SEND_MAIL.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
DATA L_NUM(3).
* Creation of the document to be sent
* File Name
DOC_CHNG-OBJ_NAME = 'SENDFILE'.
* Mail Subject
DOC_CHNG-OBJ_DESCR = 'Delivered Mail'.
* Mail Contents
OBJTXT = 'Object text'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
* Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
* Creation of the document attachment
LOOP AT ITAB_DATA.
CONCATENATE ITAB_DATA-PRODUCTOR
ITAB_DATA-VBELN
ITAB_DATA-POSNR
ITAB_DATA-MATNR INTO OBJBIN.
APPEND OBJBIN.
ENDLOOP.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = 'ORDERS'.
APPEND OBJHEAD.
** Creation of the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'TXT'.
OBJPACK-OBJ_NAME = 'WEBSITE'.
OBJPACK-OBJ_DESCR = 'ORDERS.TXT'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
* Completing the recipient list
* target recipent
clear RECLIST.
RECLIST-RECEIVER = 'test@here.com'.
RECLIST-EXPRESS = 'X'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
* copy recipents
clear RECLIST.
RECLIST-RECEIVER = 'secondtest@here.com'.
RECLIST-EXPRESS = 'X'.
RECLIST-REC_TYPE = 'U'.
RECLIST-COPY = 'X'.
APPEND RECLIST.
* Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHNG
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.
ENDFORM. " SEND_MAIL
Regards
Sudheer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am sending this program. Check it, it's working fine
TABLES: SCUSTOM, SBOOK, SPFLI.
SELECT-OPTIONS: S_ID FOR SCUSTOM-ID DEFAULT 1 TO 1,
S_FLI FOR SBOOK-CARRID DEFAULT 'LH' TO 'LH'.
DATA CUSTOMERS LIKE SCUSTOM OCCURS 100
WITH HEADER LINE.
DATA BOOKINGS LIKE SBOOK OCCURS 1000
WITH HEADER LINE.
DATA CONNECTIONS LIKE SPFLI OCCURS 1000
WITH HEADER LINE.
DATA: BEGIN OF SUMS OCCURS 10,
FORCURAM LIKE SBOOK-FORCURAM,
FORCURKEY LIKE SBOOK-FORCURKEY,
END OF SUMS.
DATA: cparam TYPE ssfctrlop,
outop TYPE ssfcompop,
fm_name TYPE rs38l_fnam,
my_tabix TYPE sy-tabix,
file_size TYPE i,
bin_filesize TYPE i.
DATA: tab_otf_data TYPE ssfcrescl,
pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
*itab LIKE TABLE OF zshail_t1 WITH HEADER LINE,
*otab TYPE TABLE OF sflight WITH HEADER LINE,
V_FORM_NAME TYPE RS38L_FNAM,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE.
start-of-selection.
suppressing the dialog box****************************
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = space.
cparam-getotf = 'X'.
SELECT * FROM SCUSTOM INTO TABLE CUSTOMERS
WHERE ID IN S_ID
ORDER BY PRIMARY KEY.
SELECT * FROM SBOOK INTO TABLE BOOKINGS
WHERE CUSTOMID IN S_ID AND CARRID IN S_FLI
ORDER BY PRIMARY KEY.
SELECT * FROM SPFLI INTO TABLE CONNECTIONS
FOR ALL ENTRIES IN BOOKINGS
WHERE CARRID = BOOKINGS-CARRID
AND CONNID = BOOKINGS-CONNID
ORDER BY PRIMARY KEY.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZMAN_FLIGHTFORMCOPY'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = V_FORM_NAME
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.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = cparam
OUTPUT_OPTIONS = outop
USER_SETTINGS = space
IMPORTING
JOB_OUTPUT_INFO = tab_otf_data
TABLES
IT_ITAB = CUSTOMERS
IT_ITAB1 = BOOKINGS
IT_ITAB2 = CONNECTIONS
IT_TEMP = BOOKINGS
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.
*********appending the otf data into the final table
*********************
tab_otf_final[] = tab_otf_data-otfdata[].
*removing the initial and final markers from the OTF data*********
DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.
searching for the end-of-page in OTF
table***********
READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.
my_tabix = sy-tabix + 1.
appending the modified OTF table to the final OTF
table***
*INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix
.
converting OTF data into pdf
data**************************
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
IMPORTING
bin_filesize = bin_filesize
BIN_FILE =
TABLES
otf = tab_otf_final
lines = pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
************downloading the converted PDF data to your local
PC*******
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = 'C:\TEST.PDF'
filetype = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
IMPORTING
filelength = file_size
TABLES
data_tab = pdf_tab
FIELDNAMES =
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
Rewards points if useful.
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am again the different program. It's working fine. The last posted is the different one.
I am using the smartforms in this program to converting it into pdf format & then send the pdf as a email attachment.
Internal Table declarations
DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
Objects to send mail.
I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
Work Area declarations
WA_OBJHEAD TYPE SOLI_TAB,
W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP,
W_RETURN TYPE SSFCRESCL,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1,
WA_BUFFER TYPE STRING, "To convert from 132 to 255
Variables declarations
V_FORM_NAME TYPE RS38L_FNAM,
V_LEN_IN LIKE SOOD-OBJLEN,
V_LEN_OUT LIKE SOOD-OBJLEN,
V_LEN_OUTN TYPE I,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I.
TABLES: SCUSTOM, SBOOK, SPFLI.
SELECT-OPTIONS: S_ID FOR SCUSTOM-ID DEFAULT 1 TO 1,
S_FLI FOR SBOOK-CARRID DEFAULT 'LH' TO 'LH'.
DATA CUSTOMERS LIKE SCUSTOM OCCURS 100
WITH HEADER LINE.
DATA BOOKINGS LIKE SBOOK OCCURS 1000
WITH HEADER LINE.
DATA CONNECTIONS LIKE SPFLI OCCURS 1000
WITH HEADER LINE.
DATA: BEGIN OF SUMS OCCURS 10,
FORCURAM LIKE SBOOK-FORCURAM,
FORCURKEY LIKE SBOOK-FORCURKEY,
END OF SUMS.
*DATA : FM_NAME TYPE RS38L_FNAM.
Get data
SELECT * FROM SCUSTOM INTO TABLE CUSTOMERS
WHERE ID IN S_ID
ORDER BY PRIMARY KEY.
SELECT * FROM SBOOK INTO TABLE BOOKINGS
WHERE CUSTOMID IN S_ID AND CARRID IN S_FLI
ORDER BY PRIMARY KEY.
SELECT * FROM SPFLI INTO TABLE CONNECTIONS
FOR ALL ENTRIES IN BOOKINGS
WHERE CARRID = BOOKINGS-CARRID
AND CONNID = BOOKINGS-CONNID
ORDER BY PRIMARY KEY.
*CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
*EXPORTING
*FORMNAME = 'ZMAN_FLIGHTFORMCOPY'
*IMPORTING
*FM_NAME = V_FORM_NAME
*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.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZMAN_FLIGHTFORMCOPY'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = V_FORM_NAME
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.
W_CTRLOP-GETOTF = 'X'.
W_CTRLOP-NO_DIALOG = 'X'.
W_COMPOP-TDNOPREV = 'X'.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = 'X'
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
TABLES
IT_ITAB = CUSTOMERS
IT_ITAB1 = BOOKINGS
IT_ITAB2 = CONNECTIONS
IT_TEMP = BOOKINGS
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.
*EXPORTING
*CONTROL_PARAMETERS = W_CTRLOP
*OUTPUT_OPTIONS = W_COMPOP
*USER_SETTINGS = 'X'
*IMPORTING
*JOB_OUTPUT_INFO = W_RETURN
*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.
I_OTF[] = W_RETURN-OTFDATA[].
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.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING '~'.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
REFRESH: I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
Create Message Body Title and Description
I_OBJTXT = 'test with pdf-Attachment!'.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = 'smartform'.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
WA_DOC_CHNG-SENSITIVTY = 'F'.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
Main Text
CLEAR I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = 'RAW'.
APPEND I_OBJPACK.
Attachment (pdf-Attachment)
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'smart'.
I_OBJPACK-OBJ_DESCR = 'test'.
APPEND I_OBJPACK.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = 'abc@yahoo.com'.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_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.
WRITE:/ 'Error When Sending the File', SY-SUBRC.
ELSE.
WRITE:/ 'Mail sent'.
ENDIF.
Reward points if useful.
Manoj
Hi,
Refer to the following link:
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf2.htm
Hope this helps.
Reward if helpful.
Regards,
Sipra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
The above code worked out well, except the error that the FM FUNC_CONVERT_DATA_ODC01 does not exists. I commented code related to this FM and directly passed it_soli to FM SO_NEW_DOCUMENT_ATT_SEND_API1 for the parameter CONTENTS_BIN. It worked.
I want to know what is FM FUNC_CONVERT_DATA_ODC01 ? My SAP version is ECC 5.0. By looking at the above code I assumed that this outputs hexadecimal data. I have another requirement to change from OTF to Hexadecimal data. Is there any FM to do this ? Your help is appreciated.
Thank you,
Surya
Hi,
I have exactly the same problem. I have a SapScript form with a logo on it. I wrote a print program that also retrieves the generated spool, convert it to PDF and emails this file in attachment. Everything worked well until we recently upgraded the system. Component SAP_BASIS and SAP_ABAP were upgraded from 19 To 55. Since then when we use the print program, the pdf seems to be corrupt for the image part. When opening the generated PDF file the message "There was an error while trying to parse an image" is showed. The PDF file is then opened but without the logo visible. I tried another image, but same problem. I tried other functions but same problem. It seems that all functions use the same function CONVERT_OTF inside and comparing the upgraded system with the former system shows that the difference arises at this point.
There is also the possibility to convert the spoolfile implicit to PDF by setting up a SAPConnect printer to email it as PDF attachment. This seems to convert the OTF to PDF correctly. This proves there is a way to do it correctly, but I need to know how this is working: which functions or programs are used to do the conversion.
Thanks,
Bart
Hi Gopal,
Check ut the following code for sending emails:
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_TEST'
IMPORTING
fm_name = v_fname.
CALL FUNCTION v_fname
EXPORTING
control_parameters = x_ctrl_p
IMPORTING
job_output_info = x_output_data.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 134
IMPORTING
bin_filesize = v_size
TABLES
otf = x_output_data-otfdata
lines = it_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_dst = 255
TABLES
content_in = it_lines
content_out = it_soli
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
CALL FUNCTION 'FUNC_CONVERT_DATA_ODC01'
EXPORTING
iv_byte_mode = 'X'
TABLES
it_data = it_lines
et_data = it_table.
*-----To caluculate total number of lines of internal table
DESCRIBE TABLE it_table LINES v_lines.
*-----Create Message Body and Title and Description
it_mess =
'i have successfully converted smartform from otf format to pdf' .
" and i have attached that in mail'.
APPEND it_mess.
wa_doc_data-obj_name = 'smartform'.
wa_doc_data-expiry_dat = sy-datum + 10.
wa_doc_data-obj_descr = 'smartform'.
wa_doc_data-sensitivty = 'F'.
wa_doc_data-doc_size = v_lines * 255.
APPEND it_pcklist.
*-----PDF Attachment
it_pcklist-transf_bin = 'X'.
it_pcklist-head_start = 1.
it_pcklist-head_num = 0.
it_pcklist-body_start = 1.
it_pcklist-doc_size = v_lines_bin * 255 .
it_pcklist-body_num = v_lines.
it_pcklist-doc_type = 'PDF'.
it_pcklist-obj_name = 'smartform'.
it_pcklist-obj_descr = 'smart_desc'.
it_pcklist-obj_langu = 'E'.
it_pcklist-doc_size = v_lines * 255.
APPEND it_pcklist.
*-----Giving the receiver email-id
CLEAR it_receivers.
it_receivers-receiver = abcd@yahoo.com'.
it_receivers-rec_type = 'U'.
APPEND it_receivers.
*-----Calling the function module to sending email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_pcklist
contents_txt = it_mess
contents_hex = it_table
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.
Reward points if helpful answer.
Ashvender
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gopal,
can u put commit work and try ....
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = maildata
put_in_outbox = ' '
<b>commit_work = 'X'</b>
tables
packing_list = mailpack
object_header = mailhead
contents_bin = mailbin
contents_txt = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
if sy-subrc ne 0 .
write:/ 'mail not sent' ,sy-subrc.
else.
write:/ 'mail has been sent' .
endif.
endform.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gopal,
Below links can help you for better understanding which i have got throught searching the forum. Thanks to the original info providers.
http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
Regards.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.