Need to send email with excel sheet as attachment: URGENT
Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
For kind information...there is only one selection field for entering the mail id.
Thanks in advance
Nanda
Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
For kind information...there is only one selection field for entering the mail id.
Thanks in advance
Nanda
Similar Messages
-
Urgent: Sending an Email with Excel sheet attachment
Hi All,
I am preparing a report and has to send mail with excel sheet attachement. In report i am getting everything fine. But in the mail i am not getting the data, data is passing to the FM succesfully. But in the mail, excel is not having full data.
the below mentioned is my code.
i_texts-line = c_stern.
i_texts-line+254(1) = c_newline.
APPEND i_texts.
LOOP AT i_texc.
i_att_line-line = i_texc.
APPEND i_att_line.
ENDLOOP.
DATA: wa_doc_chng LIKE sodocchgi1.
DATA: w_tab_lines LIKE sy-tabix.
STATICS: c_body_start TYPE i VALUE '1'.
CONSTANTS: lc_filename(10) TYPE c VALUE 'Attachment',
lc_atthead(30) TYPE c VALUE 'Manually released invoices'.
DATA: i_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: w_doc_name(30) TYPE c.
DATA: l_text1(15),
l_text2(12),
l_text3(15),
l_text4(15),
l_text5(14),
l_text6(17),
l_text7(10),
l_text8(20),
l_text9(19),
l_text10(19),
l_text11(19),
l_text12(16),
l_text13(20),
l_text14(19),
l_text15(19),
l_text16(30).
DATA: DATE(10),
DT(2),
MON(3),
YR(4),
lc_final(50).
CLEAR: i_texts, i_reci,i_att_line. "i_bname,
REFRESH: i_texts, i_reci,i_att_line. "i_bname,
WRITE sy-datum TO w_datex.
WRITE sy-uzeit TO w_timex.
l_text1 = text-003.
l_text2 = text-004.
l_text3 = text-005.
l_text4 = text-006.
l_text5 = text-007.
l_text6 = text-008.
l_text7 = text-009.
l_text8 = text-010.
l_text9 = text-011.
l_text10 = text-012.
l_text11 = text-013.
l_text12 = text-014.
l_text13 = text-015.
l_text14 = text-016.
l_text15 = text-017.
l_text16 = text-026.
CONCATENATE
l_text1
l_text2
l_text3
l_text4
l_text5
l_text6
l_text7
l_text8
l_text9
l_text10
l_text11
l_text12
l_text13
l_text14
l_text15
l_text16
INTO i_texts SEPARATED BY
c_horz_tab.
i_texts-line+254(1) = c_newline.
APPEND i_texts.
CLEAR i_texts.
LOOP AT i_texc.
i_att_line-line = i_texc.
APPEND i_att_line.
ENDLOOP.
LOOP AT so_rec.
i_reci-receiver = so_rec-low.
i_reci-express = 'X'.
i_reci-rec_type = 'U'.
APPEND i_reci.
ENDLOOP.
DESCRIBE TABLE i_texts LINES w_tab_lines.
READ TABLE i_texts INDEX w_tab_lines.
wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
wa_obj_name = 'ZFI_XX_REL_BLOCKED_INVOICE_01'.
DT = SY-DATUM+6(2).
MON = SY-DATUM+4(2).
YR = SY-DATUM+0(4).
CONCATENATE DT MON YR INTO DATE SEPARATED BY '-'.
CONCATENATE lc_atthead date into lc_final separated by ' '.
MOVE lc_final
TO wa_obj_descr .
wa_doc_chng-obj_name = wa_obj_name.
wa_doc_chng-obj_descr = wa_obj_descr.
CLEAR i_objpack-transf_bin.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 0.
i_objpack-body_num = w_tab_lines.
i_objpack-doc_type = 'RAW'.
APPEND i_objpack.
APPEND LINES OF i_att_line TO i_texts.
LOOP AT i_arseg INTO wa_arseg.
i_xmplt_d-belnr = wa_arseg-belnr.
i_xmplt_d-budat = wa_arseg-budat.
i_xmplt_d-bukrs = wa_arseg-bukrs.
i_xmplt_d-lifnr = wa_arseg-lifnr.
i_xmplt_d-name1_lifnr = wa_arseg-name1_lifnr.
i_xmplt_d-wrbtr = wa_arseg-wrbtr.
i_xmplt_d-waers = wa_arseg-waers.
i_xmplt_d-ebeln = wa_arseg-ebeln.
i_xmplt_d-ebelp = wa_arseg-ebelp.
i_xmplt_d-reason = wa_arseg-reason.
i_xmplt_d-dmeng = wa_arseg-dmeng.
i_xmplt_d-dwert = wa_arseg-dwert.
i_xmplt_d-bname = wa_arseg-bname.
i_xmplt_d-name_text = wa_arseg-name_text.
i_xmplt_d-udate = wa_arseg-udate.
i_xmplt_d-comment = wa_arseg-comment.
APPEND i_xmplt_d.
ENDLOOP.
LOOP AT i_xmplt_d.
CONCATENATE i_xmplt_d-belnr
i_xmplt_d-budat
i_xmplt_d-bukrs
i_xmplt_d-lifnr
i_xmplt_d-name1_lifnr
i_xmplt_d-wrbtr
i_xmplt_d-waers
i_xmplt_d-ebeln
i_xmplt_d-ebelp
i_xmplt_d-reason
i_xmplt_d-dmeng
i_xmplt_d-dwert
i_xmplt_d-bname
i_xmplt_d-name_text
i_xmplt_d-udate
i_xmplt_d-comment
INTO i_texts SEPARATED
BY c_horz_tab.
i_texts-line+254(1) = c_newline.
APPEND i_texts.
CLEAR i_texts.
ENDLOOP.
DESCRIBE TABLE i_texts LINES w_tab_lines.
READ TABLE i_texts INDEX w_tab_lines.
wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
DESCRIBE TABLE i_texts LINES w_tab_lines.
i_objpack-transf_bin = ' '.
i_objpack-head_start = 0.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = w_tab_lines.
i_objpack-doc_type = 'XLS'.
i_objpack-obj_name = 'Attachment'.
i_objpack-obj_descr = w_doc_name.
i_objpack-obj_descr = lc_filename.
i_objpack-doc_size = w_tab_lines * 255.
APPEND i_objpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
TABLES
packing_list = i_objpack
contents_txt = i_texts
receivers = i_reci
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
WRITE: / 'Error in send E-Mail' .
ENDIF.
please revert me asap. It is very urgent to me. thanks in advance.
ByehI
Have you build your Excel Data table to get attachement in Mail? If no then please find the Eg. code for your reference to send Excel attachment..
* End of Selection Event : Displaying the selected data *
END-OF-SELECTION.
PERFORM EMAIL_EXCEL_ATTACHMENT.
******///form
FORM EMAIL_EXCEL_ATTACHMENT .
* Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
* 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 S_EMAIL
TEXT-042
C_XLS
'filename'
CHANGING GD_ERROR
GD_RECIEVER.
* Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
ENDFORM. " EMAIL_EXCEL_ATTACHMENT
********///form BUILD_XLS_DATA_TABLE
FORM BUILD_XLS_DATA_TABLE .
DATA : LV_NETWR(20) TYPE C,
LV_BOL_DATE(20) TYPE C,
LV_KAWRT(20) TYPE C,
LV_FKDAT(20) TYPE C,
LV_WAERK(20) TYPE C,
LV_KURRF(20) TYPE C,
LV_SHIPDATE(20) TYPE C,
LV_DEPTDATE(20) TYPE C.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF. "#EC *
DATA STR TYPE STRING.
**********/ this parameter concatenate to get headers
CONCATENATE STR
'SLNO'
'OWNER'
'SERIAL NO'
'FROM'
'DESTINATION'
'INVOICE VALUE'
'DESCRIPTION'
'CUSTOMER NAME'
'BL NUMBER'
'BL DATE'
'VESSEL NAME/AIRLINE DETAILS'
'MODE OF TRANSIT'
'SHIPPING MARKS'
'DUTY SUM INSURED'
'FLAG'
'OPEN COVERNO'
'INVOICE DATE'
'INVOICE NO'
'LC WORDING'
'QUANTITY'
'PACKAGING DETAILS'
'BASIS OF VALUATION'
'EXCLUDE WAR SRCC'
'CURRENCY'
'EXCHANGE RATE'
'ADDRESS'
'VESSEL BUILT YEAR'
'VESSEL FLAG'
'VOYAGE NO'
'SHIPMENT DATE'
'DEPARTURE DATE'
'SURVEYOR COUNTRY'
'SURVEYOR CITY'
'SURVEYOR AGENT'
'SURVEYOR ADDRESS'
'EXPORT CONSIGNMENT'
'CONTAINER DETAILS'
CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
LOOP AT IT_FINAL.
*******/ this is to pass body / row data
WRITE : IT_FINAL-NETWR TO LV_NETWR, "#EC UOM_IN_MES
IT_FINAL-BOL_DATE TO LV_BOL_DATE,
IT_FINAL-KAWRT TO LV_KAWRT, "#EC UOM_IN_MES
IT_FINAL-FKDAT TO LV_FKDAT,
IT_FINAL-WAERK TO LV_WAERK,
IT_FINAL-KURRF TO LV_KURRF,
IT_FINAL-SHIPDATE TO LV_SHIPDATE,
IT_FINAL-DEPTDATE TO LV_DEPTDATE.
CONCATENATE
STR
IT_FINAL-SLNO
IT_FINAL-OWNER
IT_FINAL-SRNO
IT_FINAL-PORT_LOAD
IT_FINAL-PORT_DSCHR
LV_NETWR
IT_FINAL-DESCRIP
IT_FINAL-CUSTNAME
IT_FINAL-BOL_NUM
LV_BOL_DATE
IT_FINAL-VESSELNAME
IT_FINAL-SHP_TYPE
IT_FINAL-SHP_MARK
LV_KAWRT
IT_FINAL-FLAG
IT_FINAL-OPEN_CONO
LV_FKDAT
IT_FINAL-VBELN
IT_FINAL-LC_WORD
IT_FINAL-QUANT
IT_FINAL-PACKDETL
IT_FINAL-INCO1
IT_FINAL-EXCWSR
LV_WAERK
LV_KURRF
IT_FINAL-ADDPAY
IT_FINAL-VESSBYR
IT_FINAL-VESSFLG
IT_FINAL-VOY_FLY_NO
LV_SHIPDATE
LV_DEPTDATE
IT_FINAL-SURCOUNT
IT_FINAL-INCO2
IT_FINAL-EXPORT_CON
IT_FINAL-SURAGT
IT_FINAL-SURADD
IT_FINAL-CONTRNO
CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
ENDLOOP.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = STR
TABLES
FTEXT_TAB = IT_ATTACH.
ENDFORM. " BUILD_XLS_DATA_TABLE
******// form POPULATE_EMAIL_MESSAGE_BODY
FORM POPULATE_EMAIL_MESSAGE_BODY .
REFRESH IT_MESSAGE.
IT_MESSAGE = TEXT-043. " Please find attached Insurance Certificate details
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
*******'/ form SEND_FILE_AS_EMAIL_ATTACHMENT
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* text
* -->PIT_MESSAGE text
* -->PIT_ATTACH text
* -->P_EMAIL text
* -->P_MTITLE text
* -->P_FORMAT text
* -->P_FILENAME text
* -->P_ATTDESCRIPTION text
* -->P_SENDER_ADDRESS text
* -->P_SENDER_ADDRES_TYPE text
* -->P_ERROR text
* -->P_RECIEVER text
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES 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. "#EC *
DATA: LD_ERROR TYPE SY-SUBRC, "#EC *
* 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. "#EC *
* 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.
DESCRIBE TABLE IT_ATTACH LINES W_CNT.
READ TABLE IT_ATTACH INDEX W_CNT.
W_DOC_DATA-DOC_SIZE =
W_CNT * 255 + STRLEN( IT_ATTACH ).
W_DOC_DATA-OBJ_LANGU = SY-LANGU.
W_DOC_DATA-OBJ_NAME = 'SAPRPT'.
W_DOC_DATA-OBJ_DESCR = LD_MTITLE.
W_DOC_DATA-SENSITIVTY = 'F'.
CLEAR T_ATTACHMENT.
REFRESH T_ATTACHMENT.
T_ATTACHMENT[] = PIT_ATTACH[].
* Describe the body of the message
CLEAR T_PACKING_LIST.
REFRESH T_PACKING_LIST.
T_PACKING_LIST-TRANSF_BIN = SPACE.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 0.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = 'raw'.
APPEND T_PACKING_LIST.
* Create attachment notification
T_PACKING_LIST-TRANSF_BIN = 'X'.
T_PACKING_LIST-HEAD_START = 1.
T_PACKING_LIST-HEAD_NUM = 1.
T_PACKING_LIST-BODY_START = 1.
DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
T_PACKING_LIST-DOC_TYPE = LD_FORMAT.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-DOC_SIZE = T_PACKING_LIST-BODY_NUM * 255.
APPEND T_PACKING_LIST.
* Add the recipients email address
CLEAR T_RECEIVERS.
REFRESH T_RECEIVERS.
LOOP AT S_EMAIL.
T_RECEIVERS-RECEIVER = S_EMAIL-LOW.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-NOTIF_DEL = 'X'.
T_RECEIVERS-NOTIF_NDEL = 'X'.
APPEND T_RECEIVERS.
ENDLOOP.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL = W_SENT_ALL
TABLES
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
* Populate zerror return code
LD_ERROR = SY-SUBRC.
* Populate zreceiver return code
LOOP AT T_RECEIVERS.
LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
ENDLOOP.
ENDFORM. " SEND_FILE_AS_EMAIL_ATTACHMENT
*******/form
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
* text
* --> p1 text
* <-- p2 text
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
*********end of code to trigger mail in excel format....
If any other help please let me know......
I am sure this example code will help you to resolve your problem...
please analyse above code for your requirement...
In my scenario the message you said is not displaying.....
Reward Points -
Shell Script to send email with .txt file as attachment
Dear Al,
Could any one help me with code, for sending email with .txt file as attachment using shell script.
Thank You!978334 wrote:
Dear Al,
Could any one help me with code, for sending email with .txt file as attachment using shell script.
Thank You!http://bit.ly/XHfSCz
https://forums.oracle.com/forums/search.jspa?threadID=&q=sendmail&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Thanks,
Hussein -
Why is gmail blocking me from sending email with a "pages" document attached?
Why is gmail blocking me from sending email with a "pages" document attached? I've checked the document for viruses with "MacKeeper" and it's clean.
Google reads your emails, in case you did not know that. Unless you are sending an email containing content Google can extract and add to its vast database of personal information, Google has no use for it.
Google Mail is becoming progressively useless. It won't accept .zip attachments, at least not the last time I tried, it will eventually prevent you from using an email client unless you visit their web mail interface, and it will disable your account if you attempt to log in from someplace Google deems is not where Google thinks you ought to be.
Gmail is worth every cent you paid.
Get rid of MacKeeper. It is capable of doing nothing beneficial and will only cause problems. -
Send Email with Excel attachment with formatting(bold, color) in Background
Hi,
I have requirement wherein I have to send an email with excel attachment with proper formatting of certain fields in the excel sheet like making it bold or setting different color. The data is available in an internal table. Just to to format it and send an email when the program is executed in background mode.
Any pointers on this would be highly appreciated!
Thanks,
Anil.I resolved my own problem using the BCS_EXAMPLE_7 program as sample.
-
Bug sending email with Excel file (immediate reply would he helpfull)
Hi ,
Below is have pasted a sample code where it will sends a email along with an attachtment (xls) .where the email is working perfectly but the xls file attachtment has a blank space in the first line .
where iam facing the problem ,
ie there should not be any blank lines at the top .
Please run the code one i have pasted below .u can find the bug .
can any one help me on this .
please have ur mail id in ( reclist-receiver ) so that u can check for the output.
This table requires information about how the data in the
tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are
to be distributed to the documents and its attachments.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
This table must contain the summarized data dependent on each object type.
SAPscript objects store information here about forms and styles,
for example. Excel list viewer objects store the number of rows and columns
amongst other things and PC objects store their original file name.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
*CREATION OF INTERNAL TABLE
DATA : BEGIN OF itobjbin OCCURS 10 ,
vbeln type vbrp-vbeln,
matnr type vbrp-matnr,
werks type vbrp-werks,
fktyp like vbrk-fktyp,
END OF itobjbin .
This table must contain the summarized content of the objects identified as binary objects.
*DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: objbin TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: wa_itobjbin LIKE itobjbin .
This table must contain the summarized content of the objects identified as ASCII objects.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
This table must contain the document recipients.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
This structure must contain the attributes of the document to be sent.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA : V_FKTYP LIKE VBRK-FKTYP.
Creating the document to be sent
doc_chng-obj_name = 'OFFER'. " input contains the attributes of the document to be sent
doc_chng-obj_descr = 'EMAIL WITH EXCEL DOWNLOAD'. "input contains title/subject of the document
*BODY OF THE MAIL
OBJTXT = 'Hi'.
APPEND OBJTXT .
OBJTXT = 'Test for excel download'.
APPEND OBJTXT.
OBJTXT = 'Below is the attachment with Billing Document Details'.
APPEND OBJTXT.
OBJTXT = 'Regards'.
APPEND OBJTXT.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
Creating 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.
Creating the document attachment
(Assume the data in OBJBIN are given in BMP format)
select vbeln matnr werks
from vbrp into table itobjbin
up to 10 rows
where werks GE '1000'.
loop at itobjbin.
select single fktyp into v_fktyp from vbrk where vbeln = itobjbin-vbeln.
move v_fktyp to itobjbin-fktyp.
modify itobjbin.
endloop.
PERFORM build_xls_data_table .
DESCRIBE TABLE objbin LINES tab_lines.
objhead = 'ABC.XLS'. APPEND objhead.
Creating 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 = 'XLS'.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = 'XLS'.
objpack-doc_size = tab_lines * 255.
APPEND objpack..
Entering names in the distribution list
reclist-receiver = ''.
reclist-rec_type = 'U'.
APPEND reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
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.
WRITE: / 'Result of the send process:'.
LOOP AT reclist.
WRITE: / reclist-receiver(48), ':'.
IF reclist-retrn_code = 0.
WRITE 'sent successfully'.
ELSE.
WRITE 'not sent'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'no authorization to send to the specified number of', 'recipients!'.
WHEN 2.
WRITE: / 'document could not be sent to any of the recipients!'.
WHEN 4.
WRITE: / 'no authorization to send !'.
WHEN OTHERS.
WRITE: / 'error occurred during sending !'.
ENDCASE.
*& Form build_xls_data_table
text
--> p1 text
<-- p2 text
FORM build_xls_data_table .
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
CONCATENATE 'Billing Document' 'Material Number' 'Plant' 'Billing category' ' ' INTO objbin SEPARATED BY con_tab.
CONCATENATE con_cret objbin INTO objbin.
APPEND objbin.
LOOP AT itobjbin .
CONCATENATE itobjbin-vbeln itobjbin-matnr itobjbin-werks itobjbin-fktyp' '
INTO objbin SEPARATED BY con_tab.
CONCATENATE con_cret objbin INTO objbin.
APPEND objbin.
ENDLOOP.
thanks in advance,
vinay .Hi ravi ,
Thanks ,for your help .now xls is working fine .
but now iam facing a problem with the same function module .for txt files .where all the records are formated in asingle line .
can u provide a solution for this ,which would be very helpfull.
below is have attached the sample code .
Thanks,
vinay.
FUNCTION Z_KAILASH_ATTACHMENT1.
""Local Interface:
*" IMPORTING
*" VALUE(EMAILID)
*" VALUE(SUBJECT)
*" VALUE(ATYPE)
*" TABLES
*" ATTACH_FILE STRUCTURE SOLISTI1
*" BODY OPTIONAL
This table requires information about how the data in the
tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are
to be distributed to the documents and its attachments.
DATA OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
This table must contain the summarized data dependent on each object type.
SAPscript objects store information here about forms and styles,
for example. Excel list viewer objects store the number of rows and columns
amongst other things and PC objects store their original file name.
DATA OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
This table must contain the summarized content of the objects identified as binary objects.
DATA OBJBIN TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
This table must contain the summarized content of the objects identified as ASCII objects.
DATA OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
This table must contain the document recipients.
DATA RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE .
This structure must contain the attributes of the document to be sent.
DATA: DOC_CHING LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
Create the internal table for body , subject
DATA: IT_BODY LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
CONSTANTS: con_cret TYPE C VALUE cl_abap_char_utilities=>horizontal_tab,
con_tab TYPE C VALUE cl_abap_char_utilities=>cr_lf.
Move Body to Internal Table (body into it_body)
LOOP AT BODY .
MOVE BODY TO IT_BODY .
APPEND IT_BODY .
ENDLOOP.
DOC_CHING-OBJ_DESCR = SUBJECT. "Subject of the Email
Move the Subject and Body to OBJTXT
OBJTXT[] = IT_BODY[].
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHING-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 = 'RAW'.
APPEND OBJPACK.
Convert IT to Excel format
IF ATYPE = 'XLS' .
*CONSTANTS: con_cret TYPE C VALUE cl_abap_char_utilities=>horizontal_tab,
con_tab TYPE C VALUE cl_abap_char_utilities=>cr_lf.
LOOP AT ATTACH_FILE .
REPLACE ALL OCCURRENCES OF '#' IN ATTACH_FILE WITH con_cret. " INTO objbin.
CONCATENATE ATTACH_FILE con_tab INTO objbin.
APPEND objbin.
ENDLOOP.
ELSEIF ATYPE = 'TXT' .
LOOP AT ATTACH_FILE .
REPLACE ALL OCCURRENCES OF '#' IN ATTACH_FILE WITH con_tab. " INTO objbin.
CONCATENATE ATTACH_FILE ' ' INTO OBJBIN .
APPEND OBJBIN .
ENDLOOP.
ENDIF.
****End-Code Excel Format .
DESCRIBE TABLE objbin LINES tab_lines.
objhead = subject. APPEND objhead.
Creating 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 = ATYPE.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = 'TEST'. "Attachment File Name
objpack-doc_size = TAB_LINES * 255.
APPEND objpack..
reclist-receiver = EMAILID.
reclist-rec_type = 'U'.
APPEND reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_CHING
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
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 .
ENDFUNCTION. -
Need to send email with content of total sales
Hi experts,
I have configure notification mailer and have received also test email. Usually I may receive oracle alerts in my email address.
I need two solutions or need to build below mention point.
1) need to send email total daily sale ?
2) need to setup oracle alerts ?
I am waiting your kind response or refer solid documents to fulfil my requirements
ThanksYou can configure an alert that fires every day at about 1:00 am.
The alert can query oe_order_lines_all table for all orders lines that were created in booked status on the prior day.
Then you can format the alert to include the total amount.
You can group by sales person or by warehouse.
If you want to group the sales by item numbers, the email may become long depending on the number of items you sell every day.
See http://docs.oracle.com/cd/A60725_05/html/comnls/us/alr/summary.htm for a great example on how to send a summary alert.
Hope this helps,
Sandeep Gandhi -
Sending emails with both body and attachment to multiple recipients
I have a requirement to send email with body and attachment to multiple recipients.
Body of the email is a standard text. It is a proxy-to-mail scenario.
Here is what I've done: (I'm using PI 7.11)
One mapping from Source to Target structure (format of the attachment text file)
Second mapping from Target Structure to Mail Package format.
In the second mapping I'm concatenating the output of first step into "Content" of the Mail Package.
"XIPAYLOAD" is the message protocol used.
The "Keep attachments" option in the Mail adapter allows only to send "Content" as attachment or as body of the email.
How to send an email with both content and text?
The other problem is even with using ASMA, I can't send email to multiple recipients. I can only do CC and TO for 1 person each - a total of 2. Although I can resolve this by creating mailing lists, it is better if this can be addressed in PI.
Thanks for any input you can provide!
Edited by: crazylad on Jan 18, 2012 3:39 PMThank you for your response Mikael.
For the first question, I was able to find the solution in the following blog:
XI Mail Adapter : Dynamically building attachment and message body content using a simple UDF
(I just needed to search with the right set of key words )
The key is to set the "Content Encoding" as "None" in the mail adapter. If this is not done, the mail will be sent with an attachment - untitled.bin containing both the mail body and the attachment text. Also, don't forget to check the "Keep Attachments" checkbox in the mail adapter.
Multiple recipients could be added by separating the email IDs with a Comma. I have used ASMA to set the recipients. -
To send email with editable PDF/XLS attachment
Hi All,
Is it possible to send editable PDF/XLS attachment in a mail to the customer via SAP, if yes how?
Please Help! Urgenthi,
*Sending mail with attachment
* This program will allowed you to send email with attachment.
* First, specify the attachment file from your local hardisk and execute.
* Next, specify the sender email address and click the send button.
report y_cr17_mail.
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
* Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
* PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
* EXCEPTIONS
* USER_NOT_EXIST = 1
* PARAMETER_ERROR = 2
* X_ERROR = 3
* OTHERS = 4
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'sap-img.com testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
* FOLMEM_DATA =
* RECEIVE_DATA =
* File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
*-- End of Program
Hope this helps, Do reward. -
Can't send email with large (over 1MB) attachment
Win 7 64-bit, Thunderbird 31.2.0, eSet antivirus (but disabling it for email doesn't help), godaddy email server (works fine from godaddy web mail), port 80 (been using this port for years; 25 doesn't work)
Sending email with a 974KB attachment works. Email with a 1.4MB (and larger) attachment doesn't work. The error message appears pretty quickly (5 seconds at the most).
The message is "the connection to SMTP server smtpout.secureserver.net timed out".
This problem seem to appear at random, then go away and all is well (for a while).No. The modem is an Arris obtained from Comcast on 6/9/2014 after the prior one failed.
-
Sending email with 1-2 MB attachment
Why sending email with small attachment in iPad IOS7 feels like waiting for a flight delay without announcement ?
Very embarrassing for Apple to missed this issue....
Internet connection is fine, but email could not get through the outbox.... Oh my God...Hey,
Many people have expirienced this...
The problem for most people were their, internet connection, or their device.
This might not work, for some people.
I would recommend holding down the power button and the home button until the apple logo shows up.
Then you can open mail and send your attachment, hopefully.
If that was successfull, have a good evening!
-- Shamurocks45 -
Send email with excel attachment in outlook structure - SAP 6.0
Hello experts..
I need send a email with a excel attachment and use the signature in outlook to send.
The attachment will be create in the process of send email program.
Is it possible?
How can I created and attach in the same process?
How can I use the outlook strutucture to send a email?I resolved my own problem using the BCS_EXAMPLE_7 program as sample.
-
Issue in Sending email with EXCEL attachment
Hi,
Im using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 for sending emails to a list of recipients with an excel attachment. In the attachment data, as the field length is 255 for the structure SOLISTI1, for the records having more than 255 characters, data is being truncated. I did a search in this forum and done some changes , still it is not working properly.
I have used SCMS_TEXT_TO_XSTRING, SCMS_XSTRING_TO_BINARY FMs for converting the data to hexa format. This case, records having more than 255 are displayed properly in the attachment, but there are blank lines inserted between two records.
Please suggest me to resolve this isssue.
Thanks in advance.
JayashreeHi Jayashree,
you might want to check out the example link by Saso in his post Send external email from within ABAP program to xls.
For the rest I can only guess that there might be some issues with the format you use for Excel. In case of empty lines and using a text format for Excel the issue is in most cases that there are too many carriage return line feeds in the text fiel (cl_abap_char_utilities=>cr_lf).
Hope that helps.
Best Regards
Michael -
Send email with excel attachement
I'm using SO_DOCUMENT_SEND_API1 function to send a scheduled email with attachment.
But the problem is that the length of the string that I'm appending to the excel exceeds 256 characters.
So, the final excel file has trimmed values. Meaning only the first 255 characters are displayed.
I hope you guys understand what i'm saying.
So as I found out it seems that the above function can't be used in my case.
Do you know any other way of sending an email with attachment that meets my requirements.
Thanks,
Thilanka.Hi Buddy,
I also came across the same problem once. The only solution to this is tell your client to reduce the fields lenght which are not require.
Only 255 Char can be send on mail as per the fun Mod.
you have to reduce the length or display some data in the body of mail.
Hope this will solve your worry...
Thanks,
Krishna.. -
Hi need to send email with msg pls suggest a code to do so
hi
i want to send email to users with a simple message like for eg shipment shipped
please suggest some code for it how to do it
regards
NishantHere is a simple macro to do this. Obviously this is not generic enough, but it is very easy to tweak this to do whatever you want.
define send_mail.
data : header_text(40).
object_hd_change-objla = sy-langu.
read textpool sy-repid into text_tab language sy-langu.
read table text_tab with key id = 'R'.
move text_tab-entry to object_hd_change-objnam.
concatenate text_tab-entry ' Error ' into
object_hd_change-objdes separated by space.
object_hd_change-objsns = 'C'. "SENSITIVITY
objcont-line = 'The following messages were received:'.
append objcont.
clear objcont.
objcont-line = ' '.
append objcont.
clear objcont.
objcont-line = &1.
append objcont.
receivers-recesc = 'B'. "SAPmail to SAP user
receivers-recextnam = sy-uname.
receivers-recnam = sy-uname.
receivers-sndex = 'X'.
receivers-rcdat = sy-datum.
receivers-rctim = sy-uzeit.
append receivers.
call function 'SO_OBJECT_SEND'
exporting
object_hd_change = object_hd_change
object_type = object_type
tables
objcont = objcont
objhead = objhead
objpara = objpara
objparb = objparb
receivers = receivers
exceptions
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
folder_not_exist = 4
folder_no_authorization = 5
forwarder_not_exist = 6
note_not_exist = 7
object_not_exist = 8
object_not_sent = 9
object_no_authorization = 10
object_type_not_exist = 11
operation_no_authorization = 12
owner_not_exist = 13
parameter_error = 14
substitute_not_active = 15
substitute_not_defined = 16
system_failure = 17
too_much_receivers = 18
user_not_exist = 19
x_error = 20
others = 21.
if sy-subrc <> 0.
write :/ 'Error Sending the Object', sy-subrc.
else.
Commit work.
endif.
end-of-definition.
Maybe you are looking for
-
Pcmanfm 0.9.7 incorrect partition size? [SOLVED]
In PCManFM, the size of my hard drive is reported incorrectly. If I open gparted and look at /dev/sdb, the usable size is 186 Gb out of 200 Gb, due to manufacturing tolerance, yadda yadda; however, PCManFM reports it having 199.9 Gb free. Should I
-
Lack of customer support after spending a year trying to activate CS3
I have been trying for over a year now to activate one of the Adobe products after my boss in England had mailed me a legal copy of CS3 so I could start work. Not only did all the programs not download correctly after taking several hours to download
-
Connecting a 2nd pc to humehub wired
hi , ive a bt home hu 2.0 and my pc is on windows xp,is it possible to connect the kids pc in there room to my router via a cable to the home hub in one the the ethernet ports at the back?or is it not as simple as that?
-
Can anyone help with a Word 2007 and Acrobat 9 combine files problem?
Hi all This may be a setup problem but I was unable to find an answer. I have many word documents that use a style as Heading 1, 2 and 3. What I normally do is to use the Adobe option of "Merge Files into a Single PDF" and then select the document
-
How can i get facebook on my iphone 3g
i have been told that i cant get facebook on my iphone 3g and have tryed downloading older version bt they dont work how can i get this? if i cant get it what is half the piont of having an iphone if i cant get half the apps thinking of taking all my