Code to pickup app.server file and Email the same!!!

Hi,
I need to write an ABAP code to pickup a file in application server and Email the same file to the intended receipients--
Can i get the code pls?

Hi Simran,
Please search the forum. There are many sample codes available for reading data in application server and mail sending.
User statements OPEN DATASET, READ DATASET and CLOSE DATA SET to get the application server data. Check F1 on these. You will come to know many interesting things.
Below is the sample code for mail sending.
DATA: li_reclist  TYPE STANDARD TABLE OF somlreci1,
      li_objpack  TYPE STANDARD TABLE OF sopcklsti1,
      li_content  TYPE STANDARD TABLE OF solisti1,
      lwa_reclist TYPE somlreci1,
      lwa_objpack TYPE sopcklsti1,
      lwa_content TYPE solisti1,
      lwa_doc     TYPE sodocchgi1,
      l_lines     TYPE i.
REFRESH: li_reclist[], li_objpack[],
         li_content[].
CLEAR: lwa_reclist, lwa_objpack,
       lwa_content, lwa_doc.
lwa_reclist-receiver = "Give ur mail ID here.
lwa_reclist-rec_type = 'U'.
APPEND lwa_reclist TO li_reclist.
"Here Loop at ur internal table and populate the data
lwa_content = 'Please Check with your sales team for more details'.
APPEND lwa_content TO li_content.
CLEAR l_lines.
DESCRIBE TABLE li_content LINES l_lines.
READ TABLE li_content INTO lwa_content INDEX l_lines.
lwa_doc-doc_size = ( l_lines - 1 ) * 255 + STRLEN( lwa_content ).
lwa_doc-obj_langu  = 'E'.
CONCATENATE 'Sales order' vbak-vbeln 'deleted.' INTO lwa_doc-obj_descr
         SEPARATED BY space.
CLEAR lwa_objpack-transf_bin.
lwa_objpack-head_start = 1.
lwa_objpack-head_num = 0.
lwa_objpack-body_start = 1.
lwa_objpack-body_num = l_lines.
lwa_objpack-doc_type = 'RAW'.
APPEND lwa_objpack TO li_objpack.
*Sending the mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
    DOCUMENT_DATA                    = lwa_doc
*   PUT_IN_OUTBOX                    = ' '
   COMMIT_WORK                      = 'X'
* IMPORTING
*   SENT_TO_ALL                      =
*   NEW_OBJECT_ID                    =
  TABLES
    PACKING_LIST                     = li_objpack
*   OBJECT_HEADER                    =
*   CONTENTS_BIN                     =
   CONTENTS_TXT                     = li_content
*   CONTENTS_HEX                     =
*   OBJECT_PARA                      =
*   OBJECT_PARB                      =
    RECEIVERS                        = li_reclist
EXCEPTIONS
   TOO_MANY_RECEIVERS               = 1
   DOCUMENT_NOT_SENT                = 2
   DOCUMENT_TYPE_NOT_EXIST          = 3
   OPERATION_NO_AUTHORIZATION       = 4
   PARAMETER_ERROR                  = 5
   X_ERROR                          = 6
   ENQUEUE_ERROR                    = 7
   OTHERS                           = 8
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks,
Vinod.

