Skip to Content

I’ve had a problem assigning a newly created rental space (cut out of a poolspace) to an object group.

I solved it and want to blog it to prevent other real estate developers from running into this mess with assigning rental objects to an object group.

At first, I was trying my luck with CL_REBD_OBJ_ASSIGN_MNGR_BO. But due to the fact, that there is only a interface available with OBJASSTYPE = ’10’ (Contract=>Object Group),


OBJASSTYPE IMPLIFNAME                                            GUIFMPBO                                XOBJASSTYPE        

10                   IF_REBD_OBJ_ASSIGN_MNGR_BO     REBD_GUI_OBJASS_BO_PBO   Vertrag => Objekt(gruppe)
11                                                                                   REBD_GUI_OBJASS_BO_PBO   Objektgruppe => Objekt  (Object Group => Rental Object)

Later I discovered, that the GUI is using using the class CL_RECN_OBJ_ASSIGN_MNGR_CN to accomplish what I wanted to do.

At first, I was not able to apply a method to do just that with objasstype 11.

As you can see in the table,  type 11 can only be handled in the GUI PBO Module. That’s why I wrote nearly a copy of the code I found there when I debugged the ‘+’ Button to add an object to the object group in the GUI.

Surprisingly there’s this simple insert_bus_object-method at the end of the code snippet that does the job.

Everything works fine in the insert_bus_object-method, it quits with sy-subrc = 0:


   METHOD add_rental_space_to_objgroup.
* Fügt ein Mietobjekt in eine Objektgruppe ein
    lo_obj_assign_mngr_cn TYPE REF TO cl_recn_obj_assign_mngr_cn,
    lt_obj_assign_bo      TYPE re_t_obj_assign_bo,
    lt_object_objtype     TYPE re_t_reca_object_objtype_x,
    ls_obj_assign         TYPE rebd_obj_assign,
    ls_obj_assign_bo      LIKE LINE OF lt_obj_assign_bo,
    ls_object_objtype     LIKE LINE OF lt_object_objtype,
    ld_objnr              TYPE recaobjnr,
    ld_adjustnumber       TYPE rebd_obj_assign_bo_xadjustnumber,
    lf_assignonlyinfo     TYPE recabool,
    lo_bo                 TYPE REF TO if_reca_bus_object,
    ld_ident              TYPE recaident.

* init
* Object Assign Manager Contract
  lo_obj_assign_mngr_cn = io_obj_assign_mngr_cn.
  CLEAR: lf_assignonlyinfo.

* I. Which object will be added?
  ld_objnr = iv_objnr.

* II. get allowed object information
  CLEAR: lt_object_objtype.
  lt_object_objtype = lo_obj_assign_mngr_cn->get_objtypes_allowed( ).
* {lo_obj_assign_mngr muss vom Typ \CLASS=CL_RECN_OBJ_ASSIGN_MNGR_CN sein!}

* set valid from and valid to of assignment
  ls_obj_assignvalidfrom = md_sheet_date.
  ls_obj_assignvalidto   = reca0_datemax.

*   III. check if object already is present
  CALL METHOD lo_obj_assign_mngr_cn->get_list_bo
      id_objnrtrg    = ld_objnr
      if_fix_periods = abap_false
      et_list        = lt_obj_assign_bo.

*–> no entries in this table!

* delete generated entries
  DELETE lt_obj_assign_bo WHERE ismultiassgen = abap_true.

*   if yes use current date for insertion…
  IF lo_obj_assign_mngr_cn->is_attribute_supported(
            id_attribute = rebd2_objass_attributeperiod ) = abap_true.

* => it’s not true in my case, scroll down!

    READ TABLE lt_obj_assign_bo INTO ls_obj_assign_bo
      WITH KEY objnrtrg  = ld_objnr
               validfrom = ls_obj_assignvalidfrom.
    IF sysubrc = 0.
      ls_obj_assignvalidfrom = sydatum.
      LOOP AT lt_obj_assign_bo INTO ls_obj_assign_bo
        WHERE objnrtrg  = ld_objnr.
        IF ls_obj_assign_bovalidto > ls_obj_assignvalidfrom.
          IF ls_obj_assign_bovalidto <> reca0_datemax.
            ls_obj_assignvalidfrom = ls_obj_assign_bovalidto + 1.
          ENDIF.“ls_obj_assign_bo-validto <> reca0_date-max.
        ENDIF.“ls_obj_assign_bo-validto > ls_obj_assign-validfrom.
      ENDLOOP.“AT lt_obj_assign_bo INTO ls_obj_assign_bo
    ENDIF.“READ TABLE lt_obj_assign_bo INTO ls_obj_assign_bo

    READ TABLE lt_obj_assign_bo INTO ls_obj_assign_bo
      WITH KEY objnrtrg     = ld_objnr
               validfrom    = ls_obj_assignvalidfrom
               adjustnumber = ld_adjustnumber.
    IF sysubrc = 0.
      CALL METHOD cf_reca_bus_object=>find_by_objnr
          id_objnr    = ld_objnr
          ro_instance = lo_bo
          error       = 1
          OTHERS      = 2.
      IF sysubrc <> 0.
*        mac_symsg_send_as_type ‘S’.
*        CONTINUE.

* ?
      CALL METHOD lo_bo->get_ident
          ed_ident = ld_ident.
*      MESSAGE s028(rebdoa) WITH ld_ident.
*      CONTINUE.
    ENDIF.“READ TABLE lt_obj_assign_bo INTO ls_obj_assign_bo




  CLEAR ls_object_objtype.
  READ TABLE lt_object_objtype INTO ls_object_objtype
       WITH KEY objtype = ld_objnr(2). “IM

  lf_assignonlyinfo = abap_false.

* Insert Rental Space to Object Group
  CALL METHOD lo_obj_assign_mngr_cn->insert_bus_object
      id_objnr          = ld_objnr
      id_validfrom      = ls_obj_assignvalidfrom
      id_validto        = ls_obj_assignvalidto
      id_adjustnumber   = lc_adjustnr_10
      id_assignonlyinfo = lf_assignonlyinfo
      es_obj_assign     = ls_obj_assign
      error             = 1
      OTHERS            = 2.
  IF sysubrc <> 0.
*    mac_symsg_send_as_type ‘S’.

Checking the resulting contract with this rental space delivers in tab Objects the wanted hierarchy Object Group -> Rental Space.

Don’t forget to check_all, store and commit your data of the created contract object!

P.S.: I would have expected a method in the Object Group-Interface IF_REBD_OBJECT_GROUP or an Interface in TIVBDOBJASSTYPE like IF_REBD_OBJ_ASSIGN_MNGR_BO with OBJASSTYPE = 11 which does the job!

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply