Regarding text attachment in Email in ABAP program
Hello...
Need your expertise in one of the issues. Requirement is seems to be simple
but i am stuck up at this moment. i have refereed SDN with Several code but
some point its not giving the proper solution. So its a request to you please
do not provide any SDN link for reference as i am very much tried all of them.
please share piece of code.
Requirement : Need to develope one ABAP program, Email text attachment with Header line.thought its
very simple but still facing difficulties.
i have tried many code either its showing Data in single line without new line , in one of the Codes
data is coming in successive line but there is lot of spacing within Words means all alphabates are tab
separated. coud you please provide ,me the proper solution for this.
in one of the codes is working fine for excel but when Txt extension done data is not coming in successive line all
data is coming in single line.
Ex. Text file should contain 1 head and 4 colunns and Data size 50..
Thanks
Nishi
Hi,
Another option....
Some sample code using cl_bcs .
Note the use of cl_abap_char_utilities=>cr_lf .
FORM mail_1_prep_10
USING
it_data TYPE table
CHANGING
ob_document_bcs TYPE REF TO cl_document_bcs .
DATA: txt_line TYPE string .
DATA: txt_data TYPE string .
* Create some text data .
DO 20 TIMES .
txt_line = '' .
DO 10 TIMES .
CONCATENATE txt_line '|' 'some data 01' '|' INTO txt_line .
ENDDO .
CONCATENATE txt_line cl_abap_char_utilities=>cr_lf INTO txt_line .
CONCATENATE txt_data txt_line INTO txt_data .
ENDDO .
* Mail stuf....
DATA: it_solix TYPE solix_tab .
CALL METHOD cl_bcs_convert=>string_to_solix
EXPORTING
iv_string = txt_data
IMPORTING
et_solix = it_solix.
DATA: attachment_subject TYPE so_obj_des .
DATA: attachment_type TYPE so_obj_tp .
attachment_subject = 'Some text data' .
attachment_type = 'txt' .
TRY.
CALL METHOD ob_document_bcs->add_attachment
EXPORTING
i_attachment_type = attachment_type
i_attachment_subject = attachment_subject
i_att_content_hex = it_solix.
CATCH cx_document_bcs .
ENDTRY.
ENDFORM . "mail_1_prep_10
regards.
This is how I see it in my mail :
Similar Messages
-
Send BW query results as HTML email from ABAP program
I have published a code sample for sending BW query results as HTML email from ABAP program. if you have any questions or clarification, please post them here.
the same can be accessed from this link.
http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/b7658119-0a01-0010-39a9-b600c816f370
Regards
Raja
Message was edited by: Durairaj Athavan RajaOK forget about my earlier post.
do the following changes.
declare the following variables:
data: xtext type standard table of solix .
DATA: atta_sub TYPE sood-objdes .
after the call of FM SCMS_STRING_TO_FTEXT add the following code.
CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
EXPORTING
ip_solitab = text
IMPORTING
EP_SOLIXTAB = xtext .
and after the following statement
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = text
i_length = conlengths
i_subject = subject ).
add the following code
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'htm'
i_attachment_subject = atta_sub
i_att_content_hex = xtext.
now you will have results both in the body as well as attachment. (this is for test you can remove one of them )
Regards
Raja -
Sending emails from ABAP program
Hi,
I need to send error emails from ABAP program.
I have to pass error internal table as text (not as attachment) in the email.
Can anybody supply any sample code?
Thanks in advance.
Regards,
Arun MohanHI,
See if this code helps:
***Sending mail to the receipients
if not it_final[] is initial.
Populate table with detaisl to be entered into .xls file
PERFORM BUILD_XLS_DATA_TABLE.
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
'Sales Register Report - Set Top Box / Accessories'
'XLS'
'SSTB'
CHANGING GD_ERROR
GD_RECIEVER.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
endif.
*& Form BUILD_XLS_DATA_TABLE
text
--> p1 text
<-- p2 text
FORM BUILD_XLS_DATA_TABLE .
data: wa_itab like it_final.
CONSTANTS:
CON_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
CONCATENATE 'Business Place' 'Region Code' 'Region' 'Branch Code'
'Branch' 'Material Desc' 'Area off Code'
'Area Name' 'Zone code' 'Zone Name' 'Cust No' 'Cust Name'
'Bill Doc No' 'Bill Date' 'Base Val' 'Total Val' 'Quantity'
INTO IT_ATTACH SEPARATED BY CON_TAB.
CONCATENATE CON_CRET IT_ATTACH INTO IT_ATTACH.
APPEND IT_ATTACH.
LOOP AT IT_FINAL INTO WA_ITAB.
CONCATENATE WA_ITAB-BUSINESS_PLACE
WA_ITAB-KVGR1
WA_ITAB-REGION
WA_ITAB-VKBUR
WA_ITAB-SALES_OFF
WA_ITAB-ARKTX
WA_ITAB-vkgrp
WA_ITAB-sales_grp
WA_ITAB-bzirk
WA_ITAB-zone
WA_ITAB-kunnr
WA_ITAB-name
WA_ITAB-vbeln
WA_ITAB-fkdat
WA_ITAB-base_value
WA_ITAB-total_value
WA_ITAB-fkimg
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 POPULATE_EMAIL_MESSAGE_BODY
text
--> p1 text
<-- p2 text
FORM POPULATE_EMAIL_MESSAGE_BODY .
REFRESH IT_MESSAGE.
CONCATENATE SY-DATUM6(2) '/' SY-DATUM4(2) '/' SY-DATUM+0(4) INTO G_DATE.
IT_MESSAGE = 'Please find attached excel sheet.'.
APPEND IT_MESSAGE.
IT_MESSAGE = 'Sales Register Report - Set Top Box / Accessories'.
APPEND IT_MESSAGE.
Concatenate 'Report generated date' ':' G_Date '.' into IT_MESSAGE.
APPEND IT_MESSAGE.
clear it_message.
append it_message.
IT_MESSAGE = 'This is an autogenerated mail, please do not reply'.
APPEND IT_MESSAGE.
ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
*& 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.
T_PACKING_LIST-OBJ_NAME = 'stb'.
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-DOC_TYPE = 'XLS'.
T_PACKING_LIST-OBJ_DESCR = LD_ATTDESCRIPTION.
T_PACKING_LIST-OBJ_DESCR = 'Sales_STB'.
T_PACKING_LIST-OBJ_NAME = LD_ATTFILENAME.
T_PACKING_LIST-OBJ_NAME = 'stb'.
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 IT_RECV.
T_RECEIVERS-RECEIVER = IT_RECV-EMAIL.
T_RECEIVERS-REC_TYPE = 'U'.
T_RECEIVERS-COM_TYPE = 'INT'.
T_RECEIVERS-COPY = 'X'.
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 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 = ''
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
Regards
Subramanian -
Sending EMAIL from ABAP Program Configuration+Code(Step by step)
Dear All,
Please anybody can provide me Step by Step document for sending Email from ABAP Program.
Thanks,
RPNot an appropriate forum. Try ABAP forum.
Regards,
Jai Shankar -
Email from ABAP program to outlook with attachment
Hi,
I need to send an email to outlook from my program with an attachment. I wrote my program without attchment feature and working fine. I really donot understand how to do attchment. Can anyone send me some piece of code.
I promise points will be rewarded for useful answers.
Thanks In Advance.
Rajesh.Here is a sample program how to attach a sapscript output to your email.
REPORT ZRICH_0003.
DATA: ITCPO LIKE ITCPO,
TAB_LINES LIKE SY-TABIX.
* Variables for EMAIL functionality
DATA: MAILDATA LIKE SODOCCHGI1.
DATA: MAILPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
DATA: MAILHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
DATA: MAILBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
DATA: MAILREC LIKE SOMLREC90 OCCURS 0 WITH HEADER LINE.
DATA: SOLISTI1 LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
PERFORM SEND_FORM_VIA_EMAIL.
* FORM SEND_FORM_VIA_EMAIL *
FORM SEND_FORM_VIA_EMAIL.
CLEAR: MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
REFRESH: MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
* Creation of the document to be sent File Name
MAILDATA-OBJ_NAME = 'TEST'.
* Mail Subject
MAILDATA-OBJ_DESCR = 'Subject'.
* Mail Contents
MAILTXT-LINE = 'Here is your file'.
APPEND MAILTXT.
* Prepare Packing List
PERFORM PREPARE_PACKING_LIST.
* Set recipient - email address here!!!
MAILREC-RECEIVER = '[email protected]'.
MAILREC-REC_TYPE = 'U'.
APPEND MAILREC.
* Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = MAILDATA
PUT_IN_OUTBOX = ' '
TABLES
PACKING_LIST = MAILPACK
OBJECT_HEADER = MAILHEAD
CONTENTS_BIN = MAILBIN
CONTENTS_TXT = MAILTXT
RECEIVERS = MAILREC
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
ENDFORM.
* Form PREPARE_PACKING_LIST
FORM PREPARE_PACKING_LIST.
CLEAR: MAILPACK, MAILBIN, MAILHEAD.
REFRESH: MAILPACK, MAILBIN, MAILHEAD.
DESCRIBE TABLE MAILTXT LINES TAB_LINES.
READ TABLE MAILTXT INDEX TAB_LINES.
MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
* Creation of the entry for the compressed document
CLEAR MAILPACK-TRANSF_BIN.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 0.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'RAW'.
APPEND MAILPACK.
* Creation of the document attachment
* This form gets the OTF code from the SAPscript form.
* If you already have your OTF code, I believe that you may
* be able to skip this form. just do the following code, looping thru
* your SOLISTI1 and updating MAILBIN.
PERFORM GET_OTF_CODE.
LOOP AT SOLISTI1.
MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
APPEND MAILBIN.
ENDLOOP.
DESCRIBE TABLE MAILBIN LINES TAB_LINES.
MAILHEAD = 'TEST.OTF'.
APPEND MAILHEAD.
** Creation of the entry for the compressed attachment
MAILPACK-TRANSF_BIN = 'X'.
MAILPACK-HEAD_START = 1.
MAILPACK-HEAD_NUM = 1.
MAILPACK-BODY_START = 1.
MAILPACK-BODY_NUM = TAB_LINES.
MAILPACK-DOC_TYPE = 'OTF'.
MAILPACK-OBJ_NAME = 'TEST'.
MAILPACK-OBJ_DESCR = 'Subject'.
MAILPACK-DOC_SIZE = TAB_LINES * 255.
APPEND MAILPACK.
ENDFORM.
* Form GET_OTF_CODE
FORM GET_OTF_CODE.
DATA: BEGIN OF OTF OCCURS 0.
INCLUDE STRUCTURE ITCOO .
DATA: END OF OTF.
DATA: ITCPO LIKE ITCPO.
DATA: ITCPP LIKE ITCPP.
CLEAR ITCPO.
ITCPO-TDGETOTF = 'X'.
* Start writing OTF code
CALL FUNCTION 'OPEN_FORM'
EXPORTING
FORM = 'ZTEST_FORM'
LANGUAGE = SY-LANGU
OPTIONS = ITCPO
DIALOG = ' '
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'START_FORM'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
WINDOW = 'MAIN'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
* Close up Form and get OTF code
CALL FUNCTION 'END_FORM'
EXCEPTIONS
ERROR_MESSAGE = 01
OTHERS = 02.
MOVE-CORRESPONDING ITCPO TO ITCPP.
CALL FUNCTION 'CLOSE_FORM'
IMPORTING
RESULT = ITCPP
TABLES
OTFDATA = OTF
EXCEPTIONS
OTHERS = 1.
* Move OTF code to structure SOLI form email
CLEAR SOLISTI1. REFRESH SOLISTI1.
LOOP AT OTF.
SOLISTI1-LINE = OTF.
APPEND SOLISTI1.
ENDLOOP.
ENDFORM.
Regards,
Rich Heilman -
Key/Text table - usage in an ABAP program
Hi Abapers!
I need help about usage of key and text tables.
I have created key and text table and now i want to use them in the abap program. My problem is, that i don't know how to properly read data into internal table from these two tables, so i can show these data in the table control. I also want to know how to save data from text boxes into key and text table (text boxes: txtid, txtlang, txttext).
Key Table:
name: ztbl1
fields: mandt, id
key fields: mandt, id
Text table:
name: ztbl2
fields: mandt, lang, id, text
key fields: mandt, lang, id
Tables are connected together as they should be.
And i don't want to use sm30 for editing table data.
Regards,
EgiMy Dear,
u are loosing the concept of Text table...
Text table are generally used for multi lingual F4 (i.e you enter vaious F4 list to be displayed for a perticular field when a user from differenct lang log on)
for eg...
in urr text table u have .. 2 key itemm
item_code || lang || text
10111 || E || Eng_Chicken
10111 || D || Chickeno (translation from eng to germen)
10111 || F || Ghoose..
so when a user with logon lang as 'E' will log on and when he press F4 on item_code he ill see Eng_chicken
but when a user with logon lang as 'D' will log on and when he press F4 on item_code he ill see Chickeno not Eng_chicken..
i hope u understood the whole concept...
No rewards Plz... -
Copy Attachement in CV03N via ABAP program
I would like to copy an attachment in CV03N to my C: drive. I can do this by right clicking on the file and selecting Copy To. I need to do this via an ABAP program. Is this possible?
Thanks GaryFound the answer....
CALL FUNCTION 'CVAPI_DOC_VIEW' copies attachment from CV03N to my PC -
Reading email using abap program
Hi All,
I have a requirement to read inbox mails through abap program.
Also from address, to address, subject.
Could someone help me !!
Thanks in advance,
Venkat
Moderator message : Requirements dumping not allowed, show the work you have already done. Thread locked.
Edited by: Vinod Kumar on Jan 30, 2012 11:37 AMHi,
Please find below the tables if you are usinG BI 7.0
For 3.5 also they are almost similar...
Getting Details regarding DSO
1) RSDODSO
2) RSDODSOT
3) RSDODSOIOBJ
4) RSDODSOATRNAV
Getting Details regarding InfoObjects
5) RSDIOBJ
6) RSDIOBJT
Getting Details regarding DataSource
7) RSDSSEG
8) RSDS
9) RSDST
10) RSDSSEGFD
Getting Details regarding Transformation
11) RSTRAN
12) RSTRANFIELD
13) RSTRANRULE
Getting Details regarding InfoCube
14) RSDDIME
15) RSDCUBE
16) RSDCUBEIOBJ
17) RSDDIMEIOBJ
18) RSDCUBET
19) RSDDIMET
Getting Details regarding MultiProvider
20) RSDCUBEMULTI
21) RSDICMULTIIOBJ
Getting Details regarding Queries
22) RSREPDIR
23) RSZELTTXT
Based on the above tables ,we can write our own generic program based on your needs.....
These tables help you a lot in order to achieve that.
Regards
vamsi -
How to convert a Word document to text or html in an ABAP program
Hi,
At my client's site, for the recruitment system, they have the word processing system set to RTF, instead of SAP Script. This means that all the correspondence is in Word format. A standard SAP program takes the word letter, loads word, does the mail merge with the applicant's info and then sends the document to a printer.
The program name is RPAPRT05. The program creates a document proxy (interface I_OI_DOCUMENT_PROXY) and manipulates the document using the methods of the interface.
Now what we want to do is to instead of sending the document to a printer, we want to email the document contents to the applicant. But I don't know how to get the content from the Word document into text or html format so that I can make an email from it.
I know I can send an email with the word document as an attachment, but we'd prefer not to do that.
I would appreciate any help very much.
ThanksOk, here's what I ended up doing:
First of, in order to call FM 'CONVERT_RTF_TO_ITF' you need the RTF document in a table with line length 156. The document is returned from FM 'DP_CREATE_URL' in a table with line length 132. So first I convert the table:
Transform data table from 132 character lines to
256 character lines
LOOP AT data_table INTO dataline.
IF newrow = 'X'.
Add row to new table
APPEND INITIAL LINE TO xdatatab ASSIGNING .
newrow = space.
ENDIF.
Convert the raw line of old table to characters
ASSIGN dataline TO .
Check line lengths to determine how to add the
next line of old table
newlinelen = STRLEN( newline ).
ADD addspaces TO newlinelen.
linepos = linemax - newlinelen.
IF linepos > datalen.
Enough space available in new table line for all of old table line
newline+newlinelen = oldline.
oldlinelen = STRLEN( oldline ).
addspaces = datalen - oldlinelen.
CONTINUE.
ELSE.
Fill up new table line
newline+newlinelen(linepos) = oldline(linepos).
ASSIGN newline TO .
newrow = 'X'.
Save the remainder of old table to the new table line
IF linepos < datalen.
oldlinelen = STRLEN( oldline ).
addspaces = datalen - oldlinelen.
CLEAR newline.
newline = oldline+linepos.
ELSE.
CLEAR newline.
ENDIF.
ENDIF.
ENDLOOP.
Write the last line to the table
IF newrow = 'X'.
APPEND INITIAL LINE TO xdatatab ASSIGNING .
Next I call FM 'CONVERT_RTF_TO_ITF' to get the document in SAPScript format:
Convert the RTF format to SAPScript
CALL FUNCTION 'CONVERT_RTF_TO_ITF'
EXPORTING
header = dochead
x_datatab = xdatatab
x_size = xsize
IMPORTING
with_tab_e = withtab
TABLES
itf_lines = itf_table
EXCEPTIONS
invalid_tabletype = 1
missing_size = 2
OTHERS = 4.
This returns the document still containing the mail merge fields which needs to be filled in:
LOOP AT itf_table INTO itf_line.
WHILE itf_line CS '«'.
startpos = sy-fdpos + 1.
IF itf_line CS '»'.
tokenlength = sy-fdpos - startpos.
ENDIF.
token = itf_line+startpos(tokenlength).
REPLACE '_' IN token WITH '-'.
ASSIGN (token) TO .
ENDIF.
MODIFY itf_table FROM itf_line.
ENDWHILE.
ENDLOOP.
And finally I use FM 'CONVERT_ITF_TO_ASCII' to convert the SAPScript to text. I set the line lengths to 60, since that's a good length to format emails to.
Convert document to 60 char wide ascii document for emailing
CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
EXPORTING
formatwidth = 60
IMPORTING
c_datatab = asciidoctab
x_size = documentsize
TABLES
itf_lines = itf_table
EXCEPTIONS
invalid_tabletype = 1
OTHERS = 2.
And then the text document gets passed to FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' as the email body. -
Html Email from abap program itab - html - email
hi experts..
i want to convert an itab into html and then with html format send an email , following is the code for that
report, the email is coming but not in the html format,
can any body help me in this regard...
thanks in advance
umer
<< Please only post the relevant portions of your code - and format it.>>
Edited by: Umer Malik on Jun 5, 2009 3:48 PM
Edited by: Umer Malik on Jun 5, 2009 4:03 PM
Edited by: Rob Burbank on Jun 5, 2009 10:11 AMHi,
Check this.
TABLES: KNA1.
DATA DECLARATION
DATA : IT_DATA_XML TYPE STANDARD TABLE OF KNA1 WITH HEADER LINE.
DATA : XML_RESULT TYPE STRING.
SELECT OPTIONS
selection-screen begin of block abc with frame title text-001.
selection-screen skip.
SELECT-OPTIONS: SO_KUNNR FOR KNA1-KUNNR.
selection-screen skip.
selection-screen end of block abc.
*START OF SELECTION
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM GET_INTO_XML_FORMAT.
FORM GET_DATA
FORM GET_DATA.
SELECT * FROM KNA1 INTO TABLE IT_DATA_XML
WHERE KUNNR IN SO_KUNNR.
IF SY-SUBRC <> 0.
MESSAGE 'RECORDS NOT FOUND.' TYPE 'E'.
ENDIF.
ENDFORM. "GET_DATA
FORM GET_INTO_XML_FORMAT
FORM GET_INTO_XML_FORMAT.
call transformation id
source SOURCE = IT_DATA_XML[]
result xml XML_RESULT.
refresh IT_DATA_XML.
CALL TRANSFORMATION id
SOURCE XML XML_RESULT
RESULT SOURCE = IT_DATA_XML[].
write: 'this is test'.
ENDFORM. "GET_INTO_XML_FORMAT -
After sending attachment through mail using ABAP program.....
Hello Experts,
I am facing a problem to fulfill a requirement.
My requirement is....sending the data of the internal table to an external mail with attachment(excel format). I have done with this. But when o am opening the excel sheet(attachment) it is showing a message that 'The file you are trying to open is in different format than specified by the file extension'
I am using the extension 'XLS' and 'RAW ' in the coding for the file formats.
You can please suggest your solutions if you know or already faced this type of issues.
Thank you.
Regards,
AnandHi,
The system does not trust you....
I have the feeling that the file you are sending is a text file with the extension 'XLS'
If the file is comma separated values (http://en.wikipedia.org/wiki/Comma-separated_values) then
use the extension 'CSV' if it is a tab separated then use the extension 'TXT' .
Regards.
CSV is also good for tab separated I just checked by a copy of BCS_EXAMPLE_7 and changing:
i_attachment_type = 'CSV' "#EC NOTEXT -
Regarding COLLECT stmt usage in an ABAP Program.
Hi All,
Could anyone please explain if the COLLECT statement really hampers the performance of the program, to a large extent.
If it is so, please explain how the performance can be improved with out using the same.
Thanks & Regards,
Goutham.COLLECT allows you to create unique or summarized datasets. The system first tries to find a table entry corresponding to the table key. (See also Defining Keys for Internal Tables). The key values are taken either from the header line of the internal table itab, or from the explicitly-specified work area wa. The line type of itab must be flat - that is, it cannot itself contain any internal tables. All the components that do not belong to the key must be numeric types ( ABAP Numeric Types).
Notes
COLLECT allows you to create a unique or summarized dataset, and you should only use it when this is necessary. If neither of these characteristics are required, or where the nature of the table in the application means that it is impossible for duplicate entries to occur, you should use INSERT [wa INTO] TABLE itab instead of COLLECT. If you do need the table to be unique or summarized, COLLECT is the most efficient way to achieve it.
If you use COLLECT with a work area, the work area must be compatible with the line type of the internal table.
If you edit a standard table using COLLECT, you should only use the COLLECT or MODIFY ... TRANSPORTING f1 f2 ... statements (where none of f1, f2, ... may be in the key). Only then can you be sure that:
-The internal table actually is unique or summarized
-COLLECT runs efficiently. The check whether the dataset
already contains an entry with the same key has a constant
search time (hash procedure).
If you use any other table modification statements, the check for entries in the dataset with the same key can only run using a linear search (and will accordingly take longer). You can use the function module ABL_TABLE_HASH_STATE to test whether the COLLECT has a constant or linear search time for a given standard table.
Example
Summarized sales figures by company:
TYPES: BEGIN OF COMPANY,
NAME(20) TYPE C,
SALES TYPE I,
END OF COMPANY.
DATA: COMP TYPE COMPANY,
COMPTAB TYPE HASHED TABLE OF COMPANY
WITH UNIQUE KEY NAME.
COMP-NAME = 'Duck'. COMP-SALES = 10. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Tiger'. COMP-SALES = 20. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Duck'. COMP-SALES = 30. COLLECT COMP INTO COMPTAB.
Table COMPTAB now has the following contents:
NAME | SALES
Duck | 40
Tiger | 20 -
Hi !
I am populating the email body with some internal table values. I would like a line feed and carriage return in the email. How do I do it ?
Constants : c_lf(2) TYPE X value '0A'.
c_cr(2) TYPE X value '0D'.
SWC_CREATE_OBJECT MESSAGE 'MESSAGE' SPACE.
SWC_SET_ELEMENT CONTAINER 'DOCUMENTTITLE' 'Title'(020).
SWC_SET_ELEMENT CONTAINER 'DOCUMENTNAME' 'Email message'(020).
SWC_SET_ELEMENT CONTAINER 'DOCUMENTTYPE' 'RAW'.
SWC_SET_ELEMENT CONTAINER 'NO_DIALOG' 'X'.
CONCATENATE 'Dear' firstname INTO CONTENT.
APPEND CONTENT.
CONTENT = c_lf.
APPEND CONTENT.
CONTENT = c_cr.
APPEND CONTENT.
CONTENT 'This is the first line'.
APPEND CONTENT.
The above just appends the hex values of line feed and carriage return into the email body and doesn't actually create a line feed / carriage return.
Any ideas ?
Cheers,
Ashok.If you are using SAP R/3 Enterprise, you might want to look at the class(SE24) CL_ABAP_CHAR_UTILITIES - the attributes section.
Regards,
Subramanian V. -
To send external email from ABAP
How to send external email from ABAP Program and what are the settings to be done for the same ?
Please check..
Sending External email through SAP
What is the FM for sending the external email through SAP by attaching layout set to it?
These are the FM for sending external email :-
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
How to send a report to an external mail-id?
Try this sample code :-
REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.
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. -
Receiver Mail adapter - Text attachment
Hi Folks,
sorry to post again & again same issue.
if i want to achieve (proxy 2 mail scenario) Payload as text attachment in email,
do i need to use below 2 modules in My receiver CC?
Number 1 as AF_Modules/StrictXml2PlainBean
Number 2 as AF_Modules/MessageTransformBean
is it right (the order which i used and Modules which i used)?
Screen shot link of my config:
http://farm4.static.flickr.com/3071/2951413865_498cb4f19b_o.jpg
http://farm4.static.flickr.com/3027/2951427759_d4d3097826_o.jpg
did i make any mistake on my config?
Rightnow i am getting Business content data in the email message inbox only. I am not getting Business data as a attachment.
do i need to use PayloadSWAPBean module also to achieve my req.?
Inputs reg. this will be helpful.
Thanks
PrabaHI Gaurav,
I tested again for ur Try
With XIALL option - i am getting 2 files in a attachment
file name: ATT00001.xml - control records -
output file name : Untitled.xml - Payload (business data)
file name: ATT00001.xml as a attachment in the email
- XI PAYLOAD with out any module( but default sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean - module will be there), with out keep attachments option
output file name : Untitled.xml as a attachment in the email
XI Payload with out any module ( but default sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean - module will be there), with keep attachments
any one has idea on this, plz throw some inputs
Thanks
Praba
Maybe you are looking for
-
Hi All, I need to calculate the vendor balance amount for particular year. Can anyone please let me know related tables for the same and how to find it out. Thanks in advance! Regards, Kannan
-
Want to initiate a batch job in the web server
Hello all! I am using a tomcat server, Mysql database and jsp to perform some data manipulation. I would like to create a java class which could be initiated at specific intervals. My question is, even if we create a class which makes use of Java tim
-
11g Release 2 installation on Oracle Linux 6
Aloha! I I'am installing 11g Release 2 Database on Oracle Linux 6 but i stumble on this problem, that i cant install the said application, either I,m running the wrong file or i downloaded the wrong installation kit for OL 6. 1) I downloaded "Oracle
-
CS6 update Error Code: U44M1P.
I am trying to update my CS6. The update fails with the message: Adobe CSXS Infrastructure 4 Installation failed. Error Code: U44M1P. Does anyone know what that means and how to fix it?
-
Why can adobe reader open documents preview can't?
I recently came across a pdf here for a friend, and was shocked when preview couldn't open it, but adobe reader xi could. I had it in my head that PDF was a standard. Has adobe added something to it? Or did they just insert a script to force me to us