Skip to Content
avatar image
Former Member

Programmatically writing Involved Parties in ABSL Code

Hi Community,

we are focusing on the task of writing dinamically new Involved Parties in the ABSL Code for an Opportunity document (namespace: http://sap.com/xi/AP/CRM/Global), in a Sales Scenario. The Party Role has been correctly defined in the Business Configuration (custom code: ZSALES0100) and in the Involved Parties Configuration for the Opportunities. If we try to add manually (via UI) the Partner to the Involved Parties of an open Opportunity, that works fine.

Our question is then how to achieve the same result dinamically in the ABSL Code. For this purpose, we tried the following code:

var opportunity:BusinessObject::Opportunity;

var refOrgParty:BusinessObject::Opportunity.Party;

var elOppParty:elementsof opportunity.Party;


opportunity = Opportunity.Retrieve(this.OpportunityID);


if (bp.IsSet()) {

       elOppParty.RoleCode = "ZSALES0100";

       refOrgParty = opportunity.Party.Create(elOppParty);

       refOrgParty.Party.BusinessPartner.InternalID = bp.InternalID;

  }

but unfortunately that code leads to an exception, because the node refOrgParty.Party.BusinessPartner seems to be null. Nevertheless, we are not even able to write in the same node, because seems to be also Read Only.

Do you have any hint on how to get the desired result? It has been correct to consume the object refOrgParty?

Thanks a lot for your support.

Cheers,

Davide

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 14, 2015 at 09:04 AM

    Hi Luca,

    Try this:

    var opportunity:BusinessObject::Opportunity;

    var refOrgParty:BusinessObject::Opportunity.Party;

    var elOppParty:elementsof opportunity.Party;


    opportunity = Opportunity.Retrieve(this.OpportunityID);


    if (bp.IsSet()) {

           elOppParty.RoleCode = "ZSALES0100";

           elOppParty.PartyKey.PartyID.content = bp.InternalID;

           refOrgParty = opportunity.Party.Create(elOppParty); 

      }
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 14, 2015 at 08:57 AM

    I assume you are working in C4C, right?


    I do not have C4C so I can't give you a definite answer.


    However, in ByDesign you need to set the Party Key's ID to the Business Partner's ID.


    We successfully use code like the following in ByDesign (for service order parties, not for opportunity parties though):


    var elServiceOrder_Party : elementsof ServiceOrder.Party;

    elServiceOrder_Party.PartyKey.PartyID = templateParty.PartyID;

    elServiceOrder_Party.RoleCode = templateParty.RoleCode;

    serviceOrder.Party.Create(elServiceOrder_Party);

    Hope this helps,

    Greetings,

    Ludger Bünger

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Ludger,

      yes, it is a C4C tennant. I can say that the procedure worked in the same way in C4C.

      The only difference I spot is probably that we accessed to the member field PartyID.content, in order to access to a write-enabled field. Thank you for your support.

      Cheers,

      Davide