cancel
Showing results for 
Search instead for 
Did you mean: 

how to create/update sales opportunities with multiple stage in sap b1 sdk through DIAPI

Former Member
0 Kudos
oFormUDF = ClsSBOAddOn.SBOApplication.Forms.GetForm("-133", 1);
                iOprqNo = Convert.ToInt32(((SAPbouiCOM.EditText)oFormUDF.Items.Item("U_OPRNO").Specific).Value.ToString());
                oSalesOpprtunities = (SAPbobsCOM.SalesOpportunities)ClsSBOAddOn.SBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSalesOpportunities);
                int iLine = 0;
               // int iRow = oMatrix.VisualRowCount;
                if (oSalesOpprtunities.GetByKey(iOprqNo) == true)
                {
                    if (iLine < oSalesOpprtunities.Lines.Count)
                    {
                        //oSalesOpprtunities.Lines.SetCurrentLine(iLine);
                        oSalesOpprtunities.Lines.MaxLocalTotal = 200;
                        string assa = oSalesOpprtunities.Lines.Count.ToString();
                        oSalesOpprtunities.Lines.SetCurrentLine(oSalesOpprtunities.Lines.Count-1);


                        //if (oSalesOpprtunities.Lines.LineNum == Convert.ToInt32(sOOPline))
                        //{
                        oSalesOpprtunities.Lines.DocumentNumber = Convert.ToInt32(oDBHeader.GetValue("DocEntry", 0));


                        iOprtStatus = oSalesOpprtunities.Update();
                        if (iOprtStatus != 0)
                        {
                            int ErrorCode = 0;
                            string ErrorMessage = "";
                            ClsSBOAddOn.SBOCompany.GetLastError(out ErrorCode, out ErrorMessage);
                            BubbleEvent = true;
                            return;
                        }
                        //break;
                        // }
                        iLine++;
                    }




                }
<br>

My Code

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mohammad,

Try this:

SAPbobsCOM.SalesOpportunities oSalesOppr = (SAPbobsCOM.SalesOpportunities)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSalesOpportunities);
oSalesOppr.GetByKey(69);
oSalesOppr.Lines.StageKey = 1;
oSalesOppr.Lines.DocumentType = SAPbobsCOM.BoAPARDocumentTypes.bodt_Order;
oSalesOppr.Lines.DocumentNumber = 369;
int Up = oSalesOppr.Update();

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Accepted Solutions (0)

Answers (2)

Answers (2)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert

Hi mohammad asharaf,

Here is how to update an existing Stage on the Sales Opportunity:

SAPbobsCOM.SalesOpportunities oSalesOppr = (SAPbobsCOM.SalesOpportunities)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSalesOpportunities);
oSalesOppr.GetByKey(69);
oSalesOppr.Lines.StageKey = 1;
oSalesOppr.Lines.StartDate = DateTime.Today.AddDays(2);
int Up = oSalesOppr.Update();

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Former Member
0 Kudos
if (oSalesOpprtunities.GetByKey(iOprqNo) == true)
{
if (iLine < oSalesOpprtunities.Lines.Count)
{


string assa = oSalesOpprtunities.Lines.Count.ToString();
oSalesOpprtunities.Lines.Add();
oSalesOpprtunities.Lines.MaxLocalTotal = 200;
oSalesOpprtunities.Lines.SetCurrentLine(2); //if (oSalesOpprtunities.Lines.LineNum == 2)
//{
oSalesOpprtunities.Lines.DocumentNumber = Convert.ToInt32(oDBHeader.GetValue("DocEntry", 0));

//}
iLine++;
}
}
Former Member
0 Kudos

I am update Document No of respected Document such like

Former Member
0 Kudos

I am add/update Document No as per document type .

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Try this:

SAPbobsCOM.SalesOpportunities oSalesOppr = (SAPbobsCOM.SalesOpportunities)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oSalesOpportunities);
oSalesOppr.GetByKey(69);
oSalesOppr.Lines.StageKey = 1;
oSalesOppr.Lines.DocumentType = SAPbobsCOM.BoAPARDocumentTypes.bodt_Order;
oSalesOppr.Lines.DocumentNumber = 369;
int Up = oSalesOppr.Update();

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Former Member
0 Kudos

i am add document no at second line then after third line .

lust like

sales order - 14

Invoice - 2

                        oSalesOpprtunities.Lines.SetCurrentLine(oSalesOpprtunities.Lines.Count - 1);
                        oSalesOpprtunities.Lines.MaxLocalTotal = 200;
                        oSalesOpprtunities.Lines.DocumentNumber = Convert.ToInt32(oDBHeader.GetValue("DocEntry", 0));
                        oSalesOpprtunities.Lines.Add();

Former Member
0 Kudos

dear Ankit Sir,

Issue is solve .thanks for help .

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi mohammad asharaf,

In that case, I would request you to tell us what did you do in order to resolve the issue.

Also it would be nice, if you can close this thread by marking the correct answer.

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Former Member
0 Kudos

also give one Error : Cannot update closed row [OPR1.Line][line: 1]