Skip to Content

Add competitors and reasons to a sales opportunity using sap DI API

I am trying to link an existing competitor and reason for an existing sales opportunity through the api but I can't find a way to do it. Any help is much appreciated!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 07, 2017 at 09:51 PM

    Hi Ines,

    You should use SalesOpportunitiesCompetition(for competitors) and SalesOpportunitiesReasons(Reasons) from SalesOpportunities object to achieve your goal.

    In this situation you keep in mind the following rules:

    1. For update information from a Sales opportunity like competitors your sales opportunity should be with Status Open.

    2. For add reasons for your Sales opportunity the Status should be sold or missed.

    3. In your scenario you should perform 2 actions.

    A sample how to accomplish:

    SalesOpportunities oOportu = oCompany.GetBusinessObject(BoObjectTypes.oSalesOpportunities);
    if (oOportu.GetByKey(38))
        //Remember, you sales opportunity should be with status Open.
        //Add competitors, check if need a new line
        if (oOportu.Competition.Competition != 0)
        //provide the competitor code
        oOportu.Competition.Competition = 1;
        if (oOportu.Update() != 0)
    oOportu = oCompany.GetBusinessObject(BoObjectTypes.oSalesOpportunities);
    if (oOportu.GetByKey(38))
        //Remember, before add reasons, your opportunity should be with status Sold or Missed
        //I got the following error, when tried change status and add reason on the same request = The resource name specified in the image file could not be found.
        //If your opportunity is with status open, perform two action on Sales opportunity, change the status, and then add your reasons.
        //Add reasons, check if need a new line
        if (oOportu.Reasons.Reason != 0)
        //provide the reason code
        oOportu.Reasons.Reason = 1;
        if (oOportu.Update() != 0)

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded