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.

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.

  • Attach GOS attachments with a standard send mail functionality

    Hi Folks,
    I am here after long time and need your help.
    I have a requirement where I need to attach document with a standard send mail functionality.
    Below is the details:
    From Quality notification 'Action Box', if the user select a perticular action (it is similar to web link), the system is sending a mail to an external mail id provided by the user (In a popup). This mail send is happening through a SAP standard functionality.
    Now the requirement is, I need to attach selected file from GOS (generic Object Services) and attach them to the mail. Sending mail should happen through standard functionality.
    I want to know below two points:
    1) How to get selected files from GOS attachment?
    2) How to attach them to mail? (only attach, sending will be done by standard functionality)
    Hope I am clear with the requirement.
    Please help me to get it resolved.
    thanks,
    Surajit

    1st - analyse fm SO_ATTACHMENT_LIST_READ and table SOOD
    and function groups sgos* and SOB2
    hope that helps
    Andreas

  • How to attach GOS in a standard transaction ?

    hi folks,
    could anyone tell me how to attach Generic Object Services (GOS) to a standard transaction eg me23n.
    this GOS toolbar is present in certain transactions like pb40 ..i want to implement the same in me23n ...how can i do that?

    welcome to SDN!!!
      cht this webblog
      /people/rammanohar.tiwari/blog/2005/10/10/generic-object-services-gos--in-background
      reward points if helpful

  • 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 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

  • 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...

  • 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

Maybe you are looking for