Helloguys, iattachmentan exampleforthejobnotifytheresultingreleasedby youviaemail.You mustuse theroutinein thereportofjobfairat the end ofthe process.Using the parameter 'flag' to indicatethe correctjobperformance(example'x' iswrong).Emailaddressmust beconfiguredinthe masterofusers.
CODE:
FORM MAIL USING FLAG.
DATA: PERSNUMBER TYPE AD_PERSNUM.
DATA: MAIL TYPE AD_SMTPADR.
DATA: w_buffer TYPE string.
DATA: BEGIN OF i_record OCCURS 0.
INCLUDE STRUCTURE solisti1.
DATA: END OF i_record.
DATA: BEGIN OF receivers OCCURS 0.
INCLUDE STRUCTURE somlreci1.
DATA: END OF receivers.
DATA: BEGIN OF object_header OCCURS 0.
INCLUDE STRUCTURE solisti1.
DATA: END OF object_header.
DATA: BEGIN OF contents_txt OCCURS 0.
INCLUDE STRUCTURE solisti1.
DATA: END OF contents_txt.
DATA: BEGIN OF contents_bin OCCURS 0.
INCLUDE STRUCTURE solisti1.
DATA: END OF contents_bin.
DATA: BEGIN OF contents_hex OCCURS 0.
INCLUDE STRUCTURE solix.
DATA: END OF contents_hex.
DATA: BEGIN OF packing_list OCCURS 0.
INCLUDE STRUCTURE sopcklsti1.
DATA: END OF packing_list.
DATA: BEGIN OF document_data OCCURS 0.
INCLUDE STRUCTURE sodocchgi1.
DATA: END OF document_data.
DATA: v_lines_bin LIKE sy-pagno.
DATA: v_lines_txt LIKE sy-pagno.
SELECT SINGLE PERSNUMBER
INTO PERSNUMBER
FROM USR21
WHERE BNAME = SY-UNAME.
IF SY-SUBRC = 0.
SELECT SINGLE SMTP_ADDR INTO MAIL FROM ADR6 WHERE PERSNUMBER = PERSNUMBER.
ENDIF.
IF MAIL IS INITIAL.
MESSAGE 'MAIL NOT FOUND' TYPE 'I'.
EXIT.
ENDIF.
receivers-receiver = MAIL.
receivers-express = 'X'.
receivers-rec_type = 'U'. "Internet address
APPEND receivers.
CLEAR object_header.
APPEND object_header.
* Object with main text of the mail.
contents_txt = 'JOB RESULTS'.
APPEND contents_txt.
CLEAR contents_txt.
APPEND contents_txt.
LOOP AT TI_EKPO_MSG INTO contents_txt.
APPEND contents_txt.
ENDLOOP.
IF FLAG IS NOT INITIAL.
CLEAR contents_txt.
APPEND contents_txt.
contents_txt = 'ERROR MESSAGE LINE1'.
APPEND contents_txt.
contents_txt = 'ERROR MESSAGE LINE2'.
APPEND contents_txt.
DESCRIBE TABLE contents_txt LINES v_lines_txt.
ENDIF.
CLEAR contents_txt.
contents_txt = 'REGARDS'.
APPEND contents_txt.
DESCRIBE TABLE contents_txt LINES v_lines_txt.
* Object with PDF.
CONTENTS_BIN[] = I_RECORD[].
APPEND CONTENTS_BIN.
DESCRIBE TABLE CONTENTS_BIN LINES V_LINES_BIN.
* Obj. to be transported not in binary form
CLEAR packing_list-transf_bin.
* Start line of object header in transport packet
packing_list-head_start = 1.
* Number of lines of an object header in object packet
packing_list-head_num = 0.
* Start line of object contents in an object packet
packing_list-body_start = 1.
* Number of lines of the object contents in an object packet
packing_list-body_num = v_lines_txt.
* Code for document class
packing_list-doc_type = 'RAW'.
APPEND packing_list.
* Document information.
document_data-obj_name = 'Smartform'.
document_data-expiry_dat = sy-datum + 10.
IF FLAG IS INITIAL.
CONCATENATE 'SUCCESS JOB' '-' sy-datum+6(2) '/' sy-datum+4(2) '/' sy-datum(4) INTO document_data-obj_descr.
ELSE.
CONCATENATE 'ERROR JOB' '-' sy-datum+6(2) '/' sy-datum+4(2) '/' sy-datum(4) INTO document_data-obj_descr.
ENDIF.
document_data-sensitivty = 'O'. "Standard
document_data-doc_size = v_lines_txt * 255.
APPEND document_data.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = document_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = packing_list
object_header = object_header
contents_bin = contents_bin
* contents_hex = contents_hex
contents_txt = contents_txt
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.
MESSAGE 'MAIL ERROR' TYPE 'I'.
ELSE.
MESSAGE 'MAIL SENT' TYPE 'I'.
ENDIF.
ENDFORM.
********
Regards.