Problem in sending Excel attachment on the SAI id.
Hi Experts.
i am using one function module to send one alv output in Excel format to sapid.
FORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.
CALL FUNCTION 'Z_MAIL_ITAB_AS_XLS_ATTACHMENT'
EXPORTING
I_MESSAGE_TITLE = SYST-TITLE
I_ATTACHMENT_TITLE = SYST-TITLE
I_STRUCTURE_NAME = 'ZAMT__ZBCAUTH0001'
I_INCLUDE_HEADER = 'X'
I_RECIPIENT_UNAME = P_UNAME
TABLES
T_MESSAGE = MESSAGE_TAB
T_DATA = I_TABLE
T_RECEIVERS = RECEIVERS_TAB
EXCEPTIONS
NO_DATA_TO_SEND = 01
UNABLE_TO_GET_NAMETAB = 02
UNABLE_TO_GET_DDTEXTS = 03
NO_HEADER_SUPPLIED = 04
MAIL_SENDING_FAILED = 05
OTHERS = 06.
IF SYST-SUBRC NE 0.
MESSAGE ID SYST-MSGID TYPE SYST-MSGTY NUMBER SYST-MSGNO
WITH SYST-MSGV1 SYST-MSGV2 SYST-MSGV3 SYST-MSGV4.
ENDIF.
ENDFORM.
now, my requirement is i had two internal table one for ITAB_FICO & ITAB_SD for FICO and SD module.AND BY CHECKING CONDITON I HAD TO SEND MAIL TO CORRESPONDING DIFFERENT PERSON.
I HAD DONE THE CODING AS GIVEN BELOW.
IF NOT itab_fico[] IS INITIAL.
RECEIVERS_TAB-RECEIVER = 'SAP_00021'.
RECEIVERS_TAB-REC_TYPE = 'B'.
RECEIVERS_TAB-EXPRESS = 'X'.
APPEND RECEIVERS_TAB.
PERFORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.
endif.
IF NOT itab_sd[] IS INITIAL.
RECEIVERS_TAB-RECEIVER = 'SAP_00022'. <------- its my sap id
RECEIVERS_TAB-REC_TYPE = 'B'.
RECEIVERS_TAB-EXPRESS = 'X'.
APPEND RECEIVERS_TAB.
PERFORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.
endif.
Now, what is happening is i am getting two mails,
one contains the attachement in Excel for ITAB_FICO. ( 3 ROWS)
SECOND mail contains two attachement one for ITAB_FICO ,second attachment contains the line items of ITAB_FICO + in the same excel the line items of ITAB_SD(2 ROWS).
So, for one time its working fine, but on sending mail second or third them its attaching the previous attachment also...... i tried to refresh everything but its not working....................
please help,,,,or if possible tell me some other SAP FM ...which can fulfil the requirements.
I will reward points for every suggestion.
thanks
Hi Saurabh,
IF NOT itab_fico[] IS INITIAL.
<b>REFRESH : RECEIVERS_TAB.
CLEAR : RECEIVERS_TAB.</b>
RECEIVERS_TAB-RECEIVER = 'SAP_00021'.
RECEIVERS_TAB-REC_TYPE = 'B'.
RECEIVERS_TAB-EXPRESS = 'X'.
APPEND RECEIVERS_TAB.
PERFORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.
endif.
IF NOT itab_sd[] IS INITIAL.
<b>REFRESH : RECEIVERS_TAB.
CLEAR : RECEIVERS_TAB.</b>
RECEIVERS_TAB-RECEIVER = 'SAP_00022'. <------- its my sap id
RECEIVERS_TAB-REC_TYPE = 'B'.
RECEIVERS_TAB-EXPRESS = 'X'.
APPEND RECEIVERS_TAB.
PERFORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.
endif.
Best regards,
Prashant
Similar Messages
-
Sending excel attachment to the distribution list
Hi ,
I am sending an Excel file attachment in XLS format to the distrubution list using FM :SO_NEW_DOCUMENT_ATT_SEND_API1
I have passed the parameters as follows:
reclist-REC_TYPE = 'C'.
reclist-COM_TYPE = 'INT'.
reclist-NOTIF_DEL = 'X'.
reclist-NOTIF_NDEL = 'X'.
reclist-RECEIVER = p_DLIST.
APPEND reclist.
but i am receiving error message :
Exception from the class CX_SEND_REQ_BCS was caught
when I am passing the receiver as email address, its working fine.
Please let me know what is the issue?
Tjhanks and regards,
MadhuriHi,
Try
RECLIST-REC_TYPE = 'U'. "internet users
RECLIST-RECEIVER = '<name>@address.com'. " try one like youe first address
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
RECLIST-RECEIVER = p_DLIST. " put the list
RECLIST-REC_TYPE = 'P'.
APPEND RECLIST.
Also check this wiki [http://wiki.sdn.sap.com/wiki/display/Snippets/Howtosendmailtoadistributionlistoragroup+ID]
Ben -
Send excel attachment with more than 255 characters in the internal table
Hi,
I need to send an attachment in the form of spreadsheet.
But the internal table that is being used for sending attachment in mails can have only 255 characters in one row.
Whereas my spreadsheet requires a greater width than 255 characters .Hi,
I need to send an attachment in the form of spreadsheet.
But the internal table that is being used for sending attachment in mails can have only 255 characters in one row.
Whereas my spreadsheet requires a greater width than 255 characters . -
Send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1
Hi ABAPers,
I managed to send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
Let say I send it to my own email account.
But, when try to open the excel document, from lotus notes, there is warning message produced by the microsoft excel saying:
"The file is not in a recognizable format.
and so on....."
Anyway, when I click button 'OK', excel sheet will be opened and no information lost.
How can we code the abap program so that the message will not come each time I open the attachment from my lotus notes?
Or this is just the tab delimited issue?
Thank you.
Regards,
Edward.Hi Shan,
Thank you for replying.
I have the same as follows:
DESCRIBE TABLE lt_contents_hex LINES lv_lines.
lt_packing_list-transf_bin = 'X'.
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 1.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lv_lines.
lt_packing_list-doc_type = 'XLS'.
lt_packing_list-obj_name = 'ATTACHMENT'.
lt_packing_list-obj_descr = 'Attachment'.
lt_packing_list-doc_size = lv_lines * 255.
APPEND lt_packing_list.
I'm using lt_contents_hex instead of lt_contents_bin.
Still the problem is there.
Is there any other way to calculate the doc size correctly?
Regards,
Edward. -
Sending Excel attachment in E-mail
Hi All,
I am sending excel attachment in mail, when I see in SO01 tcode I am able to see the attachment in outbox, but getting 'Error during send Process' in sent status and not getting any mails to my e-mail id.
Could you any one help me in this?
Thanks in advance.
Vijaya.Hi,
data: p_email type somlreci1-receiver
value 'Mail ID'.
data: begin of it001 occurs 0,
bukrs type t001-bukrs,
butxt type t001-butxt,
end of it001.
data: imessage type standard table of solisti1 with header line,
iattach type standard table of solisti1 with header line,
ipacking_list like sopcklsti1 occurs 0 with header line,
ireceivers like somlreci1 occurs 0 with header line,
iattachment like solisti1 occurs 0 with header line.
start-of-selection.
select bukrs butxt into table it001 from t001.
Populate table with detaisl to be entered into .xls file
perform build_xls_data .
Populate message body text
clear imessage. refresh imessage.
imessage = 'Please find attached excel file'.
append imessage.
Send file by email as .xls speadsheet
perform send_email_with_xls tables imessage
iattach
using p_email
'Example Excel Attachment'
'XLS'
'TestFileName'
'CompanyCodes'.
Form BUILD_XLS_DATA
form build_xls_data .
constants: con_cret type x value '0D', "OK for non Unicode
con_tab type x 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 'BUKRS' 'BUTXT'
into iattach separated by con_tab.
concatenate con_cret iattach into iattach.
append iattach.
loop at it001 .
concatenate it001-bukrs it001-butxt
into iattach separated by con_tab.
concatenate con_cret iattach into iattach.
append iattach.
endloop .
endform.
Form SEND_EMAIL_WITH_XLS
form send_email_with_xls tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription.
data: xdocdata like sodocchgi1,
xcnt type i.
Fill the document data.
xdocdata-doc_size = 1.
Populate the subject/generic message attributes
xdocdata-obj_langu = sy-langu .
xdocdata-obj_name = 'SAPRPT' .
xdocdata-obj_descr = p_mtitle .
Fill the document data and get size of attachment
clear xdocdata.
read table iattach index xcnt.
xdocdata-doc_size =
( xcnt - 1 ) * 255 + strlen( iattach ).
xdocdata-obj_langu = sy-langu.
xdocdata-obj_name = 'SAPRPT'.
xdocdata-obj_descr = p_mtitle.
clear iattachment. refresh iattachment.
iattachment[] = pit_attach[].
Describe the body of the message
clear ipacking_list. refresh ipacking_list.
ipacking_list-transf_bin = space.
ipacking_list-head_start = 1.
ipacking_list-head_num = 0.
ipacking_list-body_start = 1.
describe table imessage lines ipacking_list-body_num.
ipacking_list-doc_type = 'RAW'.
append ipacking_list.
Create attachment notification
ipacking_list-transf_bin = 'X'.
ipacking_list-head_start = 1.
ipacking_list-head_num = 1.
ipacking_list-body_start = 1.
describe table iattachment lines ipacking_list-body_num.
ipacking_list-doc_type = p_format.
ipacking_list-obj_descr = p_attdescription.
ipacking_list-obj_name = p_filename.
ipacking_list-doc_size = ipacking_list-body_num * 255.
append ipacking_list.
Add the recipients email address
clear ireceivers. refresh ireceivers.
ireceivers-receiver = p_email.
ireceivers-rec_type = 'U'.
ireceivers-com_type = 'INT'.
ireceivers-notif_del = 'X'.
ireceivers-notif_ndel = 'X'.
append ireceivers.
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = xdocdata
put_in_outbox = 'X'
commit_work = 'X'
tables
packing_list = ipacking_list
contents_bin = iattachment
contents_txt = imessage
receivers = ireceivers
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.
endform.
Check this Sample code.
Thanks,
Durai.V -
Hi ,
I am sending excel attachment through email .
This excel attachment is generated from an ALV Grid Output .
The excel file has all columns fixed to its initial length due to which the entire column content isnt visible unless its extended at the time of checking its content .
Can anyone suggest a remedy to this or send any code which can be used to read the Grid Output and Convert into excel sheet ?
Thanks and Regards
Soumyadip PalHi Soumyadip Pal,
Check this code.
REPORT z_email_abap_report.
E-mail an Abap report *
DATA : w_name TYPE sos04-l_adr_name.
SELECT-OPTIONS :
Recipient address
s_name FOR w_name DEFAULT sy-uname NO INTERVALS.
START-OF-SELECTION.
E-mail Abap report
PERFORM f_send_mail.
Form f_send_mail
FORM f_send_mail.
Data Declaration
DATA:
l_datum(10),
ls_docdata TYPE sodocchgi1,
lt_objpack TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
lt_objhead TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_objtxt TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_objbin TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_reclist TYPE TABLE OF somlreci1 WITH HEADER LINE,
lt_listobject TYPE TABLE OF abaplist WITH HEADER LINE,
l_tab_lines TYPE i,
l_att_type LIKE soodk-objtp.
WRITE sy-datum TO l_datum.
List of Users According to Logon Date and Password Change
NOTE: Create ALI/OTF Document in Spool
SUBMIT rsusr200 WITH valid = 'X'
WITH notvalid = space
WITH unlocked = 'X'
WITH locked = space
EXPORTING LIST TO MEMORY AND RETURN.
Read list from memory into table
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
Error in function module &1
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
Because listobject is of size RAW(1000)
and objbin is of size CHAR(255) we make this table copy
CALL FUNCTION 'TABLE_COMPRESS'
TABLES
in = lt_listobject
out = lt_objbin
EXCEPTIONS
compress_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
Error in function module &1
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
NOTE: Creation of attachment is finished yet.
For your report, the attachment should be placed into table
objtxt for plain text or
objbin for binary content.
Now create the message and send the document.
Create Message Body
Title and Description
ls_docdata-obj_name = 'USERS_LIST'.
CONCATENATE 'List of Users' sy-sysid '-' l_datum "#EC *
INTO ls_docdata-obj_descr SEPARATED BY space.
Main Text
lt_objtxt = 'List of Users According to Logon Date' &
' and Password Change'. "#EC *
APPEND lt_objtxt.
Write Packing List (Main)
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
READ TABLE lt_objtxt INDEX l_tab_lines.
ls_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
CLEAR lt_objpack-transf_bin.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = 'RAW'.
APPEND lt_objpack.
Create Message Attachment
Write Packing List (Attachment)
l_att_type = 'ALI'.
DESCRIBE TABLE lt_objbin LINES l_tab_lines.
READ TABLE lt_objbin INDEX l_tab_lines.
lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objbin ).
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = l_att_type.
lt_objpack-obj_name = 'ATTACHMENT'.
lt_objpack-obj_descr = 'List_of_Users'. "#EC *
APPEND lt_objpack.
Create receiver list
LOOP AT s_name.
lt_reclist-receiver = s_name-low.
lt_reclist-rec_type = 'B'.
APPEND lt_reclist.
ENDLOOP.
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_docdata
put_in_outbox = ''
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
receivers = lt_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc = 0.
Document sent
MESSAGE ID 'SO' TYPE 'S' NUMBER '022'.
ELSE.
Document <&> could not be sent
MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
WITH ls_docdata-obj_name.
ENDIF.
ENDFORM. " F_SEND_MAIL
END OF PROGRAM Z_EMAIL_ABAP_REPORT ******************
Hope this resolves your query.
Reward all the helpful answers.
Regards -
Problem in sending HTTP request to the server.
Hi,
i dveloped an ant script for sar deployment.
i deployed a sar to my local soa server with ant script. it got deployed succesfully..
but when i try to deploy to a remote server, getting the below error..
"Problem in sending HTTP request to the server. Please make sure the server is up and/or check standard HTTP response code for 404"
but the server is up and runnig and i am able to ping it from my machine and also access the console...
below is my script
build.properties
wn.bea.home=C:/Oracle/Middleware
all.needed.jars.path=D:/SourceCode/neededJAR
oracle.soa.home=C:/Oracle/Middleware/Oracle_SOA1
java.passed.home=C:/Oracle/Middleware/jdk160_24
#Deployment environment
deployment.plan.environment=DEV
#Deploy Action
deployAction =redeploy
#credentials
user=weblogic
password=welcome1
#For Composite deployment
serverURL=http://10.177.154.6:7001
forceDefault=true
server=10.177.154.6
port=7001
sarLocation=D:/SourceCode/JAR
build.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="soaDeployAll" default="deployAll">
<echo>basedir ${basedir}</echo>
<property environment="env"/>
<echo>current folder ${basedir}</echo>
<property file="${basedir}/build.properties"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${all.needed.jars.path}/ant-contrib.jar"/>
</classpath>
</taskdef>
<target name="init">
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd_HH-mm-ss"/>
</tstamp>
<property name="build.log.dir" location="${basedir}/buildlogs"/>
<mkdir dir="${build.log.dir}"/> <property name="build.log.filename" value="build_${timestamp}.log"/>
<record name="${build.log.dir}/${build.log.filename}" loglevel="verbose" append="false"/>
<echo message="Build logged to ${build.log.filename}"/>
</target>
<target name="deployAll" depends="init">
<echo>Deploy for environment ${deployment.plan.environment}</echo>
<antcall target="deployAllComposites"/>
</target>
<!-- Following Actions are performed for Composite files in Managed Server - Deploy,Redeploy -->
<target name="deployAllComposites" depends="init">
<foreach target="deployComposites" param="Files">
<fileset dir="${sarLocation}" casesensitive="no" includes="*.jar"/>
</foreach>
</target>
<target name="deployComposites" depends="init">
<basename file="${Files}" property="basename"/>
<echo>Deploy Project ${basename} for environment ${deployment.plan.environment}</echo>
<if>
<equals arg1="${deployAction}" arg2="deploy" />
<then>
<echo message="Deploying composites in Managed server........." />
<ant antfile="${oracle.soa.home}/bin/ant-sca-deploy.xml" inheritAll="true" target="deploy">
<property name="serverURL" value="${serverURL}"/>
<property name="user" value="${user}"/>
<property name="password" value="${password}"/>
<property name="overwrite" value="false"/>
<property name="forceDefault" value="${forceDefault}"/>
<property name="sarLocation" value="${sarLocation}/${basename}"/>
</ant>
</then>
<else>
<echo message="ReDeploying composites in Managed server........." />
<ant antfile="${oracle.soa.home}/bin/ant-sca-deploy.xml" inheritAll="true" target="deploy">
<property name="serverURL" value="${serverURL}"/>
<property name="user" value="${user}"/>
<property name="password" value="${password}"/>
<property name="overwrite" value="true"/>
<property name="forceDefault" value="${forceDefault}"/>
<property name="sarLocation" value="${sarLocation}/${basename}"/>
</ant>
</else>
</if>
</target>
</project>
please help....Hi,
Give the serverURL as http://<host>:<managed.server.port>/soa-infra/deployer and try.
e.g . http://10.177.154.6:8001/soa-infra/deployer
Regards,
Neeraj Sehgal -
Problem to send out attachment
Hi all,
This is urgent. Any advice is appreciated. I have java class to send out attachement. The program was working fine without any issues until last Friday. Suddenly, it could not send any attachment email out. I was able to send out a simple email without attachment. I did not know what changed. I ran out of resources for troubleshooting it.
Here is my code:
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SendAttachment {
public void Send (String MailHost, String AddFrom, String AddTo, String FileAttName)
throws Exception {
String host = MailHost;
String from = AddFrom;
String to = AddTo;
String fileAttachment = FileAttName;
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session =
Session.getInstance(props, null);
// Define message
Message message =
new MimeMessage(session);
message.setFrom(
new InternetAddress(from));
message.addRecipient(
Message.RecipientType.TO,
new InternetAddress(to));
message.setSubject(
"Hello JavaMail Attachment");
// create the message part
BodyPart messageBodyPart =
new MimeBodyPart();
//fill message
messageBodyPart.setText("Hi");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// Part two is attachment
messageBodyPart = new MimeBodyPart();
DataSource source =
new FileDataSource(fileAttachment);
messageBodyPart.setDataHandler(
new DataHandler(source));
messageBodyPart.setFileName(fileAttachment);
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
// Send the message
Transport.send( message );
my test program:
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
public class TestJavaMail {
public static void main(String[] args) {
String myhost =args[0];
String from =args[1];
String to = args[2];
String filename = args[3];
try {
System.out.println("Start .....");
System.out.println("Preparing...");
SendAttachment app = new SendAttachment();
app.Send(myhost, from, to, filename);
System.out.println("Success!");
} catch (Exception e) {
//System.err.println(ExceptionUtil.printStackTrace(e));
System.exit(-1);
After successful compilation, here is how I ran the class:
java TestJavaMail mymaihost.com [email protected] [email protected] /tmp/test.txt
It stops just before it calls Transport.send( message );
Any ideas are greatly appreciated.Hello,
This could help you.
http://exchangeserverpro.com/how-to-configure-a-relay-connector-for-exchange-server-2010
if the reply help you mark it as your answer.
Free Managed .NET
Word Component(Create, Modify, Convert & Print) -
I attempted to eprint an email with an excel attachment. The attachment didn't print
I attempted to eprint an email with an Excel attachment. The email message printed but the Excel attachment does not print
Hi DaveF100,
You may want to refer to the help section of ePrintCenter.com here about attachments. In general though, Excel documents will have difficulty if they have complex variables in the document, such as pivot tables, macros, etc.
If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
Although I work for HP, my posts and replies are my own opinion and not those of HP. -
Facing problem in excel attachment in the Email
Hi,
I am facing one issue while sending an email with an excel attachment . In the excel attachment the actual number of line items are not displaying . For example if i have 4 rows in my internal table the excel shows only the first row of the internal table.
Can anybody suggest what is the issue.
Regards,
Ratheesh BSHi ,
Please find the code used.
WRITE: sy-datum TO l_date MM/DD/YY.
CONCATENATE text-014 "Enterprise workflow(s) are in ERROR status
l_date
INTO l_text
SEPARATED BY c_colon.
wa_doc_data-obj_langu = sy-langu.
wa_doc_data-obj_name = text-013. "SAPRPT
wa_doc_data-obj_descr = l_text.
wa_doc_data-sensitivty = c_false.
Fill the document data and get size of attachment
DESCRIBE TABLE i_attach LINES l_cnt.
READ TABLE i_attach INTO wa_attach INDEX l_cnt.
IF sy-subrc EQ 0.
l_size = STRLEN( wa_attach ).
l_docsize = ( ( l_cnt - 1 ) * c_length255 + l_size ).
wa_doc_data-doc_size = l_docsize.
wa_doc_data-obj_langu = sy-langu.
wa_doc_data-obj_name = text-013. "SAPRPT
wa_doc_data-obj_descr = l_text.
wa_doc_data-sensitivty = c_false.
ENDIF.
lt_attachment[] = i_attach[]." XLS attachment details
Describe the body of the message
CLEAR wa_packing_list.
REFRESH lt_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 0.
wa_packing_list-body_start = 1.
DESCRIBE TABLE lt_message LINES wa_packing_list-body_num .
wa_packing_list-doc_type = c_raw.
APPEND wa_packing_list TO lt_packing_list.
CLEAR wa_packing_list.
*l_docsize = 5000.
Create attachment notification
wa_packing_list-transf_bin = c_active.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 1.
wa_packing_list-body_start = 1.
DESCRIBE TABLE lt_attachment LINES wa_packing_list-body_num.
wa_packing_list-doc_type = c_xls.
wa_packing_list-obj_descr = text-022.
wa_packing_list-doc_size = wa_packing_list-body_num * c_length255.
APPEND wa_packing_list TO lt_packing_list.
CLEAR: wa_packing_list,l_cnt.
Email to be sent for multiple receivers
Add the recipients email address
LOOP AT s_receiv INTO wa_email.
l_email = wa_email-low.
wa_receivers-rec_type = c_rectyp.
wa_receivers-receiver = l_email.
wa_receivers-com_type = c_internet.
wa_receivers-notif_del = c_true.
wa_receivers-notif_ndel = c_true.
APPEND wa_receivers TO lt_receivers.
CLEAR : wa_receivers, wa_email, l_email.
ENDLOOP.
IF lt_receivers[] IS NOT INITIAL AND
i_itemrecord[] IS NOT INITIAL.
email sender
l_sender_address = sy-uname. " Stores the sender's address
*Function module to handel mail sending.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_doc_data
put_in_outbox = c_true
sender_address = l_sender_address
sender_address_type = c_sender_address_type
commit_work = c_true
IMPORTING
SENT_TO_ALL =
TABLES
packing_list = lt_packing_list
contents_bin = lt_attachment
contents_hex = lt_attachment1
contents_txt = lt_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 -
Problem while sending excel as attachment
Hi,
I am trying to send excel as attachment through an email.
I am using the fm: SO_DOCUMENT_SEND_API1
In english, I am able to get the data properly. However, when I try to send the same in Chinese, I am getting junk characters in excel file.
Could you please help me out to solve my issue.
I am clueless, why only for chinese, I am getting the issue.
Thanks,
SandeepHi Rushi,
In this FM, I am unable to find the parameter for code page. Could you please help me how exactly I can use this code page?
Thanks,
Sandeep -
Problem with an Excel Attachment - Mail adapter
Hello.
I have a problem when I want to attach an excel file. I have configured the communication channel for sending mails with mail package.
I have done the configuration in order to get an excel file. If I test the scenario with Content_Type "text/html" I recieve correctly the information in the mail body.
When I test the scenario with Content_Type "application/vnd.ms-excel", html tags (like: <br>, , &) are not converted. The file is attached as xls, but not converted correctly.
For example, with Content_Type "text/html":
Orders:
1 00023 ER123
2 89798 EHJ21
With Content_Type "application/vnd.ms-excel":
Orders:<br>1&nbsp;&nbsp;&nbsp;00023&nbsp;&nbsp; ER123"<br>2&nbsp;&nbsp;&nbsp;89798&nbsp;&nbsp;&nbsp;EHJ21
I have tested with Content_Type for Word files and I have the same error too.
Do I have to set some special charset in the Content_Type?
Is this an Excel error?
Thanks in advance.
Edited by: Alejandro Maldonado Quezada on Apr 6, 2009 6:28 PMHi,
I had a scenario like SAP R3 - XI - Mail receiver.
I have generated the Excel file attachment with the following details.
Content-Type:- application/vnd.ms-excel;name="Filename.CSV".
Content: - Field1,Field2,Field3,NewLineCharacter,Field4,Field5,Field6.
Content-disposition = attachment
In R3 NewLineCharacter = CL_ABAP_CHAR_UTILITIES=>NEWLINE.
Select KEEP ATTACHMENT option in Mail receive adaptet config.
Excel file Filename.CSV was generated as attachment as follow.
Field1 Field2 Field3
Field4 Field5 Field6
Regards,
Jagesh -
Send EXCEL attachment with garbage russia text
Hello All - Good day!
I have the same problem where non-english text like russian, and will appear garbage in the excel attachment after it was email.
When I test it in english description/text it looks ok.
I have tried the following FM, and got no luck.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
Program is in Unicode.
PLEASE help.Hello,
Check the following SAP note in this regards:
1151258 Error when sending Excel attachments
Also, please check SAP note regarding SO_DOCUMENT_SEND_API1 interface:
190669 Sending lists via SAPconnect
Regards,
David -
Experts:
I am working on sending Excel as an email attachment thro the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'
I am able to send mail successfully but I face the following two issues while opening the attachment.
1. While opening it says 'un recognized format' , on pressing 'OK' it opens the excel file.
2. The column heading (first row) which should be in Korean character is displayed in junk char. I tried to
specify the unicode (Code Page = '8500') but does not know how to do it.
I am reading the column header text from standard text.
Please let me know what mistake I have commited in my code and where I should specify the unicode transformation. I refered many samples but could not make it.
Please let me know the error.
The code is as follows.
FORM sendemail_barcodedata.
TYPE-POOLS: truxs.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objbin1 LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA: l_sent_to_all TYPE sonv-flag.
* Creating the document to be sent
* File Name
doc_chng-obj_name = 'BCODEINFO'.
* Mail Subject
doc_chng-obj_descr = 'Delivery Barcode Information'.
* Mail Content
objtxt = 'Hi:'.
APPEND objtxt.
objtxt = 'Find attached, Delivery Barcode Information'.
APPEND objtxt.
CONCATENATE 'Attachment : <<' w_fname1 '>>' INTO objtxt.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
doc_chng-obj_langu = sy-langu.
doc_chng-sensitivty = 'F'.
* 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
* Get column names for Barcode Data
CLEAR objbin.
CONCATENATE text-h23
text-h24
text-h25
text-h26
text-h27
INTO objbin SEPARATED BY con_tab .
CONCATENATE objbin con_cret INTO objbin.
APPEND objbin.
CLEAR objbin.
LOOP AT it_excel2 INTO wa_excel2.
CONCATENATE wa_excel2-zz_date
wa_excel2-zz_delivery
wa_excel2-zz_barcode
wa_excel2-blank1
wa_excel2-blank2
INTO objbin SEPARATED BY con_tab.
CONCATENATE objbin con_cret INTO objbin.
APPEND objbin.
CLEAR objbin.
ENDLOOP.
DESCRIBE TABLE objbin LINES tab_lines.
objhead = w_fname1.
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 = 'Barcode Information'.
objpack-obj_descr = 'Barcode Information'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
* Entering names in the distribution list
reclist-receiver = p_email.
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 = ' '
commit_work = 'X'
IMPORTING
sent_to_all = l_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
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
CASE sy-subrc.
WHEN 0.
MESSAGE i000(z65f_msgclass) WITH text-211.
WHEN 1.
WRITE: / 'no authorization to send to the specified number of'.
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.
ENDFORM.
Thanks in advance.
Regards
VijaiHi:
Can any one provide me a solution for this?
regards
vijai -
Problem in sending pdf attachment
hi all
i am facing a problem when i am sending a pdf attachment in mail... It is showing an errror that the file is not decode properly as it is an email attachment. The below code works fine for other file types. please help meFUNCTION ZMAIL_READ.
*"*"Local Interface:
*" IMPORTING
*" VALUE(SUBJECT) TYPE SO_OBJ_DES
*" VALUE(TEXT) TYPE STRING
*" VALUE(SENDER) TYPE ADR6-SMTP_ADDR
*" VALUE(RECEIVER) TYPE ADR6-SMTP_ADDR
*" VALUE(ATTACHMENTS) TYPE Z_T_XATTACH OPTIONAL
*" EXPORTING
*" VALUE(MESSAGE) TYPE STRING
DATA: lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
lo_bcs_send_request TYPE REF TO cl_bcs,
l_send type ADR6-SMTP_ADDR ,
l_rec type ADR6-SMTP_ADDR .
data: it_text type table of soli,
wa_text type soli.
DATA: lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
DATA: lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
DATA: lv_recipient_uid TYPE uname,
lv_recipient_mail TYPE adr6-smtp_addr.
data: lo_message type ref to cx_send_req_bcs value is initial,
text_val type string.
data: it_userlist type table of BAPIUSNAME,
wa_userlist type BAPIUSNAME.
data: it_selection_range type table of BAPIUSSRGE,
wa_selection_range type BAPIUSSRGE.
data: wa_attachment TYPE zxattach,
attachment_sub type SO_OBJ_DES.
DATA: xstr type xstring,
str TYPE string,
str1 type string,
it_str2 type table of soli,
wa_STR2 TYPE SOLI,
DATA: LOC_CONV TYPE REF TO CL_ABAP_CONV_IN_CE,
wa_soli type soli,
it_soli type table of soli,
it1_solix type solix_tab.
data result TYPE boolean.
data: i_ext(10) type c,
i_type type soodk-objtp.
wa_text-line = text.
append wa_text to it_text.
CLASS cl_bcs DEFINITION LOAD.
try.
lo_send_request = cl_bcs=>create_persistent( ).
catch cx_send_req_bcs.
endtry.
* Message body and subject
data: lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
try.
lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = it_text
i_subject = subject ).
catch cx_send_req_bcs.
catch cx_document_bcs.
catch cx_address_bcs.
endtry.
loop at attachments into wa_attachment.
attachment_sub = wa_attachment-file_name.
it_str2 = wa_attachment-attach.
loop at it_str2 into wa_str2.
str1 = wa_str2-line.
try.
CALL FUNCTION 'SSFC_BASE64_DECODE'
EXPORTING
B64DATA = str1
* B64LENG =
* B_CHECK =
IMPORTING
BINDATA = xstr.
catch cx_sy_dyn_call_illegal_type.
endtry.
try.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = xstr
APPEND_TO_TABLE = 'X'
* IMPORTING
* OUTPUT_LENGTH =
TABLES
BINARY_TAB = it1_solix
catch cx_sy_dyn_call_illegal_type.
endtry.
endloop.
try.
CALL FUNCTION 'SA_KW_RFC_FILENAME_EXT_GET'
EXPORTING
AREA = 'IWBSOLAR'
MIMETYPE = wa_attachment-type
IMPORTING
EXTENSION = i_ext
catch cx_sy_dyn_call_illegal_type.
endtry.
i_type = i_ext.
try.
lo_document->add_attachment(
EXPORTING
i_attachment_type = i_type
i_attachment_subject = attachment_sub
i_att_content_hex = it1_solix ).
CATCH cx_document_bcs.
endtry.
endloop.
try.
lo_send_request->set_document( lo_document ).
CATCH cx_send_req_bcs.
endtry.
wa_selection_range-PARAMETER = 'address'.
wa_selection_range-field = 'e_mail'.
wa_selection_range-sign = 'I'.
wa_selection_range-option = 'EQ'.
wa_selection_range-low = receiver.
append wa_selection_range to it_selection_range.
try.
CALL FUNCTION 'BAPI_USER_GETLIST'
* EXPORTING
* MAX_ROWS = 0
* WITH_USERNAME = ' '
* IMPORTING
* ROWS =
TABLES
SELECTION_RANGE = it_selection_range
USERLIST = it_userlist.
catch cx_sy_dyn_call_illegal_type.
endtry.
read table it_userlist into wa_userlist index 1.
try.
lo_sender = cl_cam_address_bcs=>create_internet_address( sender ).
lo_send_request->set_sender(
EXPORTING
i_sender = lo_sender ).
catch cx_send_req_bcs.
catch cx_document_bcs.
catch cx_address_bcs.
return.
endtry.
try.
lo_recipient = cl_sapuser_bcs=>create( wa_userlist-USERNAME ).
lo_send_request->add_recipient(
EXPORTING
i_recipient = lo_recipient ).
* i_express = 'X' ).
catch cx_send_req_bcs.
catch cx_document_bcs.
catch cx_address_bcs.
endtry.
try.
** Send email
LO_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
lo_send_request->send( EXPORTING
i_with_error_screen = ' '
RECEIVING
result = result ).
COMMIT WORK.
CATCH CX_DOCUMENT_BCS.
CATCH CX_SEND_REQ_BCS INTO lo_message.
CATCH CX_ADDRESS_BCS.
text_val = lo_message->IF_MESSAGE~GET_TEXT( ).
endtry.
if result = 'X'.
message = 'E-Mail sent'.
else.
message = 'E-Mail not sent'.
endif.
ENDFUNCTION.
Maybe you are looking for
-
I had updated Firefox after it kept popping up to do so, but in the process my Skype extension is now disabled and it says that Firefox can't find one that is compatible and I need to have my Skpe on here. Is there a way I can go back to the older ve
-
Subpixel hinting: all four filters are wrong.
Hi all, I've been troubling with webpages that has dark background and white or gray fonts, they always seem a little blur and uneven because the lcd screen had something to do with decreased font width. However when I tried to setup a subpixel rende
-
Hi All, Is there any User Exists for modifying 1. Customer Master (SD Modlue based) 2. Payment Terms (SD Modlue based) 3. Delivery Location (SD Modlue based) 4. Pricing List (SD Modlue based) 5. Sales Tax (SD Modlue based) And the process to work wit
-
Upgrade from 4.0 to 4.1 not working
I upgraded from apex 4.0 to 4.1 using the steps below. Everything seemed to go fine but when I try to go to http://aus-perfdb.us.oracle.com:8081/apex/ , it connects but I don't see anything. Do I need to copy the images somewhere? Thanks downloaded a
-
hi We would like to give more priority for laptops vs mobile phones/tablets in our corporate SSID. Today all of them connect to same SSID. What would be the recommended way to carry this out? 1. We mark packets coming from laptops using a COS value 2