on 09-29-2017 11:16 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
User | Count |
---|---|
92 | |
11 | |
9 | |
5 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.