Function for Sending Mail Thru SAP
Please let me know if there is any function available in SAP thru wich I can send Emails to other mail box . Please give me some example code if any available.
Kindly refer the below code to send a fiel as an attachment via MAil from SAP -
*& Report ZGILL_SENDMAIL_PDF *
REPORT ZGILL_SENDMAIL_PDF .
INCLUDE ZGILL_INCMAIL. "SEE BELOW FOR INCLUDE PROGRAM CODE.
DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case DEFAULT '[email protected]'.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY DEFAULT 'C:\TEMP\SALARY_SLIP1.PDF'.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = extension
NAME = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
*********************iNCLUDE pROGRAM********************************************
*& Include ZGILL_INCMAIL *
Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
FORM
FORM ml_customize USING objname objdesc.
Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
Header Data
Already Done Thru FM
Main Text
Already Done Thru FM
Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
Receiver List
Already done thru fm
ENDFORM. "ml_prepare
FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
object_parb =
receivers = 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 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
Data
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
**********************INCLUDE END********************************
Similar Messages
-
How can I create a schedule in Java for sending mail from SAP?
Hello;
I am coding a programme in Java which reads data from KM. I wish to schedule a job which sends mail to a list of persons selected from KM. I read the article by Prakash Singh and based my programme on his explanations.
/people/prakash.singh4/blog/2005/04/20/did-you-know-you-can-schedule-jobs-in-portal-using-kms-scheduler-task
My first problem is that I don't know how to send mail in SAP, and how to use Java to send this mail. My second problem is how to develop this "schedule job" function - is it enough to use Prakash Singh's method, or does it need to be changed?
Can anyone help me with these questions?
Thank you very much, R.E.Hi,
I dont know about the CATS system. But when ur user selects the varaint, he should remove his own id and execute the query. This should display all the variants existing for that program. Then he can select the required variant.
The user can also save this varaint under his own ID
Hope it helps.
Regards.
Jay Gandhi -
Problem in sending mail thru SAP.
Hi All
I have typical problem in sending Purchase order thru mail to vendor.
We are sending Purchase Order to our vendor thru mail and copy of purchase order as attachment in pdf file.
I am sending Purchase Order number 45XXXX01, vendor is getting something else say 45XXXX03. But when I checked the same in outbox in SAP business workplace then it is found correct i.e. Purchase Order number 45XXXX01 but when vendor open his attachment then he is found Purchase Order number 45XXXX03.
Following FMu2019s are used in y-program to send mail.
CONVERT_OTF u2013 To convert into pdf.
SO_DOCUMENT_SEND_API1 u2013 To send mail.
I do not understand why it is happening.
Kindly suggest something to overcome this.
Regards,
Rajesh VasudevaHey do as follow
1 > When you send the mail , after running ur program , you furst open the sent data from SOST or SCOTT etc. and see is it a correct data.
2 > Try sending the mail to urself , also try to mention ur id along with vendors Id and see what do u get also same time check what r u sending.
Hopefully it will give you some idea.
Regards,
Uma Dave -
I have written a program to send mail thru SAP, whcih was working fine till date. Suddenly it started giving problem.
Body of the message is now going as an attachment which was working fine previously.
I am using following function.
concatenate 'Please find attached Vendor Age Report for BA - '
gt_vendor_mail-gsber ' .'
into p_it_message.
append p_it_message.
p_it_message = 'Message Body text, line 2...'.
append p_it_message.
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = wa_w_doc_data
put_in_outbox = 'X'
sender_address = lv_sender_address
sender_address_type = lv_sender_address_type
commit_work = 'X'
importing
sent_to_all = lv_w_sent_all
tables
packing_list = lt_packing_list
contents_bin = lt_attachment
contents_txt = p_it_message
receivers = lt_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.
Please help.
Regards,
Sachin RautHi,
Check your settings in TCODE SCOT
Double click on SMTP note . For "Internet" click on set, under "Output format for SAP documents" RAW Text musts be set as "TXT"
[Email attachment poblem|Re: email attachment poblem]
Regards -
Error in sending mail from SAP to microsoft outlook
Hi all.
Greetings.
I have a requirement to send mail from SAP to Outlook.
SMTP is configured here....i have checked the steps.
I am using FM "SO_NEW_DOCUMENT_SEND_API1" to send the mail text.
when i check the SOST Tcode i got message "Wait for communications service".
after evry 10 minutes the sap connect all process runs..as it is configured in SCOT transaction, but even after 30 minutes the mail is not sent.
I don't know how should i check the error message?
tell me the checking stepls plz?...how should i step through in checking this?
what are the prerequsites for sending mails from SAP to Microsoft outlook?
regards
Prashant Tiwari
Edited by: prashant tiwari on Feb 6, 2009 10:26 AMHi prashant,
Pls refer to the link below:
Re: Inbound Email- SAP Connect
or
check your userid .
If not correct no mail will go from u r id.
Try it with another user id.
or try using the following function module
'SO_NEW_DOCUMENT_ATT_SEND_API1'
I Hope this helps you with the issue.
Thanks
Ravi Aswani -
Function module to send mail from SAP
Can any one please tell the Function module to send mail from SAP. The scenario is like this,I have a file in local system that i have to send to a particular mail address like [email protected] through a report program.
Hi shafiq,
1. There is some trick involved
in the binary files.
2. I have made a program (and it works fantastic)
ONLY 6 LINES FOR EMAILING
BELIEVE ME
ITS A FANTASTIC PROGRAM.
IT WILL WORK LIKE OUTLOOK EXPRESS !
3. The user is provided with
a) file name
b) email address to send mail
and it sends ANY FILE (.xls,.pdf .xyz..)
Instantaneously !
4. Make two things first :
1. Include with the name : ZAMI_INCLFOR_MAIL
2. Report with the name : ZAM_TEMP147 (any name will do)
3. Activate both and execute (2)
4. After providing filename, email adress
5. Code for Include :
10.08.2005 Amit M - Created
Include For Mail (First Req F16)
Modification Log
Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
FORM
FORM ml_customize USING objname objdesc.
Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
Header Data
Already Done Thru FM
Main Text
Already Done Thru FM
Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
Receiver List
Already done thru fm
ENDFORM. "ml_prepare
FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
object_parb =
receivers = 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 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
Data
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
CODE FOR PROGRAM
5.
REPORT zam_temp147 .
INCLUDE zami_inclfor_mail.
DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = extension
NAME = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
regards,
amit m. -
Looking for function that send mail
I AM LOOKING FOR A FUNCTION THAT SEND MAIL
<b><b>WITH ATTACMENT ONLY</b> ANYONE KNOW????
THANKS.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
check this Program...... -
Send mail from SAP system to another SAP system
Hello Xperts
I need to send a mail from one SAP box (ECC) to another SAP box (SRM,CRM, EP etc). I know how to send mail from SAP to external address but unable to find the parameters in this case. Kindly help.
thkx
Prabhu
PS: Kindly DONOT post on "How to send mail from SAP" as my questions is all abt how to send mail from one sap system to another sap systemHi
To send mail Internally check this sample code it works fine this code was developed by me
*& Report ZMATURITYREPORT *
*& Title - Maturity report *
*& ABAP/4 Consultant *
*& Name- Pavan Praveen Valluri Created on 26/07/2007 *
*& Module - FI *
REPORT ZMATURITYREPORT.
tables: bseg.
* SELECTION SCREEN--------------------------------------------------- *
parameters: p_email type somlreci1-receiver default
'@gujaratpetro.com'.
* Data: p_email(25) type c value '[email protected]'.
* END OF SELECTION SCREEN ------------------------------------------- *
*----------DATA DECLARATION--------------------------------------------*
data: it_message type standard table of solisti1 initial size 0
with header line.
data: it_message1 type standard table of solisti1 initial size 0
with header line.
data: it_message2(10) type N.
data: it_message3 type standard table of solisti1 initial size 0
with header line.
data: it_message4 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: text(150).
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.
data: lv_date type sy-datum.
data: lv_date1 type sy-datum.
data: lv_formatdate(10) type c.
data: lv_formatdate1(10) type c.
data: var1(4) type c,
var2(2) type c,
var3(2) type c.
data: begin of int_bseg occurs 0,
BELNR LIKE BSEG-BELNR,
ZUONR LIKE BSEG-ZUONR,
GJAHR LIKE BSEG-GJAHR,
DMBTR LIKE BSEG-DMBTR,
HKONT LIKE BSEG-HKONT,
end of int_bseg.
data: begin of int_SKAT occurs 0,
TXT50 LIKE SKAT-TXT50,
SAKNR LIKE SKAT-SAKNR,
KTOPL LIKE SKAT-KTOPL,
end of int_SKAT.
data: begin of int_bkpf occurs 0,
BELNR LIKE BKPF-BELNR,
BUKRS LIKE BKPF-BUKRS,
GJAHR LIKE BKPF-GJAHR,
BUDAT LIKE BKPF-BUDAT,
end of int_BKPF.
data: 2days_out type sy-datum.
2days_out = sy-datum + 2.
data: var4(4) type c,
var5(2) type c,
var6(2) type c.
*-------- END OF DATA DECLARATION--------------------------------------*
*--- CONCATENATING AND ARRANGING DATE ---------------------------------*
lv_date = 2days_out.
var1 = lv_date+(4).
var2 = lv_date+4(2).
var3 = lv_date+6(2).
concatenate var3 var2 var1 into lv_formatdate separated by '.'.
*--- END OF CONCATENATING AND ARRANGING DATE -------------------------*
*-------------------------SELECTION FOR BSEG---------------------------*
select zuonr belnr bukrs GJAHR DMBTR HKONT from bseg into
corresponding fields of table int_bseg
where bukrs = 'company name' and
ZUONR = lv_formatdate.
*--------------END OF SSELECTION FOR BSEG--------------------------- *
*-------------------------SELECTION FOR BKPF---------------------------*
select BUDAT BUKRS BELNR GJAHR from BKPF into
corresponding fields of table int_BKPF
where bukrs = 'company name'.
append int_BKPF.
*------------------END OF SELECTION FOR BKPF---------------------------*
*-------------------------SELECTION FOR SKAT---------------------------*
select SAKNR TXT50 from SKAT into
corresponding fields of table int_SKAT
where KTOPL = 'company name'.
*and SAKNR = INT_BSEG-HKONT.
APPEND INT_SKAT.
*--------------END OF SSELECTION FOR SKAT--------------------------- *
*-----------------POPULATING EMAIL SUBJECT ----------------------------*
perform populate_email_message_body.
perform send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Maturity 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.
*endif.
end-of-selection.
*------------END OF POPULATING EMAIL SUBJECT --------------------------*
*& 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. "send_file_as_email_attachment
*& 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.
refresh it_message1.
refresh it_message3.
refresh it_message4.
*--------------- LOOP FOR BSEG -----------------------------------------
loop at int_BSEG.
read table int_bKPF WITH KEY BELNR = INT_BSEG-BELNR
GJAHR = INT_BSEG-GJAHR.
read table int_SKAT WITH KEY SAKNR = INT_BSEG-HKONT.
*---CHANGING DATE FORMAT FOR BKPF---------------------------------------
lv_date1 = int_bkpf-budat.
var4 = lv_date1+(4).
var5 = lv_date1+4(2).
var6 = lv_date1+6(2).
concatenate var6 var5 var4 into lv_formatdate1 separated by '.'.
*---END OF CHANGING DATE FORMAT FOR BKPF-------------------------
it_message = int_bseg-belnr.
it_message1 = lv_formatdate1.
it_message2 = int_bseg-dmbtr.
it_message3 = int_bseg-hkont.
IT_MESSAGE4 = INT_SKAT-TXT50.
SHIFT IT_MESSAGE2 LEFT DELETING LEADING '0'.
*-------------POPULATING EMAIL BODY WITH DATA -------------------------
concatenate 'Maturity After 2Days' 'for' 'G/L account-' it_message3
'--' IT_MESSAGE4 ',' 'Amount-' it_message2
into it_message separated by space.
append it_message.
append it_message1.
append it_message3.
clear it_message.
clear it_message1.
clear it_message2.
clear it_message3.
endloop.
*------------END OF LOOP FOR BSEG --------------------------------------
endform. " POPULATE_EMAIL_MESSAGE_BODY
<b><i>
To send an mail with external attachment check this one
</b></i>
<i>first create a Include report with the following coding</i>
*& Include ZPA1_INCLFOR_MAIL *
* Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
* FORM
FORM ml_customize USING objname objdesc.
*----------- Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
*--------- Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
* FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
* FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
* FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
*--------- Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
* IMPORTING
* COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
* Header Data
* Already Done Thru FM
* Main Text
* Already Done Thru FM
* Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
* Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
* Receiver List
* Already done thru fm
ENDFORM. "ml_prepare
* FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
* CONTENTS_HEX = objhex
* OBJECT_PARA =
* object_parb =
receivers = 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 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
* FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
*-------------- Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
*------------- Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
* FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
*-------- Data
DATA : pos TYPE i.
DATA : len TYPE i.
*------------ Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
<b>
Then include that report in the following report and copy the same code and paste it there
</b>
*& Report ZPA_TEMP147 *
REPORT ZPA_TEMP147 .
INCLUDE zpa1_inclfor_mail.
* DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
* SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
* AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
* START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
* FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
* CHECK_DOS_FORMAT =
IMPORTING
* DRIVE =
EXTENSION = extension
NAME = name
* NAME_WITH_EXT =
* PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
<b>These are the FM for sending external email :-</b>
SO_DOCUMENT_SEND_API1
SAPoffice: Send new document with attachments via RFC
SO_NEW_DOCUMENT_ATT_SEND_API1
(In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)
SAPoffice: Send new document with attachments via RFC
Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject.
SO_NEW_DOCUMENT_SEND_API1
SAPoffice: Send new document
<b>Check this sample report</b>
DATA : BEGIN OF ITAB OCCURS 0,
PERNR LIKE PA0001-PERNR,
ENAME LIKE PA0001-ENAME,
END OF ITAB.
DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
listobject LIKE abaplist OCCURS 10,
compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
w_object_hd_change LIKE sood1,
compressed_size LIKE sy-index.
START-OF-SELECTION.
SELECT PERNR ENAME
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM PA0001
WHERE PERNR < 50.
LOOP AT ITAB.
WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
SY-VLINE.
ENDLOOP.
* Receivers
receiver_list-recextnam = '[email protected]'. "-->
* EMAIL ADDRESS
RECEIVER_list-RECESC = 'E'. "<-
RECEIVER_list-SNDART = 'INT'."<-
RECEIVER_list-SNDPRI = '1'."<-
APPEND receiver_list.
* General data
w_object_hd_change-objla = sy-langu.
w_object_hd_change-objnam = 'Object name'.
w_object_hd_change-objsns = 'P'.
* Mail subject
w_object_hd_change-objdes = 'Message subject'.
* Mail body
APPEND 'Message content' TO message_content.
* Attachment
CALL FUNCTION 'SAVE_LIST'
EXPORTING
list_index = '0'
TABLES
listobject = listobject.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
compressed_size = compressed_size
TABLES
in = listobject
out = compressed_attachment.
DESCRIBE TABLE compressed_attachment.
CLEAR packing_list.
packing_list-transf_bin = 'X'.
packing_list-head_start = 0.
packing_list-head_num = 0.
packing_list-body_start = 1.
packing_list-body_num = sy-tfill.
packing_list-objtp = 'ALI'.
packing_list-objnam = 'Object name'.
packing_list-objdes = 'Attachment description'.
packing_list-objlen = compressed_size.
APPEND packing_list.
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
object_hd_change = w_object_hd_change
object_type = 'RAW'
owner = sy-uname
TABLES
objcont = message_content
receivers = receiver_list
packing_list = packing_list
att_cont = compressed_attachment.
<b>Settings for sending mail</b>
Configuring SAP 4.6x Internet mail Gateway
SAP can be configured to send and receive emails from different sources.This section explains how to integrate SAPOffice with an external emailsystem. Your Internet email must be configured and running prior to this.Email from SAP is forwarded to the users external email system..
You can configure inbound and outbound forwarding. Outbound flow forwardsa SAP message (eg: update termination) via UNIX sendmail to the intended recepient. Inbound accepts a message from sendmail and places it in the users SAPOffice inbox. Many companies prefer to configure outbound only.
Configuring outbound forwarding
SAP configuration
1. Create your RFC destination for outbound email using transaction SM59
RFC Destination : SAP_INTERNET_GATEWAY
Connection Type : T
Description : SAP internet mail gateway
Click on 'Explicit Host' if you wanton demand gateway dameon invocation.
Program : /sapmnt/SID/exe/mlunxsnd
Target Host : Enter hostname that runs your central instance.
Click 'Test Connection' and you should seea successfull message.
2. Shared Office Settings transaction SO16-> Send -> Settings or
directly via transaction SCOT- SAPconnect Administation
Nodes - Create
Node : IMAIL
Description : SAP internet mail gateway
RFC Destination : SAP_INTERNET_GATEWAY
Tick : Internet
Address Area : *
Tick : All formats
Dev. type : Choose an approciate Printer Device
Set further addresstype : N
Maximum waiting timefor repeat send attempt procedure : Blank or decide for yourself
Tick : Node is ready for use
Setting
- DefaultDomain : <your company domain>.com
- Conversionrule : require if your communication device only support one format.
e.g. if you email system only support the format RAW (ASCII text format)
Format To Format Ranking Function module
ALI RAW 1 SX_OBJECT_CONVERT_ALI_RAW (convert APAP List)
Referto note 171698 - SAPconnect: Formats, conversion, device type
UNIX configuration
1 .. cd /sapmnt/SID/exe
2 ..csh
..mlsomadm mailgw.ini
System Name [C11] :
Client [000] :
Username : MAILADM
Password : MAILADM
Language : E
Load Balancing :
Hostname : <hostname>
System number : <instance_number>
Gateway hostname: <central_instance_hostname>
Gateway Service : <instance number>
Use SAP Router :
Trace level :
Sendmail Command [/usr/lib/sendmail -i -f<SENDER_ADDRESS>]:
Codepage [ISO-8859-1] :
Trace Level (Outbound) [0] :
Update file sapmailsid.cfg? [Y]
Testing whether your configuration is successful
1. Logon to SAP
2. Execute transaction SO01
3. Write a message and send it to <your_internet_email_address>
4. If you don't see the mail in your internet mailbox, go back and review steps 1-12
Schedule the SAP Internet Mail Gateway Jobs to start every 5 minutes
1. Create
2. Position your cursor at INT
3. Click Schedule and supply the date and time
4. Click Schedule periodically and tick Minutes and type in 5
5. Click Create and you are done
6. Click Show Scheduling to check
Problems that you might encounter :-
If you have set up a node in SCOT and it tests out well but recieve the reply.
"Cannot process message in node, parameterscannot be converted".
Make sure the RFC connection is working, and that SapConnect has been installed on the Unix Server or the Microsoft Exchange Server. Originally, I had the same error, and found that nothing had been installed on Unixor Exchange, to support SapConnect.
In SCOT (View -> System Status), your mail remains at the Intransit column.
Check you sendmail.cf files (e.g.Sun Solaris /etc/mail/sendmail.cf). Try using the sendmail command to send a test file at the Unix level. You must be able to send mail at theUnix level before you can send mail at the SAP level.
http://help.sap.com/saphelp_nw04/helpdata/en/cf/700b405bacdd5fe10000000a155106/content.htm
http://www.tamboly.com/SAPEmailConfiguration.html
Check my previous links
Mail Send
sending mails from abap program
Mail Sending to external email id's
settings needed for sending emails
Regards
Pavan -
Problem while sending mail from SAP
Hi ABAP gurus,
I tried to send mail from SAP. For this we configured SMTP Services using the transaction SCOT and all are Completed.
When I send a mail using SAPOffice it is Executing successfully and main is delivered to me.
When I tried in the program using the function module 'SO_NEW_DOCUMENT_SEND_API1' mail is not delivered to me but it is placed in SAPoffice outbox.The status of the mail says "SEND PROCESS STILL RUNNING". Even when i execute SAPconnect manually mail is not transmitted.
This is the transaction history of the mail.
Trans. history
18.02.2006 13:44:31 Document sent
13:44:31 Wait for communications service
After This stage Delivery attempt is not taking place.
This is the Code
****Document DATA
EMAIL_DATA-OBJ_NAME = 'MESSAGE'.
EMAIL_DATA-OBJ_DESCR = SUBJECT.
EMAIL_DATA-OBJ_LANGU = 'E'.
EMAIL_DATA-SENSITIVTY = 'P'.
EMAIL_DATA-OBJ_PRIO = '1'.
EMAIL_DATA-NO_CHANGE = 'X'.
EMAIL_DATA-PRIORITY = '1'.
***Receiver
EMAIL_SEND-RECEIVER = '[email protected]'.
EMAIL_SEND-REC_TYPE = 'U'.
EMAIL_SEND-EXPRESS = 'X'.
APPEND EMAIL_SEND.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = EMAIL_DATA
DOCUMENT_TYPE = 'RAW'
PUT_IN_OUTBOX = 'X'
IMPORTING
SENT_TO_ALL = SENT
NEW_OBJECT_ID = EMAIL_ID
TABLES
OBJECT_CONTENT = EMAIL_TEXT
RECEIVERS = EMAIL_SEND
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.
Please Help me to solve this Problem.
Regards,
Viswanath Babu.P.DHi viswanath,
1. in scot, in smtp node,
2. press the internet button
3. In ADDRESS AREA,
type
*yahoo.com
*rediffmail.com
etc,etc.
4. Only when such domains are entered,
will sap send mail.
5. It will not send any mail to other domains.
6. Or simply enter *
regards,
amit m. -
How can i send mails from SAP?
how can i send mails from SAP?
what are the configurations i have to do in SAP for that?
pls give me a detail reply......
if possible, pls give me the sample ABAP program for that.recently i have worked on a similar requirement here is the sample code for that
REPORT ZDOC_AS_EMAIL_3.
*& Report ZEMAIL_ATTACH *
*& Example of sending external email via SAPCONNECT *
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: l_t_objhead LIKE solisti1 OCCURS 1 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.
*CONSTANTS: con_cret(2) TYPE c VALUE '0D', "OK for non Unicode
*con_tab(2) 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.
CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
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 = 'REPORT'.
w_doc_data-obj_descr = ld_mtitle . "mail description
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 1st attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 0.
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.
**Create 1st attachment notification
*t_packing_list-transf_bin = 'X'.
*t_packing_list-head_start = 0.
*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.
**Create 2nd attachment notification
data: x type i.
DESCRIBE TABLE t_attachment LINES X.
append lines of it_attach to t_attachment.
data: start type i,
end type i,
cal type i.
start = X + 1.
describe table t_attachment lines end.
cal = end - start.
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 0.
t_packing_list-head_num = 1.
t_packing_list-body_start = start.
t_packing_list-body_num = end.
*DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-obj_descr = 'Eng Change'. "ld_attdescription.
t_packing_list-doc_type = ld_format.
*t_packing_list-obj_name = 'Eng' .
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
object_header = l_t_objhead
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 -
Error while sending mail from SAP
Hello All,
Recently we are facing an error while sending mail from SAP. When we try to compose a message ,it is moving to a dump error RAISE_EXCEPTION.
The details from ST22,
Short text
Exception condition "FOLDER_NOT_EXIST" raised.
Error analysis
A RAISE statement in the program "SA
condition "FOLDER_NOT_EXIST".
Since the exception was not intercep
program, processing was terminated.
Kindly suggest..
Thank You,
Regards,
HasanHello Priyanka,
Actually, I performed the following two steps in order to solve the issue:
- In transaction SICF, the node for SAPConnect must be active. In our system, this node was in inactive state. Hence I activated it.
- Then In transaction SCOT-> Settings menu--> default domain should be 'xyz.com' if the email addresses in your company are maintained with a suffix xyz.com.
But for me the problem didnt get solved here..
The problem that i am facing now is that if in my user profile, I have the email address maintained, then i get an error saying 'Sender address rejected'. However, if i goto transaction SU01 and clear the email id, the mail is successfully sent to outer world.
You can try the above mentioned two steps using SICF and SCOT. If the problem does not get solved then try clearing the mail id in ur user profile.
Hope this helps. If you find an answer to the problem of the mail id getting cleared, then please let me know..
Regards,
Himanshu -
How to create distribution list in workflow? for sending mail or work-item
Hi,
How to create distribution list in workflow? for sending mail or work-item to multiple users.
Regards,
SurjithHi Surjith,
A.Working with Distribution Lists Creating a Distribution List.
1 Businees Workplace->shared folder - create new subfolder name = WF_distributor
2.Then click on the distribution list in Businees Workplace.
say create Name = WF_Vliste
folder Name = WF_distributor
3.distribution list content tab
Enter Recipient (SAP User ID)
B.Wrkflow Builder
Find out the dialig step in which u want to use distribution list
Use workflow Rule 30000012 (SWX_READ_DLI).
Maintain the binding from workflow container to rule container.
Just pass the name of the distribution list from WF to Rule container.
Regards
Sagar S -
CLASS cl_bcs Query for sender mail id
Hi,
I am using class cl_bcs.but, i am facing problem for sender mail-id. I want to append mail-id directly to sernder mail-id without using user mail attribute.
Is there ne way from which i can append mail-id as sender mail id??
thanx in advance,
Sameeryou can do that.
check this code sample.
DATA: sender TYPE REF TO if_sender_bcs.
CLEAR sender .
sender = cl_cam_address_bcs=>create_internet_address( '[email protected]' ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
and check this code sample for complete code.
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5931ff64-0a01-0010-2bb7-ff2f9a6165a0
Regards
Raja -
Hi all;
i am configuring alerts for sending mails . i am on XI 7.0 SP 2.i am not able to find an option like internal processing in ALRTCATDEF settings configurations.
Can this be the reason why mails are not getting send.Hi Mudit,
To send an EMAIL, assign an EMAIL ID to the corresponding user in the transaction SU01 and then set up SCOT and you can send emails when the ALERT is triggered.
Once you have configure Alerts, you will get the Alerts into ALERT INBOX in RWB of the user. To also get the email, the following needs to be done,
1. In SU01 -- Assign the Email ID for the Recipient of the ALERT.
2. In , RWB>ALERT INBOX> PERSONALIZATION--> Time Independent Delivery and Email are selected.
3. Finally, SCOT needs to be set up to send Emails. Check this for the same. You can ask your BASIS team to do this step.
http://help.sap.com/saphelp_nw04/helpdata/en/23/1edf098ea211d2b47300609419ed29/frameset.htm
Also, In ALRTCATDEF, go to SETTINGS--> CONFIGURATION. By default, the option selected is INTERNAL PROCESSING. Select the option SMTP FORWARDING AS XML and give the email id. This will enable you to send an email alert whenever an error occurs in XI.
Also, to test your Alerts, execute the report RSALERTTEST in SE38.
Also go throuh the following links...
/people/michal.krawczyk2/blog/2005/09/09/xi-alerts--troubleshooting-guide
/people/michal.krawczyk2/blog/2005/09/09/xi-alerts--step-by-step
http://help.sap.com/saphelp_nw04/helpdata/en/3f/81023cfa699508e10000000a11402f/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/80/942f3ffed33d67e10000000a114084/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/2b/d925bf4b8a11d1894c0000e8323c4f/frameset.htm
Regards,
Abhy
Message was edited by: Abhy Thomas -
Can't send any mailcan't send mail thru
Using 10.4.11
called my isp, that didn't help. with my isp account i got this message"5.1.0 Authentication required"
can't send mail thru any of my domains eithersWho is your ISP, and who are your email providers? What are the specific settings for the Incoming and Outgoing mail servers, including account type (POP or IMAP), port numbers, authentication method, and whether or not SSL is enabled for either? More details.
Mulder
Maybe you are looking for
-
"Devices" does NOT appear in itunes and my itouch cannot be detected, help?
For some unknown reason my itouch just quit syncing with itunes. I bought a new sync cord to no avail. I removed itunes from my laptop as directed and reinstalled. No change. In fact, itunes help, directs to reinstall the device only there is no "Dev
-
Static import from SE5 (Ex 16 on p. 91 in Thinking in Java Edn 4 by Eckel)
The following line of code is underlined: import static net.mindview.util.Print.*;with this error displayed: static import declarations are not supported in -source 1.4 (try -source 1.5 to enable static import declarations). My Path variable contains
-
Best practice of getting request parameters in JSP page
int period_Id = 0; try period_Id = Integer.parseInt(request.getParameter("period_id")); catch(Exception e) period_Id = 0; }This is the normal way we use to get parameters from previous page. But I am not sure if it is thebest practice. Please respo
-
Hi guys I just bught a WVC210 Wireless-G PTZ Internet Camera I need to install it so that I can view it from any where in the world. I have no Idea how to do this. I would like if some one can send me a video tutorial on how to do it. I have a websit
-
Hi, Can any body tell me procedure how to create transport rquest and how to release the request. Please tell me step by step procedure. Thanks Rajini