Generic Object Services (GOS) Toolbar Part 6 : Copy Attachments between objects

By | November 17, 2010 | Generic Object Services (GOS) | 6,757 | 2

Copy GOS attachment from one object to another object

Sometimes it is required to copy the attachments from one object to another object. For example, we want to attach the customer’s purchase order to Sales Order and Billing document once the billing document is generated.

To copy the attachments between the objects, we can use the utility method COPY_LINKED_OBJECTS of the class CL_GOS_SERVICE_TOOLS. We need to tell the method using IT_SERVICE_SELECTION, which service needs to be performed i.e. for the attachment copy, we need to perform the “Attachment Create” service. We also let the method know the the source and target.

Here is the Code snippet which copies the attachments between Customers.

*&---------------------------------------------------------------------*

*& Developed by: Naimesh Patel
*& Purpose     : To Copy the Attachment from One Object to Another
*&---------------------------------------------------------------------*
*
REPORT  ztest_np_copy_gos_att.
*
*
DATAlt_services TYPE tgos_sels.    " Services table typ
DATAls_service TYPE sgos_sels.     " Services structure type
DATAls_source TYPE sibflporb,      " Source
      ls_target TYPE sibflporb.      " Target
*
START-OF-SELECTION.
*
* Service needs to be performed
  ls_service-sign   'I'.
  ls_service-option 'EQ'.
  ls_service-low    'PCATTA_CREA'.
  APPEND ls_service TO lt_services.
*
* Source
  ls_source-instid 'CUST1'.
  ls_source-typeid 'KNA1'.
  ls_source-catid  'BO'.
*
* Target
  ls_target-instid 'CUST2'.
  ls_target-typeid 'KNA1'.
  ls_target-catid  'BO'.
*
* Copy the objects between Source and Target
  cl_gos_service_tools=>copy_linked_objects(
      is_source            ls_source
      is_target            ls_target
      it_service_selection lt_services
         ).
*
  COMMIT WORK.

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{272 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 272 articles.

Load comments

2 Comments

  • Lechoo

    Hello,
    i need a easy setup tool to manage entries in this table. For example:
    1. In the menu i have entrie “Attachment List”;
    2. By drag&drop funcionality i select this entrie and drag it to “Create” submenu.

    Can you help me (US) with this problem?

    THX,
    Lechoo

  • Markus

    Hi,

    I’ve a special requirement :-(
    I need to upload a file from local client to GOS, the tricky thing is I need to do this in background. The user only press a button and then the file should be attached to a certain BO?
    I tried with function modules SO_OBJECT_UPLOAD and SO_ATTACHMENT_INSERT, but I didn’t get it work :-(

    Any hints?

    regards
    Markus

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.