Skip to Content
Former Member
Apr 22, 2011 at 01:04 AM

Replace Item Line with a special Text line



Need this done as soon as possible. Here is the logic.

So get the document.

and set the line, delete the line

and add a special line with some text.

Whole thing seems pretty simple. If there are already one line of text line there it will not add another one. I don't know why. Any ideas?

For example.

if I have line 0 and LIne 1. Both of which I need to replace.

When the code go through the first time, It is correct. Line 0 is not a text line.

Next go through. However. Line 1 is now deleted, but so is the line text from line 0 instead it is been replaced by LIne 1's text.

Same thing if it is multiple lines.

When it create a new text line it seems always somehow delete the previous text line.

                            if (Global.oDoc.GetByKey(Docentry) != true)
                                Global.ocompany.GetLastError(out errcode, out errtext);
                                return false;
                            Global.orecord2.DoQuery("select count(*) as 'count' from qut1 where docentry = "+Docentry +" and linenum < "+linenum);
                            linenum2 = System.Convert.ToInt16(Global.orecord2.Fields.Item("count").Value.ToString());
                            Global.oDoc.SpecialLines.LineType = SAPbobsCOM.BoDocSpecialLineType.dslt_Text;
                            Global.oDoc.SpecialLines.LineText = "Line: " + linenum + " Itemcode : " + itemcode.ToString() + " Quantity(" + quantity + ")/Price(" + price + ") Was Removed Because " + message.ToString();
                            Global.oDoc.SpecialLines.AfterLineNumber = linenum2 - 1;
                            if (Global.oDoc.Update() != 0)
                                Global.ocompany.GetLastError(out errcode, out errtext);
                                errtext = "Can Not Add Text Line " + errtext;
                                return false;

Edited by: Bo Peng on Apr 22, 2011 3:05 AM