How to link two different object (e.g. CRM TRANSACTIONS in document flow)
include CRM_BIN_RELATION_CON.
data: it_item_links TYPE crmt_brelvonai_tab.
DATA:
ls_new_binrel TYPE gbinrel,
ls_obj_predecessor TYPE borident,
ls_obj_successor TYPE borident,
lt_links TYPE STANDARD TABLE OF relgraphlk WITH HEADER LINE.
* fill role A (BUS2000116)
ls_obj_predecessor-objkey = '453C94F14F0800A902000000A0DC2704'.
ls_obj_predecessor-objtype = 'BUS2000116'.
ls_obj_predecessor-logsys = ''.
* fill role B (BUS2000126)
ls_obj_successor-objkey = '453C961B4F0800A902000000A0DC2704'.
ls_obj_successor-objtype = 'BUS2000126'.
ls_obj_successor-logsys = ''.
* Read header-relations
CALL FUNCTION 'SREL_GET_NEXT_RELATIONS'
EXPORTING
object = ls_obj_predecessor
relationtype = gc_bin_rel_type-predecessor_successor
TABLES
links = lt_links
EXCEPTIONS
OTHERS = 0.
CALL FUNCTION 'BINARY_RELATION_CREATE'
EXPORTING
obj_rolea = ls_obj_predecessor
obj_roleb = ls_obj_successor
relationtype = gc_bin_rel_type-predecessor_successor
fire_events = space
IMPORTING
binrel = ls_new_binrel
EXCEPTIONS
no_model = 1
internal_error = 2
unknown = 3
OTHERS = 4.
commit work and wait.