Skip to Content
0

How to update a sale order and allocating a serial number against the same sale order using DI API?

Sep 29, 2017 at 10:16 AM

227

avatar image
Former Member

Hi Experts,

I already Created one sale order with 10 quantity and I allocated the 5 serial number against the sale order in sap screen

Now I need to add a Another 5 serial number to the same sale order using DI API method

How t o I achieve this using DI API?


Please help me to solve.

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

1 Answer

Best Answer
DIEGO LOTHER Sep 29, 2017 at 11:54 AM
0

Hi Manikandan,

A sample:

Documents oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
if (oDoc.GetByKey(190))
{
    for (int i = 0; i < oDoc.Lines.Count; i++)
    {
        oDoc.Lines.SetCurrentLine(i);
        if (oDoc.Lines.ItemCode.Equals("the item code that I want update"))
        {
            if (!string.IsNullOrEmpty(oDoc.Lines.SerialNumbers.InternalSerialNumber))
                oDoc.Lines.SerialNumbers.Add();


            oDoc.Lines.SerialNumbers.InternalSerialNumber = "OSRN.DistNumber";
            oDoc.Lines.SerialNumbers.SystemSerialNumber = "OSRN.SysNumber";
            oDoc.Lines.SerialNumbers.Quantity = 1;
        }
    }


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

Hope it helps.

Kind Regards,

Diego Lother

Show 6 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thank you for Reply Sir

I did the above coding But its not working to my requirement.Actually I am not using a loop.But I am Giving Setcurrentline(0). its adds the first serial number to database.

My issue is "when I try to add Another serial number First one is changed from allocated to available"


What is the Difference between this two lines

oDoc.lines.serialnumbers.setcurrentline(linenum)-- which linenum will be given here?

oDoc.lines.setcurrentline(linenum)--which linenum will be given here?

Thanks Advance


0

Hi Manikandan,

How you said, you need add 5 more serialnumbers.

When you add is not necessary to setCurrentLine for serialNumbers. The currentLine of Item is the index of the item that you want add more serialNumbers.

This line:

oDoc.lines.serialnumbers.setcurrentline(linenum)-- which linenum will be given here?

Sets the cursor for a specific line in your collection of serialnumber. How you want add, more serial numbers this is not necessary, if you want edit an associated serial number, then you need first call the line below and then changes the informations of your serial number.

This line:

oDoc.lines.setcurrentline(linenum)--which linenum will be given here?

Sets the cursor for a specific line in your collection of itens in your document.

In my sample you will walk through the itens in the document and check if the current line is the line of the item that you want edit(adds more serial numbers).

Remember, the sample above shows how to add serialnumber to your document. You can modify to fit your purpose.

Hope its clear.

Kind Regards,

Diego Lother

0
Former Member

Hi Sir,

Thank you for linenum explanation. it's very useful to me.

0
Former Member

Hi Sir,

Above coding only update the Primary entries. If I put the manual entry in sale order, the above coding is not work for that.

Documents oDoc = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);

if(oDoc.GetByKey(190))

My doubt is Getbykey mentions docentry or Docnum ?
0

Hi Manikandan,

You should use DocEntry value on GetByKey method.

Kind Regards,

Diego Lother

0
Former Member
DIEGO LOTHER

Hi Sir,

Thank you , Its Working fine

0