If during creation of purchase requisition you've attached some documents into requisition and you convert requisition to purchase order then the attachments aren't copy to PO. But you can do it either by daily job or by the implementation of user-exit if you know how to link GOS object to PO. I faced a request to copy attachments from PR to PO, but what I did was in fact just linking existing attachment to PO. In that way you do not double the same content on server. Bellow you can find the code of an function module which uses 'BINARY_RELATION_CREATE' and 'BINARY_RELATION_CREATE_COMMIT'.
- Importing
I_EBELN TYPE EBELN -> Purchase Order number
I_COMMIT TYPE C -> Do you want to do the commit?
- Tables
T_EBAN STRUCTURE EBAN -> Table with PR lines to check GOS relations
- Exceptions
BINARY_RELATION_CREATE_ERROR
- Function code:
function z_copy_att_from_pr_to_po.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_EBELN) TYPE EBELN
*" REFERENCE(I_COMMIT) TYPE C DEFAULT SPACE
*" TABLES
*" T_EBAN STRUCTURE EBAN
*" EXCEPTIONS
*" BINARY_RELATION_CREATE_ERROR
*"----------------------------------------------------------------------
data: fs_option type obl_s_relt,
ft_options type obl_t_relt,
ft_links type obl_t_link,
fs_link type obl_s_link.
data: ft_polinks type obl_t_link.
data: fs_lpor type sibflporb.
data: ft_eban type standard table of eban.
data: fs_eban like line of ft_eban.
data: l_length type i,
l_fol_id type soodk,
l_fol_mk type sofmk,
l_obj_id type soodk,
l_obj_data type sood1,
l_rolea type borident,
l_roleb type borident,
l_ep_note type borident-objkey,
l_itobjh type standard table of soli.
data: f_object type srgbtbrel-instid_a.
check t_eban[] is not initial.
ft_eban[] = t_eban[].
move i_ebeln to f_object.
"get attachments for PO
select instid_b from srgbtbrel
into corresponding fields of table ft_polinks
where reltype eq 'ATTA'
and instid_a eq f_object
and typeid_a eq 'BUS2012'
and catid_a eq 'BO'
and typeid_b eq 'MESSAGE'.
sort ft_polinks by instid_b.
sort ft_eban by banfn.
delete adjacent duplicates from ft_eban comparing banfn.
" get attachments links for all pr
loop at ft_eban into fs_eban where banfn is not initial.
refresh: ft_options[].
clear: fs_option, fs_lpor.
fs_lpor-instid = fs_eban-banfn.
fs_lpor-typeid = 'BUS2105'.
fs_lpor-catid = 'BO'.
fs_option-sign = 'I'.
fs_option-option = 'EQ'.
fs_option-low = 'ATTA'.
append fs_option to ft_options.
try.
call method cl_binary_relation=>read_links_of_binrels
exporting
is_object = fs_lpor
it_relation_options = ft_options
ip_role = 'GOSAPPLOBJ'
* ip_no_buffer =
importing
et_links = ft_links.
.
loop at ft_links into fs_link.
case fs_link-typeid_b .
when 'MESSAGE'.
read table ft_polinks with key instid_b = fs_link-instid_b
binary search
transporting no fields.
if sy-subrc eq 0.
delete table ft_links from fs_link.
endif.
when others.
delete table ft_links from fs_link.
endcase.
endloop.
catch cx_obl_parameter_error .
catch cx_obl_internal_error .
catch cx_obl_model_error .
catch cx_root.
endtry.
endloop.
sort ft_links by instid_b ascending.
delete adjacent duplicates from ft_links comparing instid_b.
"link attachments from PR to PO.
loop at ft_links into fs_link.
" Prepare attachment-attributes
move 'BUS2012' to l_rolea-objtype.
move i_ebeln to l_rolea-objkey.
" Build Key for GOS-Relation
move fs_link-instid_b to l_roleb-objkey.
move 'MESSAGE' to l_roleb-objtype.
" Create GOS-Relation
if i_commit eq 'X'.
call function 'BINARY_RELATION_CREATE_COMMIT'
exporting
obj_rolea = l_rolea
obj_roleb = l_roleb
relationtype = 'ATTA'
* IMPORTING
* BINREL = BINREL
* TABLES
* BINREL_ATTRIB = BINREL_ATTRIB
exceptions
no_model = 1
internal_error = 2
unknown = 3.
else.
call function 'BINARY_RELATION_CREATE'
exporting
obj_rolea = l_rolea
obj_roleb = l_roleb
relationtype = 'ATTA'
* IMPORTING
* BINREL = BINREL
* TABLES
* BINREL_ATTRIB = BINREL_ATTRIB
exceptions
no_model = 1
internal_error = 2
unknown = 3.
endif.
if sy-subrc ne 0.
raise binary_relation_create_error.
endif.
endloop.
endfunction.