cancel
Showing results for 
Search instead for 
Did you mean: 

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

former_member440545
Participant
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member185682
Active Contributor
0 Kudos

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

former_member440545
Participant
0 Kudos

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


former_member185682
Active Contributor
0 Kudos

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

former_member440545
Participant
0 Kudos

Hi Sir,

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

former_member440545
Participant
0 Kudos

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 ?
former_member185682
Active Contributor
0 Kudos

Hi Manikandan,

You should use DocEntry value on GetByKey method.

Kind Regards,

Diego Lother

former_member440545
Participant
0 Kudos

Hi Sir,

Thank you , Its Working fine

Answers (0)