Skip to Content
0

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

Nov 03, 2017 at 05:41 PM

80

avatar image

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!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
DIEGO LOTHER Nov 07, 2017 at 09:51 PM
0

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)
        oOportu.Competition.Add();


    //provide the competitor code
    oOportu.Competition.Competition = 1;


    if (oOportu.Update() != 0)
        MessageBox.Show(oCompany.GetLastErrorDescription());
}


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)
        oOportu.Reasons.Add();


    //provide the reason code
    oOportu.Reasons.Reason = 1;


    if (oOportu.Update() != 0)
        MessageBox.Show(oCompany.GetLastErrorDescription());
}

Hope it helps.

Kind Regards,

Diego Lother

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you very much! It worked just fine!

0