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.
*
*
DATA: lt_services TYPE tgos_sels. " Services table typ
DATA: ls_service TYPE sgos_sels. " Services structure type
DATA: ls_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.
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
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