Creating and Displaying Relationships (Example)

Use

Create

The examples refer to the Modeling Examples.

Example 1: When creating a quotation the relationship is created for the preceding document "request for quotation".

Data:      neuerBeleg type borident.
        NeuerBeleg-objtyp =     'BUS2030'.
        NeuerBeleg-objkey =     neueBelegnummer.
        Referenzbeleg-objtyp =  'BUS2031'.
        Referenzbeleg-objkey =  ReferenzBelegnummer.
call function 'BINARY_RELATION_CREATE'
        export  obj_roleA =     Referenzbeleg
                obj_roleB =     NeuerBeleg
                relationtype =  'VONA'
...
COMMIT WORK.
            

Example 2: You link two lists, whereby the second list consists of the first list filtered according to the customer number. The application table is called Attrib_filter . The fields filter and field are defined in the INCLUDE structure.

Data : neuerBeleg type borident,
i_Attrib_filter type Attrib_filter occurs 10 with header line.
        NeuerBeleg-objtype =            'LIST'.
        NeuerBeleg-objkey =             neueBelegnummer.
        i_Attrib_filter-attribut =      'ATTRVONA'.
        i_Attrib_filter-posno =         '0001'.
        i_Attrib_filter-filter =        'KUNDENNUMMER'.
        i_Attrib_filter-field = Kundennummer.
call function 'BINARY_RELATION_CREATE'
        export  obj_roleA =             Referenzbeleg
                obj_roleB =             neuer_Beleg
        relationtype    =               'VONA'
        tables  binrel_attrib   =       i_Attrib_filter.
...
COMMIT WORK.
            

Display

Example 1: The simple API list display outputs all documents linked to the request for quotation (up to distance 1), in particular also the quotation.

DATA: OBJECT TYPE BORIDENT
        ...
        OBJECT-OBJTYPE = 'BUS2030'.
        OBJECT-OBJKEY = neueBelegnummer.
        CALL FUNCTION 'SREL_DISPLAY_LIST_OF_RELATIONS'
EXPORTING
        object =        OBJECT
        max_hops =      2      <-----Die Entfernung reicht bis zu den übernächsten Nachbarn
EXCEPTIONS
        NO_LOGSYS =     1
        OTHERS =        2.  
        IF sy-subrc <>    0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
ENDIF.