cancel
Showing results for 
Search instead for 
Did you mean: 

Adding partners in runtime

Former Member
0 Kudos

Hi Experts,

Im trying to change/add the partners in the runtime in WebClient, i could get the global controller's BTAdminH binded to my components context node, from there i could get the reference of BTPartnerSet using get_related_entity. Can anyone please tell me how to proceed to add/delete a partner .

Thanks,

Karthik

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can achieve this by Creating a Relation BTPartnerAll for the BTPartnerSet using the method

lr_entity = lr_btpartnerset->create_related_entity( iv_relation_name = BTPartnerAll ).

and set whatever attributes you want.

But before proceeding you can look in the BOL Browser for any One Order document that has partners and check how the relation are maintained.

For removing using use REMOVE or DELETE methods in IF_BOL_BO_COL or CL_BSP_WD_COLLECTION_WRAPPER.

(Please check some other threads I have answered on filtering the entities).

Most methods are in cl_crm_bol_entity and if_bol_bo_property_access.

Regards,

Masood Imrani S,

Former Member
0 Kudos

Hi Masood,

Thanks for the reply. I got the related entity BTPartnerAll, but that is of type CL_CRM_BOL_ENTITY. Can you please tell me how to get the refrence to the collection_wrapper to get the ADD/DELETE methods.

Thanks,

Karthik

Former Member
0 Kudos

Hi,

This is a code snippet to use DELETE or REMOVE methods in IMPL class.

lr_btadminh ?= me->typed_context->btadminh->collection_wrapper->get_first( ).

* Loop on the collection

WHILE lr_btadminh IS BOUND.

lr_btadminh->get_properties( IMPORTING es_attributes = ls_item ).

IF ls_item-partner = xxx

lr_btadminh->delete( ).

          • IF REMOVE IS REQUIRED, THIS IS THE WAY*

me->typed_context->btadminh->collection_wrapper->remove( lr_btadminh ).

****SIMLARLY ADD METHOD

me->typed_context->btadminh->collection_wrapper->add( lr_btadminh ).

ENDIF.

lr_btadminh = me->typed_context->targetgroupitem->collection_wrapper->get_next( ).

ENDWHILE.

(Check the parameters of the methods to get the type references)

lr_btadminh type ref to cl_crm_bol_entity.

Former Member
0 Kudos

Hi Masood,

Thanks for your reply. I am able to add the btpartners dynamically. As i add the parameter i am albe to see it on the screen as well, but when i try to delete the partners, it is getting deleted from the collection but it is not reflecting back on the screen. Im sure that it is geting removed from the collection because , when i try to save the transaction it gives a CL_CRM_BOL_CORE exception of "Accessing deleted entity".


lr_partnerset ?= ztyped_context->btpartnerset->collection_wrapper->get_current( ).
lr_partnerset_wrapper ?= ztyped_context->btpartnerset->collection_wrapper.

if lr_partnerset_wrapper is bound.

      lr_director = lr_partnerset->create_related_entity( 'BTPartnerAll' ).
      lr_director->set_property(
                  iv_attr_name = 'PARTNER_FCT'
                  iv_value     = 'ZZZ00071' ).

      lr_director->set_property(
            iv_attr_name = 'PARTNER_NO'
            iv_value     = '130003316' ).

      lr_partnerset_wrapper->add( lr_director ) .

     current ?= lr_partnerset_wrapper->get_first( ).
     lr_partnerset_wrapper->remove( current ).
     current->delete( ).

endif.

Can you please let me know how can changes can be reflected back on the screen.

Thanks,

Karthik

Former Member
0 Kudos

Hi Karthik,

I had a similar requirement earlier. So I used DELTE method and it was reflecting in screen back.

But I faced a similar issue and was getting exception like 'access deleted entity'. So I debugged and found that the standard code was reading the collection using the REREAD method and was causing the exception. So I move my code to a place after the execution of standard code. I used DO_HANDLE_DATA method to implement my logic and it worked fine later.

Also, if yours is a table view try using Iterator.

Regards,

Masood Imrani S.

Former Member
0 Kudos

Karthik,

I was looking at your code.

> lr_partnerset_wrapper->remove( current ).

> current->delete( ).

You are not using both remove and delete at a time right ?

I believe this was just for reference. You need to to use either DELETE or REMOVE not both.

Former Member
0 Kudos

Hi Masood,

I also tried using only one function , which did not work. Actually in my senario, the event which triggers the removal/addition is in COMP1 and the Partners which is ICCMP_BTPAARTNER is a different component. In ICCMP_BT_PARTNER the code is written to manually delete the entry from the table. Im unable to get any kind of reference to the table from mt COMP1.

Thanks,

Karthik

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Experts,

I have the Partner Collection, im not sure how to create an entity of BP to add into the collection. .

I have to add multiple bp's into the collection. Can any one let me know how can i accomplish this.

Thanks,

Karthik

Former Member
0 Kudos


lr_current = lr_btpartner_set->create_related_entity( 'BTPartnerAll' ).
          lr_current->set_property(
                   iv_attr_name = 'PARTNER_FCT'
                   iv_value     = 'Z0000053' ).
          lr_current->set_property(
             iv_attr_name = 'PARTNER_NO'
             iv_value     = ls_org_details-p_owner-partner ).
          lr_btpartner_all->add( lr_current ).

Any number of entities can be created using BTParterAll , since BTPartnerSet : BTPartnerAll relation is 1:N .

This solved my problem