Similar Messages

  • Want to update a text file and reflect the same on iview immediately

    Dear friends,
    I have a text file in a repository path
    I could read each line and do some task.
    My query is for each line task, i would like to update a file (for me it is log file) and reflec the same on a iview in the same page
    sample code appreciated
    regards
    Kantha

    If the user backs up their device to either iCloud or Mac/PC, they can restore the app data from that backup.
    There's no need to do what you intend.

  • Save data in a file and email the file

    Dear all,
    I have 2 vi files:
    1. one vi file can store data into a file when it runs and stopped
    2. another vi can send a file out through email when it is run.
    Is it possible for me to run the first vi and stop after one hour (to store data into A file), then run the second vi file and stop (to send A file through email), and then run the first vi again immediately after running the second vi? This is because I need to send out my data saved hourly through email and get my 1st vi to continue running through out the day.
    Due to the file path for my first vi and the second vi are the same, I keep getting error as below when either 1 vi is not stopped.
    Error 5 occurred at Open/Create/Replace File in Write Spreadsheet String.vi->Write To Spreadsheet File (DBL).vi
    Please advice. Thanks.
    Kim

    Dear Ravens,
    I tried to kill (remove) the event structure from my earlier code, but as I run it, I get the same error again- error 5.
    I also tried to put time out value 200 at the timenode at the upper left of the event structure but the email part just never executed.
    I searched thru the forum and found a several examples on state machine as attached. I tried the first attachment for my program but obviously I used the wrong one as you adviced. As for the other state machine examples that I downloaded, I couldn't figure out how to apply them for my case correctly. Can you advcice how can I implement state machine to get the results tat I need?... Pls gv me some clearer hints? 
    Attachments:
    QueuedStateMachineWithEvents.vi ‏49 KB
    StandardStateMachine_2MOD.vi ‏19 KB
    JKI State machine.vi ‏75 KB

  • Every File and Email has Same Date

    Hi
    I've seen other similar problems on here but not identical, and nobody seems to have resolved them successfully anyway ...
    All my emails, from different accounts, saved/inbox/stored on own computer/stored elsewhere have the same date, some insignificant date from the past (long before the date I bought the Macbook). I use Thunderbird, but it definitely seems to be a problem with Snow Leopard because it is also true of all the "last modified" etc dates when I try to open files in Microsoft Office - the same date appears every time. I've tried updating Snow Leopard - it doesn't help. Finder shows the file dates correctly.
    I've tried adjusting the "set date automatically" settings and time zones etc, it doesn't make any difference.
    Any suggestions?

    Hi
    I've seen other similar problems on here but not identical, and nobody seems to have resolved them successfully anyway ...
    All my emails, from different accounts, saved/inbox/stored on own computer/stored elsewhere have the same date, some insignificant date from the past (long before the date I bought the Macbook). I use Thunderbird, but it definitely seems to be a problem with Snow Leopard because it is also true of all the "last modified" etc dates when I try to open files in Microsoft Office - the same date appears every time. I've tried updating Snow Leopard - it doesn't help. Finder shows the file dates correctly.
    I've tried adjusting the "set date automatically" settings and time zones etc, it doesn't make any difference.
    Any suggestions?

  • Issue : Read a text file and print the same

    Hi, My requirement is to read a text file and print it the same way.
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class CatFile {
    public static void main(String[] args) throws Exception
         FileReader file = new FileReader("D:/Test/Allfiles.txt");
         BufferedReader reader = new BufferedReader(file);
         String text = "";
         String line = reader.readLine();
         while (line != null)
              text += line;
              line = reader.readLine();
         System.out.println(text);
    The text file i used contains
    A
    B
    C
    but my output is ABC.
    What change should be made to print it the same way in the txt file ?

    Hi EJP,
    I modified the code based on your suggestion and now its working as expected. Thanks
    Modified code :
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class CatFile {
    public static void main(String[] args) throws Exception
         FileReader file = new FileReader("D:/Test/Allfiles.txt");
         BufferedReader reader = new BufferedReader(file);
         String text = "";
         String line = reader.readLine();
         while (line != null)
              System.out.println(line);
              line = reader.readLine();
              text += line;
    }

  • Draw an visio shape as an .vdx file and render the same in a IE browser

    I had generated an Visio Diagrams getting input from the excel file and stored it in an local path.
    private void DynamicVisio_Load(object sender, EventArgs e)
                string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= 'c:\\Test\\FullData3.xls';Extended Properties='Excel 8.0;HDR=Yes;'";
                string sQuery = "select * from [Customer1_Server$] order by Name";
                DataSet objExcelDS = new DataSet();
                OleDbDataAdapter objDA = new OleDbDataAdapter(sQuery, strConn);
                objDA.Fill(objExcelDS);
                double dblX1 = 0.5d;
                double dblY1 = 10.3d;
                double dblX2 = 2.258d;
                double dblY2 = 6.8d;
                String sText = "";
                String sFilePath = "";
                String sDisk = "";
                String[] sArray;
                String[] separators = { "," };
                String sPicturePath = "C:\\Test\\test.png";
                String sIPRangeValue = "";
                Visio.Application objVApp = new Microsoft.Office.Interop.Visio.Application();
                objVApp.Documents.Add(@"C:\Test\CustomTemplate\ServerTemplate.vsd");// add a document
                for (int i = 0; i < objExcelDS.Tables[0].Rows.Count; i++)
                    Visio.Page objVAPage = objVApp.ActiveDocument.Pages.Add();
                    objVApp.Documents.Add(@"C:\Test\CustomShapes\MyShapes.vss");// add a document
                    Visio.Document objVADoc = objVApp.ActiveDocument;// set the working  document to our new document
                    Visio.Masters objVMasters = objVADoc.Masters;
                    Visio.Master objVMaster = objVMasters.get_ItemU("CustomTab");
                    Visio.Shape objTabShape = objVAPage.Drop(objVMaster, 8.24d, 5.54d);
                    objTabShape.Text = objExcelDS.Tables[0].Rows[0]["VLAN"].ToString(); ;
                    //set the Shape Width
                    objTabShape.get_CellsSRC(
                            (short)Microsoft.Office.Interop.Visio.VisSectionIndices.
                            visSectionObject,
                            (short)Microsoft.Office.Interop.Visio.VisRowIndices.
                            visRowXFormIn,
                            (short)Microsoft.Office.Interop.Visio.VisCellIndices.
                            visXFormWidth).ResultIU = 16.0;
                    //set the shape height
                    objTabShape.get_CellsSRC(
                       (short)Microsoft.Office.Interop.Visio.VisSectionIndices.
                       visSectionObject,
                       (short)Microsoft.Office.Interop.Visio.VisRowIndices.
                       visRowXFormIn,
                       (short)Microsoft.Office.Interop.Visio.VisCellIndices.
                       visXFormHeight).ResultIU = 10.6;
                    Visio.Shape objOuterBox = objVAPage.DrawRectangle(dblX1, dblY1, dblX2, dblY2); // Outer Rectange
                    sFilePath = "C:\\Temp\\ServerTemplate"+i.ToString()+".vsd";
                    objVApp.ActiveDocument.SaveAsEx(@sFilePath, (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visSaveAsWS);
    but I need to generate the same visio diagram over the web application using the Response.ContentType. ie.
    context.Response.ContentType = "application/vdx.visio";
    context.Response.AddHeader("content-disposition", String.Format("attachment;filename=\"{0}.vdx\"", fileName));
    Pls give me an idea about it along with any example if possible.
    Thank you.

    Hi,
    This Visio forum is for general questions. Since your issue is related to developing, I advise you to post this issue on Office for Developer forum.
    https://social.msdn.microsoft.com/Forums/office/en-US/home?category=officedev
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners
    who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Best regards,
    Greta Ge
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • When I open iTunes on my new computer using the .itl file, and using the same external drive holding the songs, all of the songs I added to iTunes up to a certain date have broken links, while none of the songs have broken links on the old computer.

    I want to open the  iTunes library on my new laptop with all the playlists and stuff I built on the old computer. I have all my music on an external drive. I have copied the .itl file from the old computer and opened it on the laptop, and it has all the playlists, but all of the songs that were added to iTunes up to a certain date have broken links. What am I doing wrong?

    Moving library files around while leaving the data in the same place usually presents no problems. Moving the data around independently from the library usually breaks things. With Windows machines all you should need to do is make sure that the same drive letter is being used on the new system as with the old. If that is not possible you need to get your library into a portable layout before moving it between systems.
    Typical layout of iTunes folders:
    When the media folder is inside the main iTunes folder as shown above then the library is portable. Typically with a split library the iTunes Music or iTunes Media folder (everything inside the red outline) is moved to a different drive by choosing a new locaton for it and then consolidating.
    To make the library portable again you need to copy the library files and album artwork folder into the parent folder of the media folder so that the nested relationship is recreated. (BTW If your media isn't already inside your designated media folder then you will also need to consolidate the files that are outside of it, before you copy the library files.) You can then use the hold-down-shift-when-starting-iTunes method to open the library file in that parent folder. Once the library has been opened, tested and closed you are most of the way there.
    The iTunes window inherits its title from the folder holding the library files so, unless you created a folder called iTunes to hold the media folder, iTunes may now have an unexpected title when you run it. The parent folder can be renamed as iTunes, and the library opened again. Alternatively, if the parent folder is at the root of the drive, or has other data which you wish to leave in place, you can create a new top level folder called iTunes and move the library files, album artwork and media folders into it before opening and testing the library again.
    If the library doesn't work after any step simply reverse it by undoing a move or rename or opening the previous set iTunes Library.itl file.
    If all has gone well then the library is now portable. Once you've migrated the data to a new system you can copy the library files back to their usual internal location if you find that having them on the external drive affects performance...
    tt2

  • Convert XML to text file and sending the same via Mail receiver adapter

    Dear All,
    I have a requirement like....
    I am getting a XML file as a result of mapping and it needs to be converted to a TEXT file and
    the converted file needs to be sent to a mail address in text format.
    Any body has idea how to achieve this?
    Thanks in advance for your help.
    Regards
    Hari

    >
    HP CReddy wrote:
    > Dear All,
    >
    > I have a requirement like....
    >
    > I am getting a XML file as a result of mapping and it needs to be converted to a TEXT file and
    > the converted file needs to be sent to a mail address in text format.
    >
    > Any body has idea how to achieve this?
    >
    > Thanks in advance for your help.
    >
    > Regards
    > Hari
    use the StructXML2Plain or XML2Plain from the standard MessageTransformBean
    Add the module to you Mail adapter before the mail adapters standard module itself
    Ref: http://help.sap.com/saphelp_nw04/helpdata/en/24/4cad3baabd4737bab64d0201bc0c6c/content.htm

  • Why do I get a NI-488 error massage when writing into a file and at the same time copiyng this file with a backup softwarre like Easy2Sync?

    I have a small LabVIEW program which writes random numbers very fast into a ASCII-file. I want that file to be copied to a new position every 10 min. Therefor I use a backup/synchronisation software which is doing a copy operation every 10 min. It works fine a certian amount of time and after a while I get either an LabVIEW error (LabVIEW: Fiel already open: NI-488 Comand requieres GPIB Controller to be System controller) or an backup-software error (couldn´t open file...whatever). I´m guessing, it has something to do with file-access but I don´t know why?!? If I run the LabVIEW program and I copy and paste the random-number-file with the windows explorer very fast (pressing ctrl+v rapidly) while LabVIEW is still writing into this file, no error appears. Can sombody help me?
    LabVIEW 2011

    Hi Serdj,
    you don't get a GPIB error, the error number has just 2 different explanations...
    Well, you have two programs accessing the same file. One program just wants to make a copy, the other (LabView) is trying to write to the file. When copying a file that is written to you get inconsistent results! That's why one of both programs is complaining an error...
    You can't have write and read access at the same time! (But you can have more than one read access at the same time...)
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • I have no contacts in my outlook contacts file, only in the icloud contacts file and also the same for the outlook calender. I need to synch with a blackberry for both, how do i restore it back?

    I have just set up icloud but now have no outlook contacts or calander, only icloud contacts and calender. I need to synch both to a blackberry so how do i restore the original contacts and calander so I can I can synch normally again?

    Try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable                     
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar
    The missing apps could have been done by setting the Restrictions that can hid those apps. If the backup was made with those retrictions set the the Restrictions are also restored.
    Thus, if you get it to work restore to factory settings/new iPod, not from backup                               
    You can redownload most iTunes purchases by:        
      Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • Way to close/reopen file and keep the same desktop position

    When closing a Text Edit document, I would like to have it reopen in the exact same position on the desktop as when I closed it. Is there any way to make this happen? It seems to remember if the window was resized, but it always puts the document at the bottom of the desktop.

    I have no idea why it isn't working for you. All of Apple's apps use that feature. You might want to launch Disk Utility, select your boot volume, and repair permissions. If that doesn't fix things, create another admin user account, log into it, and see if the problem persists. If so, report back. If not, then the original account's has problems (conflicts, corrupted preferences, or cache file problems). Preferential Treatment can examine the preferences and there's other products that will clean the cache files, but I don't use any, so I have no recommendations.

  • Logging in App Server 7 and App Server 8

    Hi,
    We have an application (servlets/MDBs/EJBs) running in the Sun Application Server 7 that we want to run on the Sun Application Server 8 (J2EE 1.4.2).
    The application has logging facilities with various objects having their own java.util.logging.Logger...
    java.util.logging.Logger m_logger = java.util.logging.Logger.getLogger( "ServletLogger" ) ;
    m_logger.fine( "How do I get this in the App Server log file?" );
    To enable the above logging in App Server 7, I would simply set the global App Server logging level to "FINE" using the admin console. How can I do the same with the App Server 8?
    I've tried using the admin console to set the App Server logging levels to "FINE", but they seem to only effect the App Server itself and not the code it is running. I've also tried adding the following properties in the "Logging Levels" page of the admin console...
    ServletLogger FINE
    ServletLogger.level FINE
    .level FINE
    but they don't seem to make any difference? Any help will be most appreciated!
    Cheers,
    Paul

    Goto the admin console (port 4848 for default domain).
    Click on Topmost Leftmost link -- "Application Server."
    choose the "Logging" Tab.
    Choose the "Log Levels" tab.
    add a new property
             com.company.app.applogger        FINER and in your code, :-
            Logger applogger = Logger.getLogger("com.company.app.applogger "); Now if only I knew how to keep a separate log file for this.

  • Read a csv file and read the fiscal yr in the 4th pos?

    Hello ABAP Experts,
    how to write a code for read a csv file and read the fiscal year in the 4th position.
    any suggestions or code highly appreciated.
    Thanks,
    BWer

    Hi Bwer,
    Declare table itab with the required fields...
    Use GUI UPLOAD to get the contents of the file (say abc.csv) in case if the file is on the presentation server...
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                        = 'c:\abc.csv'
       FILETYPE                        = 'ASC'
        WRITE_FIELD_SEPARATOR           = 'X'
      tables
        data_tab                        = itab
    EXCEPTIONS
       FILE_WRITE_ERROR                = 1
       NO_BATCH                        = 2
       OTHERS                          = 22
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Use OPEN DATASET in case if the file is on the application server..
    After that USE SPLIT command at comma to get the contents of the 4th field...
    Regards,
    Tanveer.
    <b>Please mark helpful answers</b>

  • Uninstall App store and reinstall the same?

    How i can uninstall App. Store and reinstall the same. My current OS is X Lion 10.7.4

    Removing the App Store won't help. Boot into Safe Mode http://support.apple.com/kb/HT1455 and try the download again.

  • Automatic Attach File and Email

    I know can do the following to have page opened as a word
    document. But how can I have, when opened as a word document be
    automatically emailed to email recepients as a word attachment
    without the user going through the file menu to attach and email
    the file?
    <cfheader name="Content-disposition" value="attachment;
    filename=InsertionOrder_#PartnerID#.doc" />
    <cfcontent type="application/msword"
    reset="yes"></cfcontent>

    eziokolo wrote:
    > I know can do the following to have page opened as a
    word document. But how can
    > I have, when opened as a word document be automatically
    emailed to email
    > recepients as a word attachment without the user going
    through the file menu to
    > attach and email the file?
    >
    > <cfheader name="Content-disposition"
    value="attachment;
    > filename=InsertionOrder_#PartnerID#.doc" />
    > <cfcontent type="application/msword"
    reset="yes"></cfcontent>
    >
    >
    very confused... who's emailing to who???
    do you want to email a word doc stored on your server to a
    user when a
    user requests to view the doc, or do you want a user to email
    a word doc
    from their computer to you when they are viewing it???
    if the former, just use cfmail with cfmailpart tags before
    your
    streaming code above to email the doc to anyone you want....
    in the latter case, you have no way of controlling it.
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

Maybe you are looking for

  • Function module to identify users - fowarded work items

    Hi Pls can anyone suggest an appropriate function module to identify the users of the forwarded work items? The onyl input i have is the user name. the scenario is :  UserA had fwd'ed a workitem XYZ to UserB and I need to find programatically all the

  • Auhtorization issue with GRANT_ACTIVATED_ROLE and grantable

    Hi folks, how can I use a procedure like GRANT_ACTIVATED_ROLE but not just giving the user the rights for the role but also "yes" for grantable. I would like to do so. Thanks for any comments or thoughts! Cheers Klaus

  • A possible *bug* in java jcombobox

    Hi all, I think i found a possible bug in java jcombobox .. i am sure some of you must have already experienced it.. supposedly you put a jcombobox in a jpanel returned the panel from a method to a calling method.. and that method adds it to another

  • Best way to back up both and iMac and MacBook Pro

    What's the best/simplist solution for routine backing up my 2012 iMac and 2011 MacBook Pro ? I'd like to be able to sync the Pro with the iMac and then maybe just have to backup the iMac.

  • Help Understanding Event Model

    I am having trouble getting items initialized ontime. I have read the flex 3 development guide and some other docunentation a couple of times and i have read other posts on this forum concerning the creationComplete event. I still don't have a clear