Skip to Content
author's profile photo Former Member
Former Member

Replace Item Line with a special Text line

Hello:

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.Lines.SetCurrentLine(linenum2);
                            Global.oDoc.Lines.Delete();
                            //Global.oDoc.SpecialLines.Add();
                            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;
                            Global.oDoc.SpecialLines.Add();
                            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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Apr 22, 2011 at 03:01 PM

    I think I got this solved, need to add the special line and then set the current lines before specify the current line details.

    f (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.Lines.SetCurrentLine(linenum2);
                                Global.oDoc.Lines.Delete();
                                Global.orecord2.DoQuery("select count(*) as 'count' from qut10 where docentry = " + Docentry);
                                Global.oDoc.SpecialLines.Add();
                                Global.oDoc.SpecialLines.SetCurrentLine(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;
                                }
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.