Skip to Content
0

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

May 05, 2017 at 06:56 AM

73

avatar image
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

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

2 Answers

mohammad asharaf May 05, 2017 at 05:35 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
ANKIT CHAUHAN
May 05, 2017 at 10:03 AM
0

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

Show 7 Share
10 |10000 characters needed characters left characters exceeded
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++;
}
}
0

I am update Document No of respected Document such like

opr1-docement.jpg (51.9 kB)
0

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

0

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

0

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();

0

dear Ankit Sir,

Issue is solve .thanks for help .

0

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

0