Looking for an applescript to forward mail message in outlook

Hi there...i'm looking for a simple applescript that will forward the selected message to a specific email address.  Thanks!

Hi there,
Did you got the answer already? I'm looking for the same thing
I got someting already but he doesnt send the message.
---Script----
set m   set myComment to "My comment: "
set t    set theName to "test"
set t    set theAddress to "[email protected]"
try
                     tell application "Microsoft Outlook"
                                   set theSelection to selection
                                   set theForwardedMessage to forward (item 1 of theSelection) with opening window
                                   tell theForwardedMessage
                                                                               open theForwardedMessage
                                                                               make new to recipient at theForwardedMessage with properties {email address:{name:"test", address:"[email protected]"}}
                                                                                     send theForwardedMessage
         end tell
                     end tell
e
end try
----End Script-----

Similar Messages

  • I need help exporting Apple Mail messages to Outlook for MAC 2011

    Good morning,
    I need help exporting Apple Mail messages to Outlook for MAC 2011. Please....

    It is possible to do this without external tools, but it is a tremendous faff. See
    http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macoutlook/import-ema il-from-mail-to-outlook-2011/5e858173-e1f4-4adc-99d7-253cc467169d?page=2 for details.
    The easiest way, however, is to use Mail Exporter Pro https://itunes.apple.com/us/app/mail-exporter-pro/id675131616?mt=12 which will convert the email for you from one format to the other, and comes with an excellent manual.
    A third possibility is to connect Apple Mail to an email account via IMAP (this doesn’t have to be your usual account, you can just create a Gmail account for the purpose) . Copy all the messages into it and they will be uploaded. Then connect Outlook 2011 to the same account, via IMAP again, and let the messages download, then copy them to wherever you want to keep them and disconnect from that account. This is slow but preserves the attributes of your email (e.g. read/unead) better than any other method.

  • Simple AppleScript to export Mail messages to FileMaker DB?

    Hello everyone,
    I'm using a product called "Mail Archiver X" to archive messages from Apple Mail into a custom FileMaker database ("eMailViewerX" - this is the target database that comes with Mail Archiver and is required for the process), from where I copy these messages to my main message archive (another FileMaker DB).
    While that process works, it is kind of clumsy (Apple Mail > Mail Archiver X > FileMaker DB #1 > FileMaker DB #2) - and it breaks every time when there is a new version of Apple Mail or OS X until "Mail Archiver X" has been updated by the developer.
    So I'm looking for a more simple solution: an AppleScript that will export all messages from exactly one folder ("To Archive") in Apple Mail (4.5/Snow Leopard or 5.0/Lion) as a simple CSV or .tab file, with the following data per line:
    Message Sender*
    Message Receiver*
    Sent Date
    Sent Time
    Subject
    Body
    * Separation of name and e-mail address would be cool, but I understand this may not (always) be possible.
    The only tricky part may be the conversion of carriage returns in the e-mail messages' body into the special character FileMaker expects in TAB or CSV files. In BBEdit, this is shown as \x{0B} (UTF8: 0B). So there would have to be a Find/Replace for that in the script.
    This does not have to be free (although I wouldn't mind - I'd gladly pay for something that is simple and reliable.
    If someone knows about such a script or is willing to write it, I would really appreciate it.
    TL;DR: I want to export all messages from an Apple Mail folder to a FileMaker-readable CSV file.

    You haven't fully specified the problem:
    It's not clear what to do when there are multiple recipients of an email
    You didn't say precisely what Filemaker fields you wanted in the file, nor what order you wanted them in, nor whether you needed a header row in the text file
    That being said, what you want is a script somewhat like the following (with many things still needing to be adjusted):
    set archiveFolder to "To Archive"
    set tab_delFilePath to "Path:to:tab_del file"
    set tab_delText to {}
    tell application "Mail"
              set messagesToArchive to every message of mailbox archiveFolder
              repeat with thisMessage in messagesToArchive
                        set thisEntry to {}
                        tell thisMessage
                                  set {itsSender, itsRecipients, itsDate, itsSubject, itsText} to {sender, recipients, date received, subject, content}
                                  set {senderName, senderAddress} to {extract name from sender, extract address from sender}
                                  if senderName = senderAddress then set senderName to ""
      -- get date parts
                                  set itsDateString to short date string of itsDate
                                  set itsTimeString to time string of itsDate
      -- there may be multiple recipients; create list
                                  set {recipientName, recipientAddress} to {{}, {}}
                                  repeat with thisRecipient in recipients
                                            tell thisRecipient
                                                      set recipientName's end to name
                                                      set recipientAddress's end to address
                                            end tell
                                  end repeat
      -- convert carriage returns to linefeeds in message body; unicode 0B is ascii 11, which is linfeed
                                  set itText to my tid(my tid(itsText, return), linefeed)
                                  set thisEntry to {senderName, senderAddress, itsDateString, itsTimeString, itsSubject, my tid(recipientName, ","), my tid(recipientAddress, ","), itsText}
                        end tell
                        set end of tab_delText to my tid(thisEntry, tab)
              end repeat
    end tell
    set tab_delText to tid(tab_delText, return)
    set fp to open for access tab_delFilePath with write permission
    write tab_delText to fp
    close access fp
    on tid(input, delim)
      -- a subroutine for handling text item delimiters
              set {oldTID, my text item delimiters} to {my text item delimiters, delim}
              if class of input is list then
                        set output to input as text
              else
                        set output to text items of input
              end if
              set my text item delimiters to oldTID
              return output
    end tid
    it's a place to start, anyway. 
    If you want to dangle money in front of my eyes, send me an email and I'll get it set up properly on your system (including automating the process and importing the data directly into your filemaker database).

  • Microsoft Exchange 2013 eDiscovery - specific search query: looking for specific hyperlinks within e-mails content/body

    Dear all:
    I am currently using the MS Exchange 2013 eDiscovery feature with the objective to identify which of my users have received emails containing specific hyperlinks (e.g. http://website1/webroot/file.zip, http://website2/webroot/file.zip, etc.) from an unknown
    sender.
    To this end, I have been creating an eDiscovery on-hold case looking for a specific search criteria in all mailboxes.
    As the search criteria, I have tried many options but was unable to obtain satisfying results: I know I am missing some e-mails from this specific search (I checked manually). I have notably tried the following search queries (with and without the body:
    search operator, with and without double quotes, etc.)
    body:http://website1/* OR body:http://website2/*
    body:"http://website1/*" OR body:"http://website2/*"
    body:"website1*" OR body:"website2*"
    body:"*website1*" OR body:"*website2*"
    When replaying these queries on my local Outlook client, everything works fine and I get results as expected.
    However, when going through the ECP eDiscovery feature, I am missing some results.
    Therefore, I am looking for any advice on what Exchange eDiscovery KQL query I should use to identify all emails containing, in their message body, a list of specific hyperlinks/URLs.
    Many thanks in advance for your help.
    S.

    Alas I do not know the answer to resolution via ECP and like you I have found it to be a bit maddening to use ECP for discovery tests Ive done when comparing results with our DigiScope product.  I know we can accomplish what your looking to do via Regular
    Expression but again that's with a 3rd party tool. 
    One thought is I suppose it could be an indexing issue with the DB, so perhaps rebuilding the index would help?
    If you do get it working I would love to know the resolution since many of my tests with ECP have left me yelling at the screen.  When its works its cool when not well...
    Search, Recover, & Extract Mailboxes, Folders, & Email Items from Offline Exchange Mailbox and Public Folder EDB's and Live Exchange Servers or Import/Migrate direct from Offline EDB to Any Production Exchange Server, even cross version i.e. 2003
    --> 2007 --> 2010 --> 2013 with Lucid8's
    DigiScope

  • OSB - Looking for howto's on multi machine message delivery.

    Hi.
    I am very new to Oracle Service Bus.
    I want to setup two machines, A and B.
    I want A to take service calls from BPEL, deliver them to B and have B deliver them to their final service, returning the reply back to A and finally BPEL.
    The communications between A and B can be unreliable, ie, B can wander off into the ether, for long periods, days, weeks, before returning.
    There is no expectation that A will ever 'disappear' and will always be there to talk to BPEL.
    Is there a howto or something that I can use to setup something like this?
    Am I even on the right track?
    Any assistance would be greatly appreciated.
    ...Lyall

    Thankyou, just the sort of thing I am looking for, advice on telling me what I am doing wrong.
    So, you are saying that I don't have OSB on Machine A but only have it on Machine B, listening on the end of a JMSQ.
    However, my end game scenario involves a central machine A with many satellite machines, B, C, D, etc.
    As I am a complete noob at OSB/WebLogic, I figure, for administrative purposes, I would have an OSB on A which was the administrator of the domain, which extends out to B, C, D, etc.
    So, in that case, OSB on A's sole role would be admin server whilst on B, C, D, etc, would be the actual processing. This would alleviate me having one admin console for each machine.
    Does this sound logical?
    To the above end, I am playing with OSB 10gR3 and I can create a domain using the configuration wizard and boot the admin server.
    I seem to have endless problems trying to start up a managed server for the domain. I always get a message similar to the following
    "Authentication denied: Boot identity not valid; The user name and/or password from the boot identity file (boot.properties) is not valid. The boot identity may have been changed since the boot identity file was created. Please edit and update the boot identity file with the proper values of username and password. The first time the updated boot identity file is used to start the server, these new values are encrypted."
    I have tried re-creating the boot.properties file, as per other posts on in these forums, to no avail.
    I have tried a cold install of OSB, run the config wizard, add a machine and managed server within the config wizard and the thing still wont boot.
    I have tried creating the server and machine using the admin console web pages, no success.
    I just can't seem to get a managed server to boot, out of the box!
    Once again, thanks for your help.
    ...Lyall

  • Using AppleScript to save Mail messages?

    I'm a bit of an Applescript newbie, but I'm trying to attach an AppleScript to a rule in Mail to automatically save the raw text source of certain mail messages to a folder, where I can further process them.
    Here's what I have so far. It compiles, is saved in my Mail scripts folder, and It is attached to the rule in Mail, but I get no evidence that it runs (no output file(s), no dialogs, no messages in the console or system logs).
    using terms from application "Mail"
    on perform mail action with messages theMessages
    tell application "Mail"
    repeat with eachMessage in theMessages
    save the source of eachMessage in "hd/Users/me/Desktop/slash.txt" as text
    save the source of eachMessage in "hd:Users:me:Desktop:colon.txt" as text
    end repeat
    end tell
    end perform mail action with messages
    end using terms from
    Any suggestions?
    G4 "Gigabit" Dual-500   Mac OS X (10.4.8)   1.5GB RAM, 1TB internal, SCSI, 802.11g, USB2.0

    Hi 0g,
    Automator is pretty simple compared to AppleScript. I use Automator, but I certainly could not help you with AppleScript! So I'm not sure you will find your answer here... You might, but why don't you increase your chances by posting in the AppleScript Forum here: http://discussions.apple.com/forum.jspa?forumID=724
    (You probably didn't see that one as it is hidden in the Mac OS X Technologies Category!)
    Good luck!
    Guylaine
    Mac mini Intel Core Duo 1.66 GHz 512MB DDR2 SDRAM Mac OS X (10.4.8) G4 Digital Audio Mac OS 9.2.2, iPod nano 1GB, iPod nano 4GB

  • IPhone4 when replying or forwarding mail messages i get a message that says Cannot Send Mail address rejected by the server because it does not allow relaying

    When forwarding mail this is what i get
    Cannot Send Mail
    A copy has been placed in your Outbox. The recipent _________________(email address) was rejected by the server because it does not allow relaying.
    Never had this problem before so not sure whats going on. Appreciate any help out there.

    Sounds like there is something wrong with your SMTP server. Try going into Settings>Mail, Contacts, Calendars>select the email account in question, go to the Outgoing server (SMTP) and check the settings. It may be you do not have a username and password in one of the areas. The phone may say optional in a couple, but it is usually mandatory. You can also try a reset on the device, hold the sleep/wake and home buttons together until you see the Apple logo and then release. If neither of these work, then you will need to delete the account, then delete the SMTP server, then add the account back, ensuring you use your username and password everywhere, even when it says optional.

  • IPhone won't reply or forward mail messages

    My phone works perfectly, but does not forward or reply to messages. Is something wrong with the setup?
    This is a little frustrating as the phone is often all I have to use for mails. Any helpers??

    Allan, that is correct.  Message on the screen reads:
    "Cannot Send Mail
    A copy has been placed in your Outbox.  The recipient, "[email protected]" was rejected by the server because it does not allow relaying."
    Can you help?

  • Looking for some help with an error message when exporting master file. I'm stuck and would even pay to get this sorted out!

    Hey guys, I'm really in a bind here and need some urgent help tonite. I would even be willing to pay for some actual help and not some vague information that i may not be able to understand if we could do something via skype or some other way that would be much quicker than a message board. Of course I have to have the project done by tomorow . so I'm new to fcpx, but have succesfully exported 2 other projects. I've also ran into this predicament before (error message not allowing me complete export) and have been able to solve that by converting the files i imported off my camera (canon g20) to a different file type (prores).
    so where I'm at now: i have a 13 min short, all shot on my canon g20, imported and converted to prores422 with the brorsoft video converter with all the shots in a single event in fcpx. i'm using fcpx version 10.0.08. I have one main video track in my timeline that is completely full of very fast edits. (all quick 2-5 second clips, sped up shots in 2x, 4x, or 8x, tons of transitions, titles, and a little fx. theres 2 audio tracks, one is narration/speech and the other is an ongoing music track that constantly ducks everytime the subject speaks (tons of ducks/edits). Have you seen mtv cribs? Well i filmed an EXACT replica. So If you've seen one of those episodes, its literally the same exact same thing. I have all of my work completed, everything has been fully rendered, and i have it exactly as I want it.
    I'm including all this information in case it may help. my successful projects ive exported in the past were rather simple, and this one is very complex and full of edits. here is what it looks like in the timeline:
    Ive tried exporting the master file using almost all the different ways with no luck. My primary objective is to get it on youtube by any means by tommorow for a showing to a potential buyer (long story) and so I've been told using the h.264 is the best format for that. This, along with the other methods give me the same error message:
    It think it gives this error message when i reach 24% everytime during export.
    So first of all, what is that error message? Do i need to be concerned about the specifics of it, or is there something major that I'm missing? Like i said, i dont care how, but I need to get this video up on youtube tonite for an important viewing tomorrow. Conceptually, I think if i can figure this one out I shouldnt have any more trouble in the future doing something so basic, yet critical, such as exporting my 40+ hours of work for someone to see.
    anyway, I apologize in advance for my lack of knowledge with this software, and for my extremely long winded question which will probably have the opposite effect for me as most wont want to take the time to read all this, BUT i figured if i was as thorough as possible it might help actually getting a concrete answer, instead of a "read the manual, exporting is on page 37." or "use the share button on the right of the timeline then just click export master file and it will work everytime."
    Cheers everybody, and thank you. Like i said if someone is up, and willing to talk via skype, phone, messanger or any other method that works for you I would be totally down and will compensate you generously for your time. thanks again.
    Taphabit

    boom! that advice was correct and worked. i was able to export the full project as a quicktime movie and it can be uploaded to youtube.
    NOTE, theres is definately quite a few noticeable audio glitches/lags/pops that werent there before doing this. I believe, and will test to make sure, that having a project such as this one needs to render before exporting. I'm not sure if the advice requires the project to be unrendered before exporting for a specific reason, because if it will export fine after rendering the project that's the way to go. like i said the edited version i have in my timeline plays back perfectly but this exported version has quite a few noticeable audio glitches (a few video glitches too). I'm going to retry doing the first few steps of your advice, but then at the end render, then export and compare the results...
    OK, so this leads to a big question, Is this something that is standard for everyone when trying to export? If its not, what causes this error?
    is there any way of preemptively avoiding it in future projects?
    thanks again, and hopefully this information will help others as exporting seem to be one of the biggest problems in fcpx. any word on a new patch or firmware update?

  • Looking for an example of using a Message Driven Bean.  Anyone?

    I see that iAS 6.5 does NOT come with the newest PetStore which includes a Message Bean. I have build and deployed a MDB and I see it in the iAS admin tool but it never is automatically started (like the manual says it should)and therefore is never listening for a JMS message. The same bean (different deployment descriptor of course for iAS-ejb-jar etc) works on JBoss just fine.

    Hi Mike
    You could save the workflow as an application and then write a simple script that tells the application to launch multiple times.
    But you'll find it many times faster to do it the other way round, and run a looping AppleScript from a single Automator action.
    (Your iPod must be set up in disk mode.)
    set ipod_name to "Name of your iPod goes here" -- edit this line and put the name of your pod in inverted commas
    tell application "Finder" to set ipod_ready to exists disk ipod_name
    if ipod_ready then
    set text_folder to (choose folder with prompt "Choose the folder containing notes for your iPod.")
    set file_names to list folder text_folder without invisibles
    repeat with file_name in file_names
    set file_path to text_folder & file_name as string
    if file type of (info for file_path) is "TEXT" then
    tell application "Finder"
    move file file_path to folder "Notes" of disk ipod_name
    end tell
    end if
    else -- ipod not mounted
    display dialog "Mount your iPod first!" buttons {"OK"} default button 1 with icon caution giving up after 5
    end if
    Copy and paste this into a Run AppleScript action, edit to supply the name of your own ipod, and see how it goes.
    Hope this helps,
    H

  • Cannot reply to or forward mail message

    For the last three days I cannot delete/ reply/ forward or move messages in my Yahoo account once I open them. This only happens when i access the account on my macbook (safari or mozilla firefox) - the account works fine on my dell desktop so the problem is not with Yahoo. Any suggestions?
    Macbook   Mac OS X (10.4.7)  

    After opening an email message in Yahoo, when I click on the "delete/reply/forward/move" buttons at the top of the message, nothing happens - no drop down menu for inline text/attachment, etc. Normally, I just need one click to execute any of these functions. I can compose and send new messages but I cannot reply to or forward an email that I have received.

  • Looking for Mac software that manages text messages on Nokia 6300

    iSync only manages contacts and calendar. How do I send and receive text messages on my Mac? I would greatly appreciate it if anyone in the forum can give a hint. I have been using Nokia PC Suite in VMWare Fusion and it was very slow and annoying. Thanks in advance.

    1) it can't read text messages from my Nokia phone;
    If you look at the compatibility list you'll see that its because your phone does not provide a public way to read SMS over Bluetooth. So, nothing that can be done about that.
    2) I am still trying to find out how I can send a message to many recipients at the same time.
    Just enter more than one number into the TO field of a message. You can also send to Address Book groups.

  • BLANK MAIL MESSAGES USING OUTLOOK

    Hi - I apologise for throwing this one in again - but I need to get an answer and haven't been able to find anything yet.
    I am using a MacBook Pro with OS x Ver 10.6.8.  For mail within our company we use MS Outlook.  verything was fine up until a few weks ago.  Messages appeared at Yahoo, came through on the Blackberry and came onto the MacBook in Outlook - all was well.
    Something then happened - messages still appear in Yahoo and on trhe Blavkberry - the mesage appears in Outlook but when th emessage is opened there is no text within it!!  The message sender details and the subject are all there - but no text below it.  If I send a message or reply to (a blank message) my response text appears OK.
    Anyone got any ideas please?
    Tony Duckowrth

    Am afraid that none of that helped.  Have tried to get updates for software - but if and when you try you get a response that say's no updates available - what can you do?
    This went on for about three months, tried many forums and groups, tried Apple direct with no response at all.  Tried Microsoft to see if a problem with Outlook - a good forum but no solution.  No response at all from anyone at Yahoo.
    The only thing I could do was to create a completely new profile on the Mac, recreate the mail profile in the new profile and all the mail at Yahoo came through fine.  Then had to copy across all the files etc - from the old profile to the new.  A complete bore.
    You would think that the likes of Apple and Microsoft - who must know that these 'help forums' exist - might monotor what s going on and maybe tried to fix some of these things that just happen - for no good reason.

  • Can you use a text field for email sender with E-mail button

    basically i would like to use input information from the user when someone sends an email instead of the default which is to look for a third party e-mail program like outlook. I want to bypass that and possibly use a text field that has the user input their email. some people don't use outlook so it would be nice to bypass that somehow. Is there a way to send email without the whole outlook thing, like not needing a "sender" and instead require them to input email address. I just want to receive the pdf. I am using LIVECYCLE by the way.

    You must enable POP forwarding for the account preferences via webmail access for the account.
    http://mail.google.com/support/bin/answer.py?answer=13273
    http://www.macosxhints.com/article.php?story=20041110192454841
    The instructions for enabling POP forwarding and creating the account as a POP account with an email client such as the Mail.app are available at Gmail's website.

  • Looking for function that send mail

    I AM LOOKING FOR A FUNCTION THAT SEND MAIL
    <b><b>WITH ATTACMENT ONLY</b> ANYONE KNOW????
    THANKS.

    REPORT ZMAILOUTPUT
        MESSAGE-ID ZZ.
    *  CONSTANTS                                                           *
    CONSTANTS : C_X(1)      TYPE C VALUE 'X',      " For constant value
                C_OTF(3)    TYPE C VALUE 'OTF',    " For format
                C_U(1)      TYPE C VALUE 'U'.      " Mail Option
    *  VARIABLES                                                           *
    DATA : V_RQIDENT  TYPE TSP01-RQIDENT,  " For Spool Number
           V_RQCLIENT TYPE TSP01-RQCLIENT, " For Client
           V_RQO1NAME TYPE TSP01-RQO1NAME, " For Object name
           V_SPOOL    TYPE TSP01-RQIDENT,  " For Spool Number
           V_SPOOL1   TYPE TSP01-RQIDENT.  " For Spool Number
    *  FLAGS                                                               *
    DATA : F_SPOOL TYPE C.
    *   INTERNAL TABLES                                                    *
    * Internal table for sending mails
    DATA: IT_PDF          LIKE TLINE      OCCURS 10 WITH HEADER LINE,
          IT_XI_PDF       LIKE TLINE      OCCURS 0  WITH HEADER LINE,
          IT_HTML         LIKE SOLISTI1   OCCURS 0  WITH HEADER LINE,
          IT_XI_TEMP      LIKE BAPIQCMIME OCCURS 0  WITH HEADER LINE,
          IT_XI_MIME(255) TYPE C          OCCURS 0  WITH HEADER LINE.
    * For sending mail
    DATA: IT_OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    * Internal table for Single List with Column Length 255
    DATA : IT_OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    * Internal table for Single List with Column Length 255
    DATA : IT_OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    * Internal table for Structure of the API Recipient List
    DATA : IT_RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    * Structure of the API Recipient List
    DATA: X_DOC_CHNG LIKE SODOCCHGI1.
    * Internal table for storing the variants
    DATA : BEGIN OF IT_VARIANT1 OCCURS 0,
            VARIANT LIKE VARID-VARIANT,
           END   OF IT_VARIANT1.
    * Internal table to store variants for the programs
    DATA: IT_VARIANT2 LIKE IT_VARIANT1 OCCURS 0 WITH HEADER LINE.
    * Internal table for storing the selected values
    DATA IT_RETURN TYPE DDSHRETVAL OCCURS 0 WITH HEADER LINE.
    * Internal table for storing the mail-ids
    DATA : BEGIN OF IT_MAILID OCCURS 0,
            KOKRS LIKE CSKS-KOKRS,
            KOSTL LIKE CSKS-KOSTL,
            DATBI LIKE CSKS-DATBI,
            TELX1 LIKE CSKS-TELX1,
           END   OF IT_MAILID.
    * Internal table for storing the mail-ids
    DATA : IT_MAILID1 LIKE IT_MAILID OCCURS 0 WITH HEADER LINE.
    *   SELECTION SCREEN                                                   *
    DATA : V_CHAR TYPE CHAR50.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_EMAIL FOR V_CHAR  NO INTERVALS
                    LOWER CASE
                    NO-DISPLAY.
    SELECT-OPTIONS: S_EMAIL1 FOR V_CHAR  NO INTERVALS
                    LOWER CASE
                    NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-028.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS : P_C1 AS CHECKBOX.
    SELECTION-SCREEN COMMENT 3(66) TEXT-026 FOR FIELD P_C1.
    SELECTION-SCREEN END OF LINE.
    PARAMETERS : P_SET LIKE TSP1D-PAPART MATCHCODE OBJECT ZH_TSP1D.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS : P_VARA1 TYPE RS38M-SELSET.
    SELECTION-SCREEN END OF BLOCK A1.
    SELECTION-SCREEN BEGIN OF BLOCK A2 WITH FRAME TITLE TEXT-029.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS : P_C2 AS CHECKBOX.
    SELECTION-SCREEN COMMENT 3(56) TEXT-027 FOR FIELD P_C1.
    SELECTION-SCREEN END OF LINE.
    PARAMETERS : P_SET1 LIKE TSP1D-PAPART MATCHCODE OBJECT ZH_TSP1D.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS : P_VARA2 TYPE RS38M-SELSET.
    SELECTION-SCREEN END OF BLOCK A2.
    * AT SELECTION SCREEN ON VALUE REQUEST
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARA1.
    * For fetching the variants available for the program
      PERFORM FETCH_VARIANTS.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARA2.
    * For fetching the variants available for the program
      PERFORM FETCH_VARIANTS1.
    * AT SELECTION SCREEN
    AT SELECTION-SCREEN.
    * For Validation
      PERFORM VALIDATION.
    *  START OF SELECTION                                                  *
    START-OF-SELECTION.
    * To get the output data and mail
      PERFORM FETCH_DATA.
    *  END OF SELECTION                                                    *
    END-OF-SELECTION.
      IF F_SPOOL = C_X.
        MESSAGE E000 WITH 'Spool Not Generated'(060).
      ENDIF.
    *&      Form  fetch_data
    *       To get the output data and mail
    FORM FETCH_DATA .
    * To send the output to spool
      PERFORM GENERATE_SPOOL.
    ENDFORM.                    " fetch_data
    *&      Form  generate_spool
    *       To send the output to spool
    FORM GENERATE_SPOOL .
      DATA: L_PARAMS LIKE PRI_PARAMS,
            L_DAYS(1)  TYPE N VALUE 2,
            L_COUNT(3) TYPE N VALUE 1,
            L_VALID    TYPE C,
            L_VALID1   TYPE C,
            L_PARAMS1  LIKE PRI_PARAMS.
      DATA: L_DEVICE TYPE USR01-SPLD.
    *Get the printer name for the user
      SELECT SINGLE SPLD INTO L_DEVICE FROM USR01 WHERE BNAME = SY-UNAME.
      IF L_DEVICE IS INITIAL.
        L_DEVICE = 'LOCL'.
      ENDIF.
    * For report-1
      IF P_C1 = 'X'.
    * Setting the print parameters
        CALL FUNCTION 'GET_PRINT_PARAMETERS'
          EXPORTING
            DESTINATION    = L_DEVICE
            COPIES         = L_COUNT
            LIST_NAME      = SY-UNAME
            LIST_TEXT      = 'SUBMIT ... TO SAP-SPOOL'(008)
            RELEASE        = C_X
            NEW_LIST_ID    = C_X
            EXPIRATION     = L_DAYS
    *        LINE_SIZE      = 255
    *        LINE_COUNT     = 65
            LAYOUT         = p_set
            SAP_COVER_PAGE = SPACE
            COVER_PAGE     = SPACE
            RECEIVER       = 'SAP*'(010)
            DEPARTMENT     = 'System'(011)
            NO_DIALOG      = C_X
          IMPORTING
            OUT_PARAMETERS = L_PARAMS
            VALID          = L_VALID.
        IF L_VALID <> SPACE.
          CLEAR V_SPOOL.
    * Fetch the spool number b4 submit
          PERFORM FETCH_RECENT_SPOOL USING V_SPOOL.
    * Submitting the program to spool
          SUBMIT RKAEP000 TO SAP-SPOOL
            USING SELECTION-SET P_VARA1
            SPOOL PARAMETERS L_PARAMS
            WITHOUT SPOOL DYNPRO
            AND RETURN.
          CLEAR V_SPOOL1.
    * Fetch the spool number after submit
          PERFORM FETCH_RECENT_SPOOL USING V_SPOOL1.
          IF V_SPOOL = V_SPOOL1.
            F_SPOOL = C_X.
            IF P_C2 IS INITIAL.
              STOP.
            ENDIF.
          ELSE.
    * Checking the format ( ABAP/OTF)
            PERFORM FORMAT_CHECK TABLES S_EMAIL.
          ENDIF.
        ELSE.
          MESSAGE E000 WITH 'Problem in print settings'(003).
          STOP.
        ENDIF.
      ENDIF.
    * For Report-2
      IF P_C2 = 'X'.
    * Setting the print parameters
        CALL FUNCTION 'GET_PRINT_PARAMETERS'
          EXPORTING
            DESTINATION    = L_DEVICE
            COPIES         = L_COUNT
            LIST_NAME      = SY-UNAME
            LIST_TEXT      = 'SUBMIT ... TO SAP-SPOOL'(008)
            RELEASE        = C_X
            NEW_LIST_ID    = C_X
            EXPIRATION     = L_DAYS
    *        LINE_SIZE      = 200
    *        LINE_COUNT     = 65
            LAYOUT         = p_set1
            SAP_COVER_PAGE = SPACE
            COVER_PAGE     = SPACE
            RECEIVER       = 'SAP*'(010)
            DEPARTMENT     = 'System'(011)
            NO_DIALOG      = C_X
          IMPORTING
            OUT_PARAMETERS = L_PARAMS1
            VALID          = L_VALID1.
        IF L_VALID1 <> SPACE.
          CLEAR V_SPOOL.
    * Fetch the spool number b4 submit
          PERFORM FETCH_RECENT_SPOOL USING V_SPOOL.
    * Submitting the program to spool
          SUBMIT GP3DIEHXY88SNFJ0391V7KF9EK7050 TO SAP-SPOOL
            USING SELECTION-SET P_VARA2
            SPOOL PARAMETERS L_PARAMS1
            WITHOUT SPOOL DYNPRO
            AND RETURN.
          CLEAR V_SPOOL1.
    * Fetch the spool number after submit
          PERFORM FETCH_RECENT_SPOOL USING V_SPOOL1.
          IF V_SPOOL = V_SPOOL1.
            MESSAGE E000 WITH 'Spool Not Generated'(060).
            STOP.
          ENDIF.
    * Checking the format ( ABAP/OTF)
          PERFORM FORMAT_CHECK TABLES S_EMAIL1.
        ELSE.
          MESSAGE E000 WITH 'Problem in print settings'(003).
          STOP.
        ENDIF.
      ENDIF.
    ENDFORM.                    " generate_spool
    *&      Form  fetch_recent_spool
    *       Fetch the recent spool number generated
    FORM FETCH_RECENT_SPOOL USING P_V_SPOOL TYPE TSP01-RQIDENT .
      DATA:  L_USER LIKE TSP01-RQ2NAME.
      CLEAR : V_RQIDENT,
              V_RQCLIENT,
              V_RQO1NAME.
      L_USER = SY-UNAME.
    * Get latest Spool No
      SELECT SINGLE RQIDENT
                    RQCLIENT
                    RQO1NAME
             INTO (V_RQIDENT , V_RQCLIENT , V_RQO1NAME)
        FROM TSP01
       WHERE RQCRETIME =   ( SELECT MAX( RQCRETIME )
                                    FROM TSP01
                                   WHERE RQ2NAME EQ L_USER
                                     AND RQFINAL EQ '.' ).
      IF SY-SUBRC = 0 .
        P_V_SPOOL = V_RQIDENT.
      ENDIF.
    ENDFORM.                    " fetch_recent_spool
    *&      Form  format_check
    *       Checking the format ( ABAP/OTF)
    FORM FORMAT_CHECK TABLES P_S_EMAIL STRUCTURE S_EMAIL.
      DATA : L_OBJTYPE    LIKE RSTSTYPE-TYPE.
      CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
        EXPORTING
          AUTHORITY     = 'SP01'(019)
          CLIENT        = V_RQCLIENT
          NAME          = V_RQO1NAME
          PART          = 1
        IMPORTING
          OBJTYPE       = L_OBJTYPE
        EXCEPTIONS
          FB_ERROR      = 1
          FB_RSTS_OTHER = 2
          NO_OBJECT     = 3
          NO_PERMISSION = 4.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      IF L_OBJTYPE(3) = C_OTF.
    * Convert OTF Spool to PDF
        PERFORM CONVERT_OTF2PDF TABLES P_S_EMAIL.
      ELSE.
    * Convert ABAP Spool to PDF
        PERFORM CONVERT_ABAP2PDF TABLES P_S_EMAIL.
      ENDIF.
    ENDFORM.                    " format_check
    *&      Form  convert_otf2pdf
    *       Convert OTF Spool to PDF
    FORM CONVERT_OTF2PDF TABLES P_P_S_EMAIL STRUCTURE S_EMAIL .
      CLEAR   IT_PDF.
      REFRESH IT_PDF.
      DATA : L_BYTECOUNT  TYPE I.
    * Fn. to get the PDF format
      CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
        EXPORTING
          SRC_SPOOLID              = V_RQIDENT
          NO_DIALOG                = 'X'
        IMPORTING
          PDF_BYTECOUNT            = L_BYTECOUNT
        TABLES
          PDF                      = IT_PDF
        EXCEPTIONS
          ERR_NO_OTF_SPOOLJOB      = 1
          ERR_NO_SPOOLJOB          = 2
          ERR_NO_PERMISSION        = 3
          ERR_CONV_NOT_POSSIBLE    = 4
          ERR_BAD_DSTDEVICE        = 5
          USER_CANCELLED           = 6
          ERR_SPOOLERROR           = 7
          ERR_TEMSEERROR           = 8
          ERR_BTCJOB_OPEN_FAILED   = 9
          ERR_BTCJOB_SUBMIT_FAILED = 10
          ERR_BTCJOB_CLOSE_FAILED  = 11.
      IF SY-SUBRC = 0.
    * For page format
        PERFORM PAGE_FORMAT TABLES P_P_S_EMAIL.
      ELSE.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " convert_otf2pdf
    *&      Form  convert_abap2pdf
    *        Convert ABAP Spool to PDF
    FORM CONVERT_ABAP2PDF TABLES P_P_S_EMAIL STRUCTURE S_EMAIL.
      CLEAR   IT_PDF.
      REFRESH IT_PDF.
      DATA : L_BYTECOUNT  TYPE I.
    * Fn. to convert to PDF format
      CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          SRC_SPOOLID              = V_RQIDENT
          NO_DIALOG                = 'X'
        IMPORTING
          PDF_BYTECOUNT            = L_BYTECOUNT
        TABLES
          PDF                      = IT_PDF
        EXCEPTIONS
          ERR_NO_ABAP_SPOOLJOB     = 1
          ERR_NO_SPOOLJOB          = 2
          ERR_NO_PERMISSION        = 3
          ERR_CONV_NOT_POSSIBLE    = 4
          ERR_BAD_DESTDEVICE       = 5
          USER_CANCELLED           = 6
          ERR_SPOOLERROR           = 7
          ERR_TEMSEERROR           = 8
          ERR_BTCJOB_OPEN_FAILED   = 9
          ERR_BTCJOB_SUBMIT_FAILED = 10
          ERR_BTCJOB_CLOSE_FAILED  = 11.
      IF SY-SUBRC = 0.
    * For page formatting
        PERFORM PAGE_FORMAT TABLES P_P_S_EMAIL.
      ELSE.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " convert_abap2pdf
    *&      Form  send_mail
    *       For sending mail
    FORM SEND_MAIL TABLES MAIL STRUCTURE S_EMAIL .
    * Structures and internal tables for the send data
      DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2  WITH HEADER LINE,
            OBJHEAD LIKE SOLISTI1   OCCURS 1  WITH HEADER LINE,
            OBJBIN  LIKE SOLISTI1   OCCURS 0  WITH HEADER LINE,
            OBJTXT  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE,
            RECLIST LIKE SOMLRECI1  OCCURS 5  WITH HEADER LINE.
      DATA: DOC_CHNG LIKE SODOCCHGI1,
            TAB_LINES LIKE SY-TABIX.
    * Data for the status output after sending
      DATA: SENT_TO_ALL LIKE SONV-FLAG.
      CLEAR: IT_RECLIST, IT_RECLIST[],
             IT_OBJTXT , IT_OBJTXT[],
             IT_OBJPACK, IT_OBJPACK[],
             IT_OBJBIN , IT_OBJBIN[],X_DOC_CHNG.
      LOOP AT IT_HTML.
        OBJBIN-LINE = IT_HTML-LINE.
        APPEND OBJBIN.
        CLEAR OBJBIN.
      ENDLOOP.
    * Create the document which is to be sent
      DOC_CHNG-OBJ_NAME  = 'List'(012).
      DOC_CHNG-OBJ_DESCR = 'Mail'(013).
    * Heading
      OBJTXT-LINE = 'Mail with pdf attachment'(014).
      APPEND OBJTXT.
      CLEAR OBJTXT.
    * Size
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ TABLE OBJTXT INDEX TAB_LINES.
      DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    * Fill the fields of the packing_list for the main document:
      CLEAR OBJPACK-TRANSF_BIN.
    * The document needs no header (head_num = 0)
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
    * Body
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'(015).
      APPEND OBJPACK.
    * Create the attachment (the list itself)
      DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    * Fill the fields of the packing_list for the attachment:
      OBJPACK-TRANSF_BIN = 'X'.
    * Header
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
    * Body
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'PDF'(016).
      OBJPACK-OBJ_NAME = 'Attachment'(017).
      OBJPACK-OBJ_DESCR = 'Mail with pdf Attachment'(018).
      OBJPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND OBJPACK.
    *-Fill the mail recipient list
      LOOP AT MAIL.
        RECLIST-RECEIVER = MAIL-LOW.
        RECLIST-REC_TYPE = C_U.
        APPEND RECLIST.
        CLEAR: RECLIST,
               MAIL.
      ENDLOOP.
    *-Send the document by calling the SAPoffice API1 module for sending
    *-documents with attachments
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA              = DOC_CHNG
          PUT_IN_OUTBOX              = C_X
          COMMIT_WORK                = C_X
        IMPORTING
          SENT_TO_ALL                = SENT_TO_ALL
        TABLES
          PACKING_LIST               = OBJPACK
          OBJECT_HEADER              = OBJHEAD
          CONTENTS_BIN               = OBJBIN
          CONTENTS_TXT               = OBJTXT
          RECEIVERS                  = RECLIST
        EXCEPTIONS
          TOO_MANY_RECEIVERS         = 1
          DOCUMENT_NOT_SENT          = 2
          OPERATION_NO_AUTHORIZATION = 4
          OTHERS                     = 99.
      CASE SY-SUBRC .
        WHEN 0.
          MESSAGE I000 WITH 'Mail has been sent successfully'(006).
        WHEN OTHERS.
          MESSAGE E000 WITH 'Problem in sending the mail'(023).
      ENDCASE.
    ENDFORM.                    " send_mail
    *&      Form  page_format
    *        For page foramtting
    FORM PAGE_FORMAT TABLES EMAIL STRUCTURE S_EMAIL .
      DATA : L_LINES       TYPE I,
             L_TEMP(500)   TYPE C,
             L_OFFSET      TYPE P,
             L_LINESLEN(2) TYPE P,
             L_MIMELEN(2)  TYPE P,
             L_TABIX       LIKE SY-TABIX.
      CLEAR : IT_XI_PDF,
              IT_XI_TEMP.
      REFRESH : IT_XI_PDF,
                IT_XI_TEMP.
      IT_XI_PDF[] = IT_PDF[].
    * Reformat the line to 255 characters wide (--code from SAP--)
      CLEAR: L_TEMP, L_OFFSET, IT_XI_TEMP.
      DESCRIBE TABLE IT_XI_PDF   LINES  L_LINES.
      DESCRIBE FIELD IT_XI_PDF   LENGTH L_LINESLEN IN CHARACTER MODE.
      DESCRIBE FIELD IT_XI_TEMP  LENGTH L_MIMELEN IN CHARACTER MODE.
      LOOP AT IT_XI_PDF.
        L_TABIX = SY-TABIX.
        MOVE IT_XI_PDF TO L_TEMP+L_OFFSET.
        IF L_TABIX = L_LINES.
          L_LINESLEN = STRLEN( IT_XI_PDF ).
        ENDIF.
        L_OFFSET = L_OFFSET + L_LINESLEN.
        IF L_OFFSET GE L_MIMELEN.
          CLEAR IT_XI_TEMP.
          IT_XI_TEMP = L_TEMP(L_MIMELEN).
          APPEND IT_XI_TEMP.
          SHIFT L_TEMP BY L_MIMELEN PLACES.
          L_OFFSET = L_OFFSET - L_MIMELEN.
        ENDIF.
        IF L_TABIX = L_LINES.
          IF L_OFFSET GT 0.
            CLEAR IT_XI_TEMP.
            IT_XI_TEMP = L_TEMP(L_OFFSET).
            APPEND IT_XI_TEMP.
          ENDIF.
        ENDIF.
      ENDLOOP.
      CLEAR : IT_XI_MIME,
              IT_XI_MIME[].
      LOOP AT IT_XI_TEMP.
        IT_XI_MIME(255) = IT_XI_TEMP-LINE.
        APPEND IT_XI_MIME.
        CLEAR  IT_XI_MIME.
      ENDLOOP.
    * Final Data
      CLEAR : IT_HTML,
              IT_HTML[].
      IT_HTML[] = IT_XI_MIME[].
    * For sending mail
      PERFORM SEND_MAIL TABLES EMAIL.
    ENDFORM.                    " page_format
    *&      Form  fetch_variants
    *       For fetching the variants available for the program
    FORM FETCH_VARIANTS .
      DATA : L_PROGRAM LIKE RS38M-PROGRAMM VALUE 'RKAEP000',
             L_VARA1 TYPE DFIES-FIELDNAME VALUE 'P_VARA1'.
      CLEAR : IT_VARIANT1,
              IT_VARIANT1[].
    * Get variants
      PERFORM GET_VARIANTS TABLES IT_VARIANT1
                           USING L_PROGRAM.
    * F4 Help
      IF NOT IT_VARIANT1[] IS INITIAL.
        PERFORM GET_F4_HELP TABLES IT_VARIANT1
                             USING L_VARA1
                            CHANGING P_VARA1.
      ELSE.
        MESSAGE E000 WITH 'No variants available for report1'(054).
      ENDIF.
    ENDFORM.                    " fetch_variants
    *&      Form  validation
    *       For Validation
    FORM VALIDATION .
      DATA : L_PRO1 LIKE RS38M-PROGRAMM VALUE 'RKAEP000',
             L_PRO2 LIKE RS38M-PROGRAMM VALUE 'GP3DIEHXY88SNFJ0391V7KF9EK7050',
             L_C1,
             L_C2.
    * If both check-box are unchecked
      IF P_C1 IS INITIAL
    AND P_C2 IS INITIAL.
        MESSAGE E000 WITH 'Check any one check-box'(049).
      ENDIF.
    * If checked without varaint
      IF NOT P_C1 IS INITIAL AND P_VARA1 IS INITIAL.
        MESSAGE E000 WITH 'Please give any one of the variant for report1'(055).
      ENDIF.
    * If checked without varaint
      IF NOT P_C2 IS INITIAL AND P_VARA2 IS INITIAL.
        MESSAGE E000 WITH 'Please give any one of the variant for report2'(061).
      ENDIF.
    * Reading the variant and fetching the mail-ids
      IF P_C1 = C_X.
        L_C1 = '1'.
        CLEAR : S_EMAIL,
                S_EMAIL[].
        PERFORM READ_VARIANTS TABLES IT_MAILID
                                     S_EMAIL
                               USING P_VARA1
                                     L_PRO1
                                     L_C1.
        IF S_EMAIL[] IS INITIAL.
          MESSAGE E000 WITH 'No Id available for given Cost report1'(066).
        ELSE.
          SORT S_EMAIL BY LOW.
          DELETE ADJACENT DUPLICATES FROM S_EMAIL COMPARING LOW.
        ENDIF.
      ENDIF.
    * Reading the variant and fetching the mail-ids
      IF P_C2 = C_X.
        CLEAR : S_EMAIL1,
                S_EMAIL1[].
        L_C2 = '2'.
        PERFORM READ_VARIANTS TABLES IT_MAILID1
                                     S_EMAIL1
                               USING P_VARA2
                                     L_PRO2
                                     L_C2.
        IF S_EMAIL1[] IS INITIAL.
          MESSAGE E000 WITH 'No Id available for given Cost report2'(067).
        ELSE.
          SORT S_EMAIL1 BY LOW.
          DELETE ADJACENT DUPLICATES FROM S_EMAIL1 COMPARING LOW.
        ENDIF.
      ENDIF.
    ENDFORM.                    " validation
    *&      Form  GET_VARIANTS
    *       Fetching Variants
    FORM GET_VARIANTS  TABLES   P_IT_VARIANT STRUCTURE IT_VARIANT1
                       USING    P_V_PROGRAM  TYPE RS38M-PROGRAMM.
      SELECT VARIANT
             FROM VARID
             INTO TABLE P_IT_VARIANT
             WHERE REPORT = P_V_PROGRAM.
    ENDFORM.                    " GET_VARIANTS
    *&      Form  GET_F4_HELP
    *       text
    FORM GET_F4_HELP  TABLES   P_IT_VARIANT1 STRUCTURE IT_VARIANT1
                       USING   P_L_VARA1 LIKE DFIES-FIELDNAME
                      CHANGING P_P_VARA LIKE P_VARA1.
    * Fn. for Pop-Up
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          RETFIELD        = P_L_VARA1
          VALUE_ORG       = 'S'
          DISPLAY         = ' '
        TABLES
          VALUE_TAB       = P_IT_VARIANT1
          RETURN_TAB      = IT_RETURN
        EXCEPTIONS
          PARAMETER_ERROR = 1
          NO_VALUES_FOUND = 2
          OTHERS          = 3.
      IF SY-SUBRC = 0.
        P_P_VARA = IT_RETURN-FIELDVAL.
      ELSE.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " GET_F4_HELP
    *&      Form  FETCH_VARIANTS1
    *       text
    FORM FETCH_VARIANTS1 .
      DATA : V_PROGRAM1 LIKE RS38M-PROGRAMM VALUE 'GP3DIEHXY88SNFJ0391V7KF9EK7050',
             L_VARA2  TYPE DFIES-FIELDNAME VALUE 'P_VARA2'.
      CLEAR : IT_VARIANT2,
              IT_VARIANT2[].
    * Get Variants
      PERFORM GET_VARIANTS TABLES IT_VARIANT2
                           USING V_PROGRAM1.
    * F4 Help
      IF NOT IT_VARIANT2[] IS INITIAL.
        PERFORM GET_F4_HELP TABLES IT_VARIANT2
                            USING  L_VARA2
                          CHANGING P_VARA2.
      ELSE.
        MESSAGE E000 WITH 'No variants available for report2'(050).
      ENDIF.
    ENDFORM.                    " FETCH_VARIANTS1
    *&      Form  read_variants
    *        Reading the variant and fetching the mail-ids
    FORM READ_VARIANTS TABLES P_IT_MAILID STRUCTURE IT_MAILID
                              P_S_EMAIL   STRUCTURE S_EMAIL
                       USING  P_P_VARA1   LIKE P_VARA1
                              P_L_PRO1    LIKE RS38M-PROGRAMM
                              P_L_C1      TYPE C.
      DATA : L_TEMP(44),
             IT_VALUTAB LIKE RSPARAMS OCCURS 0 WITH HEADER LINE.
      RANGES : R_COCEN FOR CSKS-KOSTL.
    * Function Module to get the variant contents
      CALL FUNCTION 'RS_VARIANT_CONTENTS'
        EXPORTING
          REPORT               = P_L_PRO1
          VARIANT              = P_P_VARA1
        TABLES
          VALUTAB              = IT_VALUTAB
        EXCEPTIONS
          VARIANT_NON_EXISTENT = 1
          VARIANT_OBSOLETE     = 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.
      CLEAR : R_COCEN,
              R_COCEN[].
      LOOP AT IT_VALUTAB WHERE SELNAME = 'KOSTL'
                            OR SELNAME = '_C-CCTR'.
    * Getting the range of cost centers
        IF IT_VALUTAB-OPTION = 'BT'.
          R_COCEN-LOW    = IT_VALUTAB-LOW.
    * For Conversion Routine
          PERFORM CONVERSION USING R_COCEN-LOW.
          R_COCEN-HIGH   = IT_VALUTAB-HIGH.
    * For Conversion Routine
          PERFORM CONVERSION USING R_COCEN-HIGH.
          R_COCEN-OPTION = 'BT'.
          R_COCEN-SIGN   = 'I'.
          APPEND R_COCEN.
          CLEAR  R_COCEN.
        ENDIF.
    * Getting the single cost centers
        IF IT_VALUTAB-OPTION = 'EQ'.
          R_COCEN-LOW    = IT_VALUTAB-LOW.
    * For Conversion Routine
          PERFORM CONVERSION USING R_COCEN-LOW.
          R_COCEN-OPTION = 'EQ'.
          R_COCEN-SIGN   = 'I'.
          APPEND R_COCEN.
          CLEAR  R_COCEN.
        ENDIF.
      ENDLOOP.
    * If no cost centers
      IF NOT R_COCEN[] IS INITIAL.
        SELECT KOKRS
               KOSTL
               DATBI
               TELX1
          FROM CSKS
               INTO TABLE P_IT_MAILID
         WHERE KOSTL IN R_COCEN.
        IF P_IT_MAILID[] IS INITIAL.
          IF P_L_C1 = '1'.
            MESSAGE E000 WITH 'No IDs available for report1'(059).
          ELSEIF P_L_C1 = '2'.
            MESSAGE E000 WITH 'No IDs available for report2'(062).
          ENDIF.
        ENDIF.
    * Deleting the blank entries
        DELETE P_IT_MAILID WHERE TELX1 = SPACE.
        CLEAR L_TEMP.
        READ TABLE P_IT_MAILID INDEX 1.
        L_TEMP = P_IT_MAILID-TELX1.
        DATA : L_CHECK.
        LOOP AT P_IT_MAILID WHERE TELX1 <> L_TEMP.
          L_CHECK = C_X.
        ENDLOOP.
    * For checking the unique ids
        IF L_CHECK = C_X.
          IF P_L_C1 = '1'.
            MESSAGE E000 WITH 'No unique mail-ids for  report1'(058).
          ELSEIF P_L_C1 = '2'.
            MESSAGE E000 WITH 'No unique mail-ids for  report2'(065).
          ENDIF.
        ENDIF.
    * Populating the IDs for the cost centers
        LOOP AT P_IT_MAILID.
          SET LOCALE LANGUAGE SY-LANGU.
          TRANSLATE P_IT_MAILID-TELX1 TO LOWER CASE.
          SET LOCALE LANGUAGE SPACE .
          CONCATENATE P_IT_MAILID-TELX1 '@allergan.com' INTO L_TEMP.
          P_S_EMAIL-LOW = L_TEMP.
          P_S_EMAIL-SIGN = 'I'.
          P_S_EMAIL-OPTION = 'EQ'.
          APPEND P_S_EMAIL.
          CLEAR  P_S_EMAIL.
        ENDLOOP.
      ELSE.
        IF P_L_C1 = '1'.
          MESSAGE E000 WITH 'No Cost Center Available for report1'(057).
        ELSEIF P_L_C1 = '2'.
          MESSAGE E000 WITH 'No Cost Center Available for report2'(063).
        ENDIF.
      ENDIF.
    ENDFORM.                    " read_variants
    *&      Form  CONVERSION
    *       For Conversion Routine
    FORM CONVERSION  USING    P_IT_VALUTAB_LOW TYPE C.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          INPUT  = P_IT_VALUTAB_LOW
        IMPORTING
          OUTPUT = P_IT_VALUTAB_LOW.
    ENDFORM.                    " CONVERSION
    check this Program......

Maybe you are looking for

  • Nokia X6-00 8GB

    Media Key is not working. What to do? Please help me.

  • I can't make back up copies

    Since last week, i've been trying to make a back up copy using icloud, but it always keep showing an error during the process and it make just part of the complete copy. Since then it keeps saying that i never have made a back up copy. When i do the

  • Basic theme corrupt, black boxes in apps when connected

    Hi.... On one of our Windows 2012 Remote Desktop Host servers we have the following problem. --Not working example: -- Working example: So black boxes all over the place. When I troubleshooted this as admin I found that switching the theme to "Window

  • Adobe Acrobat Standard 8.12 keeps crashing

    Hello I have an issue with Adobe Acrobat Standard 8.12.  When I load up Acrobat and go into the EDIT menu and then choose Preferences I get the following error. I initially uninstalled Adobe Acrobat Standard 8.12 and then reinstalled the application

  • Battery life on my G4 iBook

    I have had my iBook for 2.5 years now and I find the charge life on the battery is a little over an hour. Is this a normal time concidering the age of the battery? Is there anything I can do to extend this life? Where is a good place to get a new bat