Delete attachment

Hi all,
I am newbie in BPM. I am confuse about deleting one of attachment that i store in instance BPM attachment (this.attachments).
Example:
I create attachment twice..
- Attachment.create(contents :content1, name :..., description :'desk1', remarks :...);
- Attachment.create(contents :content2, name :..., description :'desk2', remarks :...);
How to delete the first attachment?
I can identify the first attachment use looping.But i dont know to delete this.
Here is the snippet code:
for(Attachment attach :this.attachments){
if(attach.description=='desk1'){
//do things here
Edited by: user10903377 on Dec 6, 2009 7:15 PM

The answer for your question depends on what that method create is doing...
To delete an attachment, all you have to do is stop referencing it.
perhaps this source can clarify what I'm saying:
//Create the attachments
attachments as Attachment[]
for i in 0..2 do
insert attachments using int = length(attachments), value= Attachment()
end
//Delete the second attachment
result as Any = delete centros[1]
I hope it helps...

Similar Messages

  • Outlook delete attachment files if use POP3

    Hi every body,
    I have a problem with outlook. I send a mail with attachment using java mail api. Anyone get the mail correctly (gmail, outlook, outlook express or thunderbird) via SMTP. But if outlook try to get the mail via POP3, it deletes attachment and show only other part of mail. Other clients dont do it include outlook express. I dont have any idea about this situation. Can any body help me?
    My mail code is here:
    Properties props = new Properties();
    props.put("mail.smtp.host", server);
    props.put("mail.smtp.port", String.valueOf(port));
    session = Session.getDefaultInstance(props, null);
    transport = session.getTransport("smtp");
         MimeMessage msg = new MimeMessage(session);
         msg.setSentDate(new Date());
         msg.setFrom(fromAddress);
         msg.setRecipients(Message.RecipientType.TO, toAddress);
         msg.setSubject(subject, "UTF-8");
         MimeBodyPart messageBodyPart = new MimeBodyPart();
         String htmlEncoded = TurkishLocaleHelper
                   .convertTrToUTF8(message);
         messageBodyPart.setText(htmlEncoded);
         messageBodyPart.setHeader("Content-Type",
                   "text/html;charset=UTF-8");
         messageBodyPart.setHeader("Content-Transfer-Encoding",
                   "quoted-printable");
         MimeMultipart multipart = new MimeMultipart(
                   "alternative");
         multipart.addBodyPart(messageBodyPart);
         if (mailItem.getAttachmentFileList() != null) {
              for (String fileName : mailItem.getAttachmentFileList()) {
                   BodyPart fileBodyPart = new MimeBodyPart();
                   DataSource source = new FileDataSource(fileName);
                   fileBodyPart.setDataHandler(new DataHandler(source));
                   fileBodyPart.setFileName(FileUtil.trimFilePath(fileName));
                   multipart.addBodyPart(fileBodyPart);
         if (mailItem.getAttachmentFileMap() != null) {
              Map<String, String> fileMap = mailItem.getAttachmentFileMap();
              Set<String> keySet = fileMap.keySet();
              for (String filePath : keySet) {
                   String fileName = fileMap.get(filePath);
                   BodyPart fileBodyPart = new MimeBodyPart();
                   DataSource source = new FileDataSource(filePath);
                   fileBodyPart.setDataHandler(new DataHandler(source));
                   fileBodyPart.setFileName(fileName);
                   multipart.addBodyPart(fileBodyPart);
         msg.setContent(multipart);
         msg.saveChanges();
    transport.sendMessage(msg, msg.getAllRecipients());Edited by: vistek on Apr 13, 2010 6:10 AM

    Yes i was wrong. I use SMTP to sent mail, and POP3 to read it. Mail is shown with attachment in gmail but it is shown only body in outlook. If i open socket and sent mail via socket it is worked.
    Now i search using this method with attachment. Does any body know that?
    Example code:
    import java.net.*;
    import java.io.*;
    public class SMTP {
      private String message;
      private String localMachine;
      private String senderName;
      private String recipient;
      private boolean valid_and_unsent = false;
      private BufferedReader in;
      private BufferedWriter out;
      // class constants
      public static final int SMTP_PORT = 25;
      private static final boolean logging = true;
      public SMTP() {
      public SMTP(String sender) {
        int indexOfAtSign = sender.indexOf('@');
        if (indexOfAtSign < 0) {
          throw new RuntimeException("Malformed sender address." +
            " Need full user@host format");
        this.senderName = sender.substring(0, indexOfAtSign);
        this.localMachine = sender.substring(indexOfAtSign + 1);
      public SMTP(String sender, String recipient, String message) {
        this(sender);
        setMessage(recipient, message);
      public void setMessage(String recipient, String message) {
        this.recipient = recipient;
        this.message = message;
        valid_and_unsent = true;
      public void send() throws IOException {
        if (!valid_and_unsent) {
          throw new RuntimeException("Attempt to send incomplete message," +
            " or send message twice");
        // if this message is legitimate, continue to extract
        // the remote machine name
        int indexOfAtSign = recipient.indexOf('@');
        if (indexOfAtSign < 0) {
          throw new RuntimeException("Malformed recipient address." +
            " Need full user@host format");
        String destinationMachine = recipient.substring(indexOfAtSign + 1);
        // attempt to make the connection, this might throw an exception
        Socket s = new Socket(destinationMachine, SMTP_PORT);
        in = new BufferedReader(
               new InputStreamReader(s.getInputStream(),"8859_1"));
        out = new BufferedWriter(
               new OutputStreamWriter(s.getOutputStream(),"8859_1"));
        String response;
        // discard signon message, introduce ourselves, and discard reply
        response = hear();
        say("HELO " + localMachine + "\n");
        response = hear();
        say("MAIL FROM: " + senderName + "\n");
        response = hear();
        say("RCPT TO: " + recipient + "\n");
        response = hear();
        say("DATA\n");
        response = hear();
        say(message + "\n.\n");
        response = hear();
        say("QUIT\n");
        // now close down the connection..
        s.close();
      private void say(String toSay) throws IOException {
        out.write(toSay);
        out.flush();
        if (logging) {
          System.out.println(toSay);
      private String hear() throws IOException {
        String inString = in.readLine();
        if ("23".indexOf(inString.charAt(0)) < 0) {
          throw new IOException("SMTP problem: " + inString);
        if (logging) {
          System.out.println(inString);
        return inString;
      public static void main(String args[]) throws Exception {
        BufferedReader in = new BufferedReader(
                                   new InputStreamReader(System.in));
        System.out.print("Your address: ");
        System.out.flush();
        String sender = in.readLine();
        System.out.print("Recipient address: ");
        System.out.flush();
        String recipient = in.readLine();
        String message = "";
        String part;
        System.out.println("Message, end with '.' by itself:");
        for (;;) {
          part = in.readLine();
          if ((part == null) || part.equals(".")) {
            break;
          message += part + "\n";
        SMTP mailer = new SMTP(sender, recipient, message);
        mailer.send();
    }

  • Delete Attachment in activity/interaction record ICWEB ???

    Hello
    I have implemented the deltion of attachment using following code. the commands went sucessfull but it is not deleting attachment(which is linked to activity/interaction record)
    lr_entity_col = lv_bo->get_related_entities(  iv_relation_name =  cl_crm_cm_genil_comp=>gc_rel_bo_document_ref ).
    lv_bo  =   lr_entity_col->get_first( ).
           lv_bo->delete( ).
           lv_core->modify( ).
           lv_transaction = lv_core->get_transaction( ).
           lv_transaction->save( ).
           lv_transaction->commit( ).
    Does anybody implemented similar logic?
    Regards,
    Laxman
    Edited by: laxman on Jan 29, 2008 7:26 PM

    Hi Laxman,
          The code you have mentioned is fine.
         But the bug might exist in UI or BOL layer. Just to be sure that save is successful, I always use the below code. You may try the same.
      IF lv_transaction->check_save_needed( ) EQ abap_true.
        IF lv_transaction->save( ) = abap_true.
    Regards,
    Manas.

  • Documents Search - Delete Attached Documents

    Hi,
    I am trying to figure out a way to delete attached documents from CRM tickets. There are instances where the user is attaching the wrong document to an interaction record. There is currently no known way to delete this attachment. Is there a way to do this? We want to be able to delete attachment totally...not just archive.
    We are using CRM 5.0
    Thanks,
    John.

    Class CL_CRM_DOCUMENTS Static Method DELETE
    BUSINESS_OBJECT-instid =   Business Object Number / CRM Transaction Number
    BUSINESS_OBJECT-typeid = Business Object i.e BUS200126
    BUSINESS_OBJECT-catid  = 'BO'.

  • Delete attachment linked to activity in ICWEB

    Hello
    I have implemented the deltion of attachment using following code. the commands went sucessfull but it is not deleting attachment(which is linked to activity/interaction record)
    lr_entity_col = lv_bo->get_related_entities( iv_relation_name = cl_crm_cm_genil_comp=>gc_rel_bo_document_ref ).
    lv_bo = lr_entity_col->get_first( ).
    lv_bo->delete( ).
    lv_core->modify( ).
    lv_transaction = lv_core->get_transaction( ).
    lv_transaction->save( ).
    lv_transaction->commit( ).
    Does anybody implemented similar logic?
    Regards,
    Laxman

    I have added custom tab to store attach the files to Interaction recrod i.e business activity.
    I m using following way to add attachment
    create document child
      lv_core = cl_crm_bol_core=>get_instance( ).
      lv_transaction = lv_core->begin_transaction( ).
      IF lv_bo->lock( ) = if_genil_boolean=>true.
        if lv_bo->is_changeable( ) = abap_true.
          TRY.
              lv_doc = lv_bo->create_related_entity(
                         cl_crm_cm_genil_comp=>gc_rel_bo_document_ref ).
            CATCH cx_crm_genil_model_error.
            CATCH cx_crm_genil_duplicate_rel.
          ENDTRY.
        endif.
    regards,
    Laxman

  • New Mail Message Won't Let Me Delete Attachment

    MacBook Pro (Retina, 15-inch, Mid 2014)
    10.10.2 (14C109)
    2.8 GHz Intel Core i7
    16 GB 1600 MHz DDR3
    500 GB SSD
    NVIDIA GeForce GT 750M 2048 MB
    Now some fun with emails.
    I composed a lengthy, carefully thought out, email to my CPA.  Then, without thinking, I added an PDF document as an attachment right in the middle of the text.  Can happen to anyone.
    I spent the next 20 minutes looking for a delete, CMD X, edit delete, or someway to remove the attachment.  No luck,  CMD Z did remove the CC: entry I just added, but not the attachment.  Can't drag it.
    So I spent another 10 minutes manipulating the text, ever so carefully, around the attachment, so the attachment would appear at the bottom on the email.
    So tell me.  Someone actually designed it to work this way?  Or maybe design is too harsh of a word.  It is a **** of a lot of work for something that should be so simple.

    Normally, you delete objects like that in mail by either positioning the cursor just after the attachment and pressing delete. Or by clicking once on it and pressing delete.

  • Delete Attachment link and the launchWebdynpro button in the UWL iview

    Hi,
    Can anyone help me in deleting or hiding the Attachment link and the launchWebdynpro button in the UWL iview. I dont want to do it in the iview properties which would affect all the tasks. Is there a way I can do it in the backend.\
    I appreciate the help.
    Thanks

    Hi Surjith,
    I have the same problem. How can I remove the link? After I called the mentioned function module, the attachment was removed (content) but in the UWL the file name is still there:
    From UWL:
    myFile.pdf by WF-BATCH (94 kb)
    myDeletedFile.pdf   <-- I removed this one with the function module
            CALL FUNCTION 'SAP_WAPI_ATTACHMENT_DELETE'
              EXPORTING
                workitem_id     = me->mv_wf_instance_id
                att_id          = ls_att_id
                delete_document = abap_true
              IMPORTING
                return_code     = lv_return.
    Could you please help me?
    Thanks,
    Thomas

  • How to delete attachment to reduce size of message

    I recently moved over from Eudora to Mail.app
    In Eudora, all attachments were put in an attachments folder, so the size of the actual message in the mailbox was small.
    In Mail.app, it seems that the attachments stay as part of the message, even if I save them to another location. If I try to delete the attachment (a jpg for example) it deletes the entire message.
    Is there a way to keep the message, but delete the attachment, so that my mailbox size stays small?
    thank you...

    LOL!
    Full marks for spotting my deliberate error!
    Ta for the star!

  • How to recover deleted attached mdf file from sql server management studio

    Hi everyone
    I've faced very bad problem
    I had a mdf file that created in visual studio, and then I had attached this file to sql server management studio and after that, when I wanted to deattach
    this file I had a big mistake; and deleted the mdf file; then now this file was deleted from my computer
    I test several recovery tools but they can't find deleted mdf file; the volume of the mdf file was more than 2 GB.
    Please help me if you can

    Hello,
    If you don't have a backup of the database, then it's not really possible to get it back. There are some "Undelete" Tools available for Windows, but when even only one page was overwritten on disk, then it's not possible to recover it.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Delete Attachment - GOS

    Hi,
    I am deleting a GOS attachment using following code.
    data: i_borident  type borident,
           i_attsrv    type ref to cl_gos_document_service.
      i_objectd-objtype = 'YATTA'.
      i_objectd-logsys  = 'BO'.
      i_objectd-objkey  = inumber.
      select * from srgbtbrel                " Get GOS Link
               into table i_srgbtbrel
               where instid_a eq i_objectd-objkey
                 and typeid_a eq i_objectd-objtype
                 and catid_a eq i_objectd-logsys
                 and reltype eq 'ATTA'.
      if sy-subrc eq 0.
        create object i_attsrv.
        loop at i_srgbtbrel.
         i_borident-objkey =  i_srgbtbrel-instid_b.
         call method i_attsrv->delete_attachment
           exporting
    *         is_object     = i_objectd
             ip_attachment = i_borident-objkey.
         commit work.
        endloop.
      endif.
    I am getting proper binary key from table SRGBTBREL and passing to method DELETE_ATTACHMENT , and getting sy-subrc eq 0, then also attachment are showing in the document. But if you are going thru service object delete it has been deleting the attachment perfectly. What is the error in the code?
    Thanks
    aRs
    Message was edited by:
            aRs

    Hi.
    You are missing  SO_OBJECT_DELETE_IN_VB:
        data ls_folder_id type soodk.
        data ls_object_id type soodk.
        loop at i_srgbtbrel.
          i_borident-objkey =  i_srgbtbrel-instid_b.
          call method i_attsrv->delete_attachment
            exporting
    *         is_object     = i_objectd
             ip_attachment = i_borident-objkey.
          ls_folder_id = i_borident-objkey(17).
          ls_object_id = i_borident-objkey+17(17).
          call function 'SO_OBJECT_DELETE_IN_VB'
             in update task
             exporting
               folder_id = ls_folder_id
               object_id = ls_object_id.
        endloop.
        commit work and wait.
    At the end of cl_gos_document_service->delete_attachment, there is the line:
    call function 'GOS_ADD_KEY' exporting ip_objkey = ip_attachment.
    This function adds the deleted item to table gt_obj_to_delete.
    Later, the standard makes the call to SO_OBJECT_DELETE_IN_VB at include LSGOSITSF01, form  DELETE_OBJECTS using gt_obj_to_delete.
    Thanks.

  • Delete attachment from master data

    Hello,
    I need to delete .pdf file from attachment list of one material but there is no delete button. How could I delete it?
    Thank you

    click the right hand side of the icon( services for object), where you attached the document
    click the attachment list, select the attached file you want to delete and click delete icon in MM02
    or
    in  menu click system-->service for object in MM02
    Click the attachment list  icon next to the create icon select the attached file you want to delete and click delete icon
    Edited by: Sundaresan . E. V on Oct 2, 2010 9:14 PM

  • Composing a new email message, can't delete attachment

    While composing an email message, I attached a file. Realizing I attached the wrong file, I couldn't find any way to delete it, and attach the correct file instead. I had to create a brand new message in order to attach the correct file.

    I played around with it some more, and have discovered what is really going on. After you add one or more attachments to a composing email, there are two different ways to select an attachement. One way is to click on the icon (the cursor will show as an arrow pointer). You can then do edit - cut, and remove the attachement. Another way is to click on the name of the file below the icon (the cursor will show as a link pointer). This will open the file and move focus to the program that the file is opened under (for instance MS Word). That was what was confusing me. However, if you move focus back to Mail (by clicking on the email you are composing) the attachement will be selected, and you can either use the delete key, or use edit/cut to delete it.

  • Question about SAP_WAPI_ATTACHMENT_DELETE and deleting attachment in WF

    I find SAP_WAPI_ATTACHMENT_DELETE with import parameter of WI_ID just delete the attachment of the entered workitem.  If the WF process continues to the next step and generates a new workitem, the workitem still has the attachment.
    Other question: What is the system of storing attachment in WF? Are they stored in the container ? Or What is saved in the container element is only a reference? Can I delete a attachment globally? Is there any statement to delete the attachment?

    Hi Sun,
    Please check whether you have inserted a attachment objects to the father work item id or to the current work item id.
    and after deleting the attachments please check the log for attachments.
    Regards
    SM Nizamudeen

  • Disable 'Delete' button for posted invoices  in GOS Attachment List

    Hi,
    when i open the attachement list of a generic object i see the attached files. In this dialog i want to disable the   "Delete" ( attachment)  button  for Posted invoices ( In MIR4 tcode -> If the invoice is already posted it should not allow to delete the attachment )
    I read oss notes and some ides of copying diverse classes but nothing really helps.
    I found two badis
    GOS_SRV_REQUEST
    GOS_SRV_SELECT
    but i dont know where we have to write our code .
    I read so many posts related to attachments but all the places described about authoriztion object .
    Can you please give some ideas to disable the delete button for posted invoices.

    Hello,
    For GOS there is no SAP Standard authorization concept. The only way to
    manage GOS authorizations is implementing it via custom code as
    described in SAP Note: 491271.
    Please have a look at the SAP notes:
    491271 Authorizations for generic object services
    701609 Authorizations for services: Final classes
    For the use of S_OC_ROLE: this object states if a user is an office
    administrator he can create, modify or delete every document, even
    those created by other users. If the user is not an office admin, the
    user is still able to create his own attachments.
    Regarding to the issue, there is an role object S_GUI for upload.
    To match your inquiry, pleaes find the user's role and active the
    object S_GUI.
    Regards,
    David

  • How to disable delete option or symbol in attachment control in infopath 2010

    Any have any idea how to disable the delete option or symbol near the attached file using attachment control in infopath 2010.
    I have created a custom list in sharepoint online 2013(Office 365) and customized it in  Infopath forms 2010 
    i want tht user can attach the files using attachment control but not to allow to delete other attached files.
    plzzzzzz help me out :( .

    Hello,
    As per my finding, you have to custom create event receiver to handle this situation. Use "ItemAttachmentDeleting" event to prevent user to delete attachment. Please refer below MSDN link to implement this:
    http://stackoverflow.com/questions/2023414/prevent-deletion-of-attachments-from-a-sharepoint-list-item
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

Maybe you are looking for

  • Cheque No

    Hi Is it possible to display Incoimng Payment Cheque No in Business Party Ledger . If yes then how it can be displayed. Regards Jagjit Saini

  • Resize a single desktop icon?

    Is there any way to change the size of just one folder icon on the desktop? I just want to be able to emphasize one icon, and keep the others a smaller size.  Is this possible?

  • HT201289 Aperture 3.6 update does NOT export my slideshows

    Slideshows created in previous version 3.5x and could be exported with that version, now it is no longer possible to export with 3.6v. I do all the clicks necessary for the export and nothing comes out of Aperture, even to iTunes lib. I'm running thi

  • How to reinstall Thinkpad Components on a T61?

    The hard drive on my T61 died.  The operating system on it was XP.  I want to take the opportunity to upgrade to 7.  I ordered a new hard drive from Lenovo and rather than purchasing the recovering CDs, installing XP on the new drive, and then upgrad

  • Safari 5.1 can't redirection by hotspot

    after upgrade to Lion Safari 5.1, I can't login Madonld WiFi.