Welcome, you seems to be new here. Get Connected: Become a Fan on Facebook Join ABAP Help on Google+ Subscribe to email X

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

By | November 17, 2010 | Generic Object Services (GOS) | 2,035 views
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.

Get your Social On!

Stay Tuned with ABAP Help

1 Comment

  • 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

    Reply

Wanna say something?





=

To post ABAP code use shortcode [abap_code slider="X" title=""][/abap_code]