Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

issue with cl_binary_relation=>create_link while running through tcode o3o_sc01

Former Member
0 Kudos

We have a scenario in which for attaching filesto PR's which were created through tcode O3O_SC01.

We use the method cl_binary_relation=>create_link, in a BADI implemented for ME_REQ_POSTED.

The issue is when we give a set of 3 to 5 PR's at a time to the tcode O3O_SC01 for attaching from the corresponding STR's then the last PR is getting all the attachements.

We were unable to understand what special is happening in the last PR in the code.

The code is as below, Request you to kindly let us know if anyone has come across similar situation or know what is the better way to handle this

IF sy-tcode = 'O3O_SC01' AND sy-ucomm = 'SAVE' OR sy-batch IS NOT INITIAL.
    DATA : lt_eban TYPE STANDARD TABLE OF eban,
           lwa_eban LIKE LINE OF lt_eban,
           lt_toa01 TYPE STANDARD TABLE OF toa01,
           lwa_toa01 LIKE LINE OF lt_toa01,
           lt1_toa01 TYPE STANDARD TABLE OF toa01,
           lwa1_toa01 LIKE LINE OF lt_toa01,
           lt_srgbtbrel TYPE STANDARD TABLE OF srgbtbrel,
           lwa_srgbtbrel TYPE srgbtbrel,
           lwa_lpor TYPE sibflporb,
           lt_relat TYPE obl_t_relt,
           lwa_relat LIKE LINE OF lt_relat,
           lt_connections TYPE STANDARD TABLE OF bdn_con,
           lwa_connections LIKE LINE OF lt_connections,
           lwa_is_object_a TYPE sibflporb,
           lwa_is_object_b TYPE sibflporb,
           lv_notekey TYPE borident-objkey,
           lwa_eban_tmp TYPE eban,
           lt_links TYPE obl_t_link,
           la_links LIKE LINE OF lt_links,
           lwa_reltype TYPE oblreltype.

    CONSTANTS : c_bus2012 TYPE saeanwdid VALUE 'BUS2012',
                c_bus2010 TYPE saeanwdid VALUE 'BUS2010',
                c_bus2105 TYPE saeanwdid VALUE 'BUS2105',     " added by SHA179
                c_message(7) TYPE c VALUE 'MESSAGE',
                c_atta TYPE oblreltype VALUE 'ATTA',
                c_bo(2) TYPE c VALUE 'BO',
                c_w TYPE c VALUE 'W',
                c_i TYPE c VALUE 'I',
                c_eq(2) TYPE c VALUE 'EQ',
                c_bus1001006 TYPE bapibds01-classname  VALUE 'BUS1001006'.
    READ TABLE im_eban INTO lwa_eban_tmp INDEX 1.
    IF  NOT lwa_eban_tmp-oio_ref_banfn IS INITIAL.
      SELECT * FROM toa01 INTO TABLE lt_toa01 WHERE object_id EQ lwa_eban_tmp-oio_ref_banfn.

      IF NOT lt_toa01[] IS INITIAL.
        LOOP AT lt_toa01 INTO lwa_toa01.
          lwa1_toa01-mandt = sy-mandt.
          lwa1_toa01-sap_object = c_bus2105.
          lwa1_toa01-object_id =  lwa_eban_tmp-banfn.
          lwa1_toa01-archiv_id = lwa_toa01-archiv_id.
          lwa1_toa01-arc_doc_id = lwa_toa01-arc_doc_id.
          lwa1_toa01-ar_object = lwa_toa01-ar_object.
          lwa1_toa01-ar_date = lwa_toa01-ar_date.
          lwa1_toa01-del_date = lwa_toa01-del_date.
          lwa1_toa01-reserve = lwa_toa01-reserve.
          APPEND lwa1_toa01 TO lt1_toa01.
          CLEAR lwa1_toa01.
        ENDLOOP.
        CLEAR lwa_toa01.
      ENDIF.
    ENDIF.
    SELECT * FROM srgbtbrel INTO TABLE lt_srgbtbrel WHERE instid_a EQ lwa_eban_tmp-oio_ref_banfn AND typeid_a EQ c_bus2105 AND catid_a EQ c_bo.
    IF NOT lt_srgbtbrel[] IS INITIAL.
      READ TABLE lt_srgbtbrel INTO lwa_srgbtbrel INDEX 1.
      lwa_lpor-instid = lwa_srgbtbrel-instid_a.
      lwa_lpor-typeid = c_bus2105.
      lwa_lpor-catid  = c_bo.
      lwa_relat-sign = c_i.
      lwa_relat-option = c_eq.
      lwa_relat-low = lwa_srgbtbrel-reltype.
      APPEND lwa_relat TO lt_relat.
      CALL FUNCTION 'BDS_GOS_CONNECTIONS_GET'
        EXPORTING
          classname       = 'BUS2105'
          objkey          = lwa_srgbtbrel-instid_a
        TABLES
          gos_connections = lt_connections.
      IF sy-subrc <> 0.
      ENDIF.
    ENDIF.
    IF lt_connections IS NOT INITIAL.
      SORT lt_connections BY loio_id.
      DELETE ADJACENT DUPLICATES FROM lt_connections COMPARING loio_id.
      delete lt_connections WHERE objkey NE LWA_EBAN_TMP-OIO_REF_BANFN.     "added by SHA179
      LOOP AT lt_connections INTO lwa_connections.
        lv_notekey = lwa_connections-loio_id.
        lwa_is_object_b-instid = lv_notekey.
        lwa_is_object_b-typeid = c_message.
        lwa_is_object_b-catid  = c_bo.
        lwa_is_object_a-instid = lwa_eban_tmp-banfn.
        lwa_is_object_a-typeid = c_bus2105.
        lwa_is_object_a-catid  = c_bo.
        lwa_reltype = la_links-reltype.


        IF lwa_is_object_a-instid  IS NOT INITIAL AND
             lwa_is_object_a-typeid  IS NOT INITIAL AND
             lwa_is_object_a-catid   IS NOT INITIAL AND
             lwa_is_object_b-instid  IS NOT INITIAL AND
             lwa_is_object_b-typeid  IS NOT INITIAL AND
             lwa_is_object_b-catid   IS NOT INITIAL.

          TRY.
              CALL METHOD cl_binary_relation=>create_link
                EXPORTING
                  is_object_a = lwa_is_object_a
                  is_object_b = lwa_is_object_b
                  ip_reltype  = c_atta.
            CATCH cx_obl_parameter_error.
            CATCH cx_obl_model_error.
            CATCH cx_obl_internal_error.
          ENDTRY.
        ENDIF.
        CLEAR : lwa_connections , lwa_is_object_b , lwa_is_object_a , lv_notekey.
      ENDLOOP.
    ENDIF.
  ENDIF.

1 REPLY 1

Azeemquadri
Contributor
0 Kudos

Can you try using COMMIT work after the method call to create the links.