Idoc to txt file to mail
Hello everyone,
I have the following scenario:
IDOC -> XI -> Mail w/ .txt attach with fields of IDOC separated by ';'
How can i "concatenate" all fields into one text file and then send this in an attachment via email ?
Thank you in advance,
Hi Nuno
What you can do here is
1. parse IDOC XML into a flat file using UDF or Java mapping and pass it to a string. use the mail package and map this string field to Content field of mail package. Now at mail adapter use Mail package with attachment.
2. You write a mail adapter module to parse the file and attach it to mail.
3. Use the StrictXMLtoPlain Bean at receiver mail adapter to parse IDOC XML into a flat file and then use MessageTransformBean to attach it to the mail
Using Mail package usage will allow dynamic mail message.
Thanks
Gaurav
Similar Messages
-
How to skip all files other than .txt file in Mail Sender Attachemnt ?
Hi Friends ,
I am reading an Mail attachement and sending to R3 using PaloadSwapBean and MessageTransformBean .
I used to get attachement as .txt file , name like Ex10185.txt in one mail . In another mail Ex10186.txt like that.
If only thoses file comes then no problem .
<b> IF some times along with .txt file some .html files are coming by that time my Mail Adapter incorretly reading the .html file.</b>
<b> Please tell me how to skip those kind of attachements and read only .txt file</b>
Expecting your answers asap.
Best Regards.,
V.RangarajanHi Michal,
Thanks for your reply , Sorry! I am aware of how to write adapter module. Can you please tell me how to write adapter module ?
Is there any links available or Blogs ?
I am expecting your reply asap .
Best Regards.,
V.Rangarajan -
Convert Script output data to Text(.txt) file & send mail with attachment.
Hi All,
Requirement: I shulb be able to conver th Script output data to Text(.text) file & send a maill with attachment with this text file. Formant of text file should be like output of Print priview.
Plese sugget with Function modules to cover as Text file.
I am able to converting the Script output data to PDF and sending mail with attachment. So I don't want PDF file now.
Thanks in advance.Hi, Thanks for responst.
We can convert the Scirpt output to PDF file by using OTF function module and the PDF file looks like Print Privew output.
Same like this I want Script out in NOTEPAD (.txt). Is that possible, Plz sugget with relavent Function Modules.
Thanks. -
Hello All,
I have recived an IDOC DATA in TEXT file.
would u please help me how to create an idoc using the above text file.
Kind Regards,
Dev.Hi,
first put the file in application server and then in we16 give the directory name and the path and the sender port info and press execute..ur idoc will be generated.before that in we21(FILEPORT),in the inboundfile maintain the directory name and the path.
Regards,
Nagaraj -
Separeted enter key / new line Txt File
Hi Experts;
I want to send mail with attach file (xxx.txt).
xxx.txt file's source itab.
I'm seeing xxx.txt file at mail.. But It's not separeted enter key / new line.
I'want to see line-by-line my itab at the xxx.txt file.
How can I make?
Best regards.Hi, Melih.
Try to insert new lines using cl_abap_char_utilities=>newline.
Like this:
DATA:
BEGIN OF gs_tab,
string TYPE string,
END OF gs_tab,
gt_tab LIKE TABLE OF gs_tab WITH HEADER LINE.
gt_tab-string = 'first row'.
APPEND gt_tab.
CONCATENATE 'second row' cl_abap_char_utilities=>newline INTO gt_tab-string.
APPEND gt_tab.
gt_tab-string = 'third row'.
APPEND gt_tab.
Best regards,
George Shlyahov. -
How can i read only .txt file and skip other files in Mail Sender Adapter ?
Hi Friends ,
<b> I am working on scenario like , I have to read an mail attachement and send the data to R3.</b>
It is working fine if only the .txt file comes.
<b>Some times ,html files also coming along with that .txt files. That time my Mail adapter fails to read the .txt file.</b>
I am using PayLoadSwap Bean and MessageTransformBean to swap and send the attachment as payload .
<b>Michal as told to write the Adapter module to skip the files .But i am not ware of the adapter moduel . If any blogs is there for this kind of scenarios please give me the link.</b>
Otherwise , please tell me how to write adapter module for Mail Sender Adapter?
How to download the following
newest patch of XI ADAPTER FRAMEWORK CORE 3.0
from SAP Service Marketplace. Open the file with WinZip and extract the following
SDAs:
aii_af_lib.sda, aii_af_svc.sda
aii_af_cpa_svc.sda
I have searche in servive market place .But i couldn't find that . Can you please provide me the link to download the above .
If any other suggestions other than this please let me know.
Regards.,
V.Rangarajan=P
Dude, netiquette. Messages like "i need this now! Do it!" are really offensive and no one here is being payed to answer anyone's questions. We're here because we like to contribute to the community.
Anyway, in your case, just perform some search on how you could filter the files that are attached to the message. The sample module is just an example, you'll have to implement your own. Tips would be to query the filename of the attachments (or maybe content type) and for the ones which are not text, remove them.
Regards,
Henrique. -
Address Book NOT accepting csv.txt file as import from EARTHLINK web mail
Greetings. Unsuccessful thus far in importing e-addresses from Earthlink Web Mail to MAC Address Book. Found preferences and saved Earthlink addresses as csv.txt file but AB rejected as not true csv. Apple suggested conversion to V cards but could not find that option in Earthlink-ville. Perused Allan's post on synching with Total Access but fear accidentally installing stuff on my MACbook Pro from that application that is unneccessary or will screw up my new MAC world. Although in the long run, having Web mail back up my MAC makes sense. (Work and husband remain PC/ XP.)
Any solutions you can offer will be much appreciated.
Macbook Pro Mac OS X (10.4.9)Thanks again. Okay, I pasted a portion of the csv file . I might be mistaken here, but I don't think these are V card format and perhaps converting them to V cards is what I'd have to do. But I would need pretty explicit directions.
Regards,
Andrea
"First Name","Last Name","Middle Name","Name","Nickname","E-mail Address","E-mail 2 Address","E-mail 3 Address","Home Street","Home City","Home Postal Code","Home State","Home Country/Region","Home Phone","Home Fax","Mobile Phone","Personal Web Page","Business Street","Business City","Business Postal Code","Business State","Business Country/Region","Business Web Page","Business Phone","Business Fax","Pager","Company","Job Title","Department","Office Location","Notes"
"[email protected]","","","[email protected]","","[email protected]","","","","" ,"","","","","","","","","","","","","","","","","","","","",""
"Thomas","Brown","","Thomas Brown","","[email protected]","","","","","","","","","","","","","","",""," ","","","","","","","","",""
"Bob","Nash","","Bob Nash","","[email protected]","","","","","","","","","","","","","","","", "","","","","","","","","","" -
How to send mail from linux with .txt file as attachment ..
I want to send email from linux box and in the body of the email i want to have the content of dblog.txt file.
I want dglob.txt file content to be part of the mail body.
Thanks in advance!!Apr 29 15:19:35 lctwprddb01 sendmail[1616]: m3TJJZ4k001616: to=[email protected], ctladdr=oracle (500/500), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30109, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (m3TJJZhB001617 Message accepted for delivery)
Apr 29 16:04:52 lctwprddb01 sendmail[1422]: m3TIP6LJ031388: to=<[email protected]>, ctladdr=<[email protected]> (500/500), delay=01:39:46, xdelay=00:48:01, mailer=esmtp, pri=120423, relay=cluster2a.us.messagelabs.com. [216.82.249.211], dsn=4.0.0, stat=Deferred: Connection timed out with cluster2a.us.messagelabs.com.
Apr 29 16:07:36 lctwprddb01 sendmail[1619]: m3TJJZhB001617: to=<[email protected]>, ctladdr=<[email protected]> (500/500), delay=00:48:01, xdelay=00:48:01, mailer=esmtp, pri=120425, relay=cluster2a.us.messagelabs.com. [216.82.248.44], dsn=4.0.0, stat=Deferred: Connection timed out with cluster2a.us.messagelabs.com.
Apr 29 16:07:52 lctwprddb01 sendmail[1627]: m3TILs2r031176: to=<[email protected]>, ctladdr=<[email protected]> (500/500), delay=01:45:58, xdelay=00:48:01, mailer=esmtp, pri=120429, relay=cluster2a.us.messagelabs.com. [216.82.248.45], dsn=4.0.0, stat=Deferred: Connection timed out with cluster2a.us.messagelabs.com. -
N IDoc s message to one txt file
I have finished IDoc to file scenarios.
If I send n IDocs , there will be n txt files.
Can I just get a TXT file, with one line with one IDoc?
Thanks.hi
Another idea for collecting IDocs consists in using standard functionality of the IDoc. Instead of sending the IDoc directly to the XI via the IDoc adapter, you can download the IDocs gathered in a file with XML format. This file can now be uploaded by the sender file adapter. As the XML structure is the same as the IDoc adapter produces, there is no change of the behaviour of the message, besides there no single IDoc inside, but multiple IDocs instead.
1)As first step you go to WE21 and create an XML file port in the application system. Apply here a function module for creating the file name. You can use a standard module or a self-written module.
2)Schedule report RSEOUT00 with a variant where you assign the IDoc type, the xml port and the number of IDocs which shall be collected.
3)The report collects all IDocs in one file, until the "Maximal number of IDoc" is reached. When you have for example 2400 IDocs and you set "Maximal number of IDoc" to 1000, you receive 3 files, two with 1000 IDocs and one with 400. Inside the file there is one IDoc tag for each IDoc.
Do not gather too many IDocs into one file. The file size should be considered carefully. Too large files might cause memory leaks, when your hardware is not sufficient.
The files can be uploaded by the sender file adapter. When you collect IDocs of the same type, the Mapping can be done the same way as for IDocs processed by the IDoc adapter.
check the blog
/people/stefan.grube/blog/2006/09/18/collecting-idocs-without-using-bpm
Note: reward points if solution found helpfull
Regards
Chandrakanth.k -
Coverting txt file to orders05 IDOC
Hi all,
Want to convert a text file(normal flat text file) into an orders05 Idoc which in turn should be commited to an SAP sytem and could be viewable by calling the transaction VA03.
It was decided to write an ABAP report program for this.
The txt file looks as follows.
Each number on a row seperated by space or tab indicates
plant,soldToparty,ShipToParty,orderreference,delivery date,itemnumber,quantity,ordertype,way of shipment in that order.
0700 91485 96291 123456 24022010 000798757 3 OR AU
0700 91485 96291 123456 24022010 1060022568 3 OR AU
The above text file is saved in a directory.
This file should be read and converted to an idoc by writing an ABAP program.
Any ideas in this direction is greatly appreciated.
Thanks
KI have to write a report to do this.
So in whichever system from which this report transaction is called have to create a sales order in that system.
It is my system,then.
Which BAPI and how is it going to work.
Please elaborate how to read the file and create an order ,if thats the case.
Iam having the sap r/3 enterprise release.
K -
Problem in send mail with .txt file attached
According to the diferent checks, I found the next problems:
1.- Between each caracters there is an space, example:(E Q U I P M E N T) and could be (EQUIPMENT), the last one is the correct form.
2.- For example, two registers in my internal table appear in one line of my .txt file, but i want that each register of my internal table appear in differents lines of my .txt file.
3.- The length of each register of my internal table (objbin) is 255 characters, but i really want that the length of each register of my internal table be 1023 characters.
Thank youThis is my perform:
FORM z_envia_correo .
DATA: docu_data LIKE SODOCCHGI1,
tablines TYPE i,
destinatarios like somlreci1 occurs 1 with header line.
DATA: BEGIN OF packlist OCCURS 0.
INCLUDE STRUCTURE SOPCKLSTI1.
DATA: END OF packlist.
DATA: BEGIN OF objbin OCCURS 0.
INCLUDE STRUCTURE SOLISTI1.
DATA: END OF objbin.
DATA: BEGIN OF object_header OCCURS 0.
INCLUDE STRUCTURE SOLISTI1.
DATA: END OF object_header.
DATA: BEGIN OF contents OCCURS 0.
INCLUDE STRUCTURE SOLISTI1.
DATA: END OF contents.
*-->ihv270907
DATA: l_string TYPE string,
l_fecha(10) TYPE c,
l_dia(2) TYPE c,
l_mes(2) TYPE c,
l_ano(4) TYPE c,
l_hora(8) TYPE c,
l_h(2) TYPE c,
l_min(2) TYPE c,
l_seg(2) TYPE c.
*<--ihv270907
Variable del destinatario para enviar el mail
DATA: l_usrnam TYPE string.
*Caracter salto de linea
FIELD-SYMBOLS <hex_container> TYPE c.
CONSTANTS: zz_tab TYPE x VALUE '0D' LENGTH 4. "valor del salto de linea en hexadecimal
ASSIGN zz_tab TO <hex_container> CASTING.
cargo el texto de cabecera del mail
CLEAR docu_data.
docu_data-obj_name = 'ZFLOTA'.
CONCATENATE 'ZFLOTA' sy-datum INTO docu_data-obj_descr SEPARATED BY space.
docu_data-proc_type = 'T'.
docu_data-proc_name = 'ZFLOTA'.
cargo el texto del cuerpo del mail
CLEAR contents.
*-->ihv270907
l_string = TEXT-I04.
REPLACE '&' IN l_string WITH sy-uname.
l_ano = sy-datum+0(4).
l_mes = sy-datum+4(2).
l_dia = sy-datum+6(2).
CONCATENATE l_dia l_mes l_ano INTO l_fecha SEPARATED BY '/'.
REPLACE '&' IN l_string WITH l_fecha.
l_h = sy-uzeit+0(2).
l_min = sy-uzeit+2(2).
l_seg = sy-uzeit+4(2).
CONCATENATE l_h l_min l_seg INTO l_hora SEPARATED BY ':'.
REPLACE '&' IN l_string WITH l_hora.
contents = l_string.
*<--ihv270907
APPEND contents.
DESCRIBE TABLE contents LINES tablines.
READ TABLE contents INDEX tablines.
docu_data-doc_size = ( tablines - 1 ) * 255 + STRLEN( contents ).
cargo el contenido del attachmet
LOOP AT g_gt_outtab_mail.
g_gt_outtab_mail-line+254(1) = <hex_container>.
MOVE g_gt_outtab_mail-line TO objbin-line.
APPEND objbin.
ENDLOOP.
genero el nombre del archivo a ser attachado
CLEAR object_header.
object_header-line = 'ZFLOTA.txt'.
APPEND object_header.
armo las caracteristicas del mail
CLEAR packlist.
packlist-head_start = 1.
packlist-head_num = 0.
packlist-body_start = 1.
packlist-body_num = tablines.
packlist-transf_bin = space.
packlist-doc_type = 'RAW'.
APPEND packlist.
armo las caracteristicas del attachment
DESCRIBE TABLE objbin LINES tablines.
packlist-transf_bin = 'X'.
packlist-head_start = 1.
packlist-head_num = 0.
packlist-body_start = 1.
packlist-body_num = tablines.
packlist-doc_type = 'TXT'.
packlist-obj_name = 'ZFLOTA.txt'.
packlist-obj_descr = 'ZFLOTA.txt'.
packlist-doc_size = tablines * 250.
APPEND packlist.
Destinatarios
l_usrnam = sy-uname.
MOVE: l_usrnam TO destinatarios-receiver.
destinatarios-rec_type = 'B'. "U externo; B -> SAP
destinatarios-sap_body = 'X'.
APPEND DESTINATARIOS.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = docu_data
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = packlist
OBJECT_HEADER = object_header
CONTENTS_BIN = objbin
CONTENTS_TXT = contents
RECEIVERS = destinatarios
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " z_envia_correo
Thank you. -
Different Attachment extension(.xls,.txt) in sender mail adapter
Hi Experts
Is it possible to use different type of attachment extension (e.g .xls,.txt) in the sender mail adapter?
My requirement is , the attachment in the mail adapter will be used as the main payload.So I am using PayloadSwapBean adapter module.
Currently I am using the following module key for .xls attachment and it is working.Configuration for .xls attachment is as follows
swap.keyName-Content-Disposition
swap.keyname-Content-Description
swap.keyName-Content-Type
swap.keyValue-attachment;filename="MailAttachment-1.xls"
swap.keyValue-MailAttachment-1
swap.keyValue-application/vnd.ms-excel.
Now, the attachment may be .xls or .txt file.
Now If I want to use .txt atachment then do I need to define all these parameter again and in that case what will be my content type for .txt file.
Your inputs required
thanks
AyanPayloadSwapBean will only convert the attachment as the main payload.
Yeah for reading excel file I have a separate custom adapter module.This is not in the scope of my question..
All I am asking , can .txt as well as .xls attachment be used in the same sender mail adapter.
If that is possible what will be my content-type for .txt or can I remove content-type and use only content-disposition and content-description so that any type of attachment it can recognise.
The momment I am specifying content-type , I am making it particular that only say .xls attachment , it will identify.
I hope I make you clear.Inputs required
Thanks
Ayan -
HOW TO READ AND OPEN Zip files IN MAIL?
Anyone know how to open and read attached zip-files in iPhone 3G mail?
Thanks in advance,
AlessioHi Alessio,
The iPhone does not support reading or uncompressing .zip files.
+Mail attachment support+
+Viewable document types: .jpg, .tiff, .gif (images); .doc and .docx (Microsoft Word); .htm and .html (web pages); .key (Keynote); .numbers (Numbers); .pages (Pages); .pdf (Preview and Adobe Acrobat); .ppt and .pptx (Microsoft PowerPoint); .txt (text); .vcf (contact information); .xls and .xlsx (Microsoft Excel)+
http://www.apple.com/iphone/specs.html
Jason -
How to read the second line in a .txt file with bufferedReader?
hi,
i am not the best in speaking english and programming java :)
so, just try to make sense of my question:
Im using a BufferedReader to read a .txt file.
the .txt file has 5+ different lines, and each line has 6 tokens (separated with ; )
My java file has 6 textFields and each textfield is filled with one of the 6 different tokens.
and my problem is:
I want my buffered reader to read the next line (with 6 new different tokens) by pressing a button.
if somethings not understandable, just ask :)maybe its easier to help me, when i publish my code, so here it is:
(its my version, without Thof's code. Sorry, but the comments are the most in german)
/* userdata.java */
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
public class userdata extends Frame {
//-----------------------------------KlassenVariablen------------------------------------------------
private JPanel panel = new JPanel ();
String tokId = "";
String tokName= "";
String tokAge= "";
String tokTel= "";
String tokMail= "";
String tokText= "";
BufferedReader br;
String zeile;
StringTokenizer st;
String delim = ";";
//---------Buttons f?r Panel 1-------------------------
Button first = new Button("|< First");
Button back = new Button("< Back");
Button next = new Button("Next >");
Button last = new Button("Last >|");
//---------Buttons f?r Panel 3-------------------------
Button neu = new Button("New");
Button safe = new Button("Safe");
Button refresh = new Button("Refresh");
//--------Labels f?r Panel 2-----------------------------
Label lid = new Label("ID",Label.LEFT);
Label lname = new Label("Name",Label.LEFT);
Label lage = new Label("Age",Label.LEFT);
Label ltel = new Label("Tel.",Label.LEFT);
Label lmail = new Label("E-Mail",Label.LEFT);
Label ltext = new Label("Spruch",Label.LEFT);
Label lub = new Label("Last Button",Label.LEFT);
TextField id = new TextField();
TextField name = new TextField();
TextField age = new TextField();
TextField tel = new TextField();
TextField mail = new TextField();
TextField text = new TextField();
TextField usedbutton = new TextField();
//--------ActionEvent bla sachen eben--------------------
public static void main (String[] args) throws IOException {
userdata wnd = new userdata();
wnd.setVisible(true);
public userdata() throws IOException {
//--------------------------------Layout mit panel bestimmung--------------------------------------
setLayout(new BorderLayout());
JPanel p1 = new JPanel();
JPanel p2 = new JPanel();
JPanel p3 = new JPanel();
add(BorderLayout.NORTH ,p1);
add(BorderLayout.CENTER , p2);
add(BorderLayout.SOUTH , p3);
//-------------------------------Funktionslose Buttons in PANEL 1------------------------------------
p1.add(first);
p1.add(back);
p1.add(next);
p1.add(last);
p1.add(usedbutton);
//--------------------------------Funktionierende Textfelder in PANEL 2------------------------------
Panel labelpanel = new Panel();
p2.setLayout(new GridLayout(7,3));
p2.add(lid);
p2.add(id);
p2.add(lname);
p2.add(name);
p2.add(lage);
p2.add(age);
p2.add(ltel);
p2.add(tel);
p2.add(lmail);
p2.add(mail);
p2.add(ltext);
p2.add(text);
p2.add(lub);
p2.add(usedbutton);
//--------------------------------------Buttons in PANEL 3-----------------------------------------
p3.add(neu);
p3.add(safe);
p3.add(refresh);
//--------------------------------BufferedReader -------------------------------------------------
readData();
//--------------------------------Panel 2 TextField-----------------------------------------------
fillForm();
//================================ActionPerformed==================================================
first.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("First");
usedbutton.setText("First");
back.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Back");
usedbutton.setText("Back");
next.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Next");
usedbutton.setText("Next");
last.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Last");
usedbutton.setText("Last");
neu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("New entry");
usedbutton.setText("New");
safe.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
System.out.println ("Now Saving, do not turn off!");
usedbutton.setText("Save");
//-----------------refresh
refresh.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed( ActionEvent e ) {
try{
readData();
}catch( IOException ioe){
System.out.println("Fehler beim lesen aus Datei");
fillForm();
usedbutton.setText("Refresh");
//=============================================================================Button Funktionen!!!
pack();
//--------------------------------WindowsListener hinzuf?gene--------------------------------------
addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent event)
setVisible(false);
dispose();
System.exit(0);
//-----------------------------------readData() - > Buffered Reader in aktion! --------------------
private void readData() throws IOException{
BufferedReader br = new BufferedReader(new FileReader("My .txt File with path"));
String zeile;
StringTokenizer st;
String delim = ";";
zeile = br.readLine();
st = new StringTokenizer(zeile, delim);
st.hasMoreTokens();
//System.out.println (st.nextToken());
tokId = new String(st.nextToken());
tokName = new String (st.nextToken());
tokAge = new String (st.nextToken());
tokTel = new String (st.nextToken());
tokMail = new String (st.nextToken());
tokText = new String (st.nextToken());
//--------------------------fillForm() - > f?llt die TextFelder aus!--------------------------------
private void fillForm(){
id.setText(tokId);
name.setText(tokName);
age.setText(tokAge);
tel.setText(tokTel);
mail.setText(tokMail);
text.setText(tokText);
} -
Email attachment with .txt file (first line blank in the file)
Hi all ,
Iam trying attach .txt file to email , the file that iam accessing from server . But first line blank (extra) even though i dont have blank line in original file .Can any help me out to resolve this issue?
<u>Example</u> original file
12345 aa pq
<u>Email attachment file</u>
-> This line
12345 aa pq
This is my code:
REPORT ZTEST_FILE .
DATA:BEGIN OF t_upload occurs 0,
matnr LIKE zwplcsmev-matnr,
zwgehrrg LIKE zwplcsmev-zwgehrrg,
zwgehrct LIKE zwplcsmev-zwgehrct,
zwgbev LIKE zwplcsmev-zwgbev,
zwpldt LIKE zwplcsmev-zwpldt,
zwacdt LIKE zwplcsmev-zwacdt,
END OF t_upload.
*DATA: maildata type sodocchgi1.
*DATA: mailtxt type table of solisti1 with header line.
*DATA: mailrec type table of somlrec90 with header line.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA:REC(80) TYPE C.
DATA g_mask(20) TYPE c VALUE ',., ..'.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA:P_ERROR(3).
DATA:P_REFO(3).
DATA: gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1.
selection-screen begin of block b1 with frame title text-001.
parameters:p_file type localfile.
parameter:p_email type ad_smtpadr.
selection-screen end of block b1.
--At Selection-Screen- -
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'TB_LIMIT_WS_FILENAME_GET'
EXPORTING
def_filename = p_file
mask = g_mask
mode = 'S'
title = 'INPUT FILE'
IMPORTING
filename = p_file
EXCEPTIONS
selection_cancel = 1
selection_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
START-OF-SELECTION.
PERFORM process_file.
if p_error = 'X' AND P_REFO <> 'X'.
PERFORM populate_message_body.
ENDIF.
IF P_REFO = 'X' AND P_ERROR <> 'X'.
it_message = 'Please find Attached file'.
APPEND it_message.
PERFORM send_attachment tables it_message
it_attach
using p_email
'Crest to Plc Data'
'TXT'
p_file
changing gd_error
gd_reciever.
ENDIF.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
END-OF-SELECTION.
*& Form process_file
text
FORM process_file.
*CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
DATA :l_path TYPE string.
l_path = p_file.
CONSTANTS: con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB
con_cret type c value cl_abap_char_utilities=>newline.
OPEN DATASET P_FILE FOR INPUT IN TEXT MODE encoding default.
if sy-subrc = 0.
do.
read dataset p_file into IT_ATTACH.
IF SY-SUBRC NE 0 .
EXIT.
ELSE.
T_UPLOAD = IT_ATTACH.
CONCATENATE con_cret it_attach INTO it_attach .
append it_attach.
clear it_attach.
P_REFO = 'X'.
APPEND T_UPLOAD .
clear t_upload.
ENDIF.
ENDDO.
else.
p_error = 'X'.
ENDIF.
ENDFORM. "process_file
*& Form populate_message_body
text
FORM populate_message_body.
w_doc_data-obj_name = 'TEST'.
w_doc_data-obj_descr = 'Crest to Plc Data'.
w_doc_data-obj_langu = sy-langu.
it_message = 'File Not Found'.
APPEND it_message.
t_receivers-receiver = p_email.
t_receivers-rec_type = 'U'.
append t_receivers.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = w_doc_data
document_type = 'RAW'
put_in_outbox = 'X'
tables
object_header = it_message
object_content = 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.
if sy-subrc = 0.
commit work.
SUBMIT rsconn01 USING SELECTION-SET 'SAP&CONNECTINT' AND RETURN.
else.
MESSAGE s027(vv) WITH 'E-mail not sent'.
endif.
ENDFORM. "populate_message_body
*& Form send_attachment
text
FORM send_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.
w_doc_data-doc_size = 1.
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[].
clear t_attachment.
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.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
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.
if sy-subrc = 0.
commit work.
SUBMIT rsconn01 USING SELECTION-SET 'SAP&CONNECTINT' AND RETURN.
else.
MESSAGE s027(vv) WITH 'E-mail not sent'.
endif.
Populate error return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. "send_attachmentJust copy the code below and execute . I just checked and found the exact values on attachment with no blank lines. This is more simple than the one u have written , just include ur data upload logic . For ITAB values to be attached i have written a simple logic to retrive from EKPO. Just copy this code and execute. u will understand then.
I understand that ur initial requirement was to attach the file directly and not to upload and attach. If u still want to go for the old requirement then check out the code(2nd program of the two that i have sent) that i have sent u on ur previous post.
REPORT ZEMAIL_ATTACH .
TABLES: ekko.
PARAMETERS: p_email TYPE somlreci1-receiver
DEFAULT '[email protected]'.
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
wa_ekpo TYPE t_ekpo.
TYPES: BEGIN OF t_charekpo,
ebeln(10) TYPE c,
ebelp(5) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.
DATA: wa_charekpo TYPE t_charekpo.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
*START_OF_SELECTION
START-OF-SELECTION.
Retrieve sample data from table ekpo
PERFORM data_retrieval.
Populate table with detaisl to be entered into .xls file
PERFORM build_TXT_data_table.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
perform populate_email_message_body.
Send file by email as .TXT speadsheet
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example .TXT documnet attachment'
'TXT'
'filename'
changing gd_error
gd_reciever.
Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp aedat matnr
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekpo.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_TXT_DATA_TABLE
Build data table for .txt document
FORM build_txt_data_table.
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 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO it_attach SEPARATED BY SPACE . "con_tab.
CONCATENATE con_cret it_attach INTO it_attach." Use this if req.
APPEND it_attach.
LOOP AT it_ekpo INTO wa_charekpo.
CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
wa_charekpo-aedat wa_charekpo-matnr
INTO it_attach SEPARATED BY SPACE ."con_tab.
CONCATENATE con_cret it_attach INTO it_attach." Use this if req.
APPEND it_attach.
ENDLOOP.
ENDFORM. " BUILD_txt_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
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.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test ekpo records'.
APPEND it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY
execute this code and i hope that will help u.
regards,
Barath.
Maybe you are looking for
-
Need a login strategy for JSF application
I have inherited a JSF application (prototype) and need to modify this application to require a user login. Right now, the application requires a login only for a sub-portion of the application, well after JSF is up and running. That has to change to
-
After importing a small group of photo's I noticed that aperture didn't create a project for them as usual. The only place I could see them was in last imported. While last importwas open I selected the photo's and told aperture to creat a new projec
-
External Monitoring with MXO2 Mini not working
OK, I chose the Matrox 1080i60 Sequence Preset. And then I import and use AVCINTRA P2 footage. When I put it into the sequence...I see the clips on the timeline, but nothing in the Program monitor, nor my external monitor. I press play...nothing h
-
Hi, I am trying to load the ECC - FI AR data to SAP BI using the extractor 0FI_AR_4. The period balances get populated but the opening balances miss out. I checked the BSID and BSAD tables for period 00 but could not find any data. How to get AR - pe
-
Hi All, When I starting the ASM in a RAC box I am getting the below erro. How can I proceed with this error. From sqlplus I can stat the ASM instance. But from srvctl i can't. [oracle@node1 admin]$ srvctl start asm -n node1 -i +ASM1 PRKS-1009 : Faile