Exception on read or set UDF document lines value

Hi All,
have a big problem...
I'm creating invoice documents from many and many delivery documents via DI API.
In some cases, my addon gives an exception reading or setting UDF line fields.
Here is the exception message:
System.Runtime.InteropServices.COMException (0x80010105): The server has rise an exception. (Eccezione da HRESULT: 0x80010105(RPC_E_SERVERFAULT))
in SAPbobsCOM.FieldClass.get_Value() in Morato.CreaDocFatturazioneMassiva.CopyUDFLineFields(String)
or
System.Runtime.InteropServices.COMException (0x80010105): The server has rise an exception. (Eccezione da HRESULT: 0x80010105(RPC_E_SERVERFAULT))
in SAPbobsCOM.FieldClass.set_Value() in Morato.CreaDocFatturazioneMassiva.CopyUDFLineFields(String)
The strange thing is that if I create an invoices from a little quantity of deliveries, there is no problem. The error seems to rise when I create an invoice from a huge quantity of deliveries.
The code is:
Private Function CopyUDFLineFields(ByVal oLineNum As String) As Boolean
        Dim i As Integer
        oDocFrom.Lines.SetCurrentLine(oLineNum)
        Try
            With oDocFrom.Lines.UserFields
                For i = 0 To .Fields.Count - 1
                    Select Case .Fields.Item(i).Type
                        Case SAPbobsCOM.BoFieldTypes.db_Date
                            '// campi di tipo data
                            Select Case .Fields.Item(i).SubType
                                Case SAPbobsCOM.BoFldSubTypes.st_Time
                                    '// campi di tipo ora
                                    If Hour(.Fields.Item(i).Value) <> "0" Or Minute(.Fields.Item(i).Value) <> "0" Then
                                        oDocTo.Lines.UserFields.Fields.Item(i).Value = .Fields.Item(i).Value
                                    End If
                                Case Else
                                    If Year(oDocFrom.Lines.UserFields.Fields.Item(i).Value) <> "1899" And Year(.Fields.Item(i).Value) <> "1999" Then
                                        oDocTo.Lines.UserFields.Fields.Item(i).Value = .Fields.Item(i).Value
                                    End If
                            End Select
                        Case SAPbobsCOM.BoFieldTypes.db_Float
                            '// campi di tipo unità e totale
                            If .Fields.Item(i).SubType = SAPbobsCOM.BoFldSubTypes.st_Measurement Or .Fields.Item(i).SubType = SAPbobsCOM.BoFldSubTypes.st_Percentage Or .Fields.Item(i).SubType = SAPbobsCOM.BoFldSubTypes.st_Price Or .Fields.Item(i).SubType = SAPbobsCOM.BoFldSubTypes.st_Quantity Then
                                oDocTo.Lines.UserFields.Fields.Item(i).Value = CDbl(.Fields.Item(i).Value)
                            End If
                        Case SAPbobsCOM.BoFieldTypes.db_Alpha
                            '// campi di tipo stringa
                            If Not String.IsNullOrEmpty(oDocFrom.Lines.UserFields.Fields.Item(i).Value) Then
                                oDocTo.Lines.UserFields.Fields.Item(i).Value = .Fields.Item(i).Value.ToString
                            End If
                        Case SAPbobsCOM.BoFieldTypes.db_Numeric
                            oDocTo.Lines.UserFields.Fields.Item(i).Value = Val(.Fields.Item(i).Value)
                        Case SAPbobsCOM.BoFieldTypes.db_Memo
                            oDocTo.Lines.UserFields.Fields.Item(i).Value = .Fields.Item(i).Value.ToString
                        Case Else
                            '// altri tipi stringa
                            If Not String.IsNullOrEmpty(oDocFrom.Lines.UserFields.Fields.Item(i).Value) Then
                                oDocTo.Lines.UserFields.Fields.Item(i).Value = .Fields.Item(i).Value.ToString
                            End If
                    End Select
                Next i
            End With
            Return True
        Catch ex As Exception
            SBO_Application.MessageBox(ex.ToString & " - " & oDocFrom.Lines.UserFields.Fields.Item(i).Name.ToString)
            Return False
        End Try
    End Function
Anyone have experienced something similar?
Kind Regards,
Paolo Caricasole.
Edited by: Rui Pereira on Dec 23, 2008 4:26 PM

Please refer to note#1235603
SAP Notes: [http://service.sap.com/notes|http://service.sap.com/notes]
Replace:
oDocTo.Lines.UserFields.Fields.Item(i).Value
with:
Document_Lines oLines = oDocTo.Lines
oLines.UserFields.Fields.Item(i).Value
Regards, Yatsea

Similar Messages

  • How to read long text in Document line item

    Hi,
    How to read long text in FI Document line item.

    Use Read_text function module.
    you need to pass
    ID
    LANGUAGE
    NAME
    OBJECT   to the function moduel
    To find the Text id name language and object these are the following steps. Example: FB02
    1. goto FB02, Enter Document number
    2. from menuselect Goto>Header-->header Text..... New window will be displayed 
    3. select the Header Text. here you can see all the text. 
    4. click on the TEXT (which you want to know the Text id) , then press log ICON (you can find in bottom right of the text window) it looks like a rolled paper. 
    5. in the Next window you will find Text Name. Text ID, Language. etc...
    Regards,
    Lalit Mohan Gupta.

  • How can I set the reference line in a graph

    Hello together,
    I would like know if it is possible to set the Reference Line Value as a variable
    Example:
    "<ReferenceLine index="0" visible="true" value=variable sql-statement displayedInLegend="true"/>"
    My problem:
    I need a combined graph with a stacked area and a line for the Limit or "Reference Line".
    regards

    Sorry. I don't mean page tabs, but the order in which form fields are selected by the tab key. In simple html there is a value called tabindex and I was just wondering if there is a way to assign this order within a portal form. I have basically recreated the form with a custom layout and adjusted the table structure to force the order I was looking for, but it would be a nice add for future versions.

  • UDF in documents lines that can be Change after adding the doc.

    Dear all
    How can i create a UDF in documents lines that can be change after adding the doc? He need to mark some of the lines to already audit or not audit and the date of the action.
    Kind Regards
    Margarida

    It also depends on what documents you are wanting to add these comments to. On documents such as the A/R Invoice/ Delivery, and A/P Invoice/ Goods Receipt PO you cannot change the UDFs on the line item after the document is added (regardless of whether the document is closed). Sales Orders/ Quotes and Purchase Orders line item UDFs can be changed as long as the line hasn't been closed (or partially received/delivered/invoiced).
    Hopefully that makes sense. I could give more of an explanation if I knew what documents you were wanting to add these line item comments to.

  • Trying to close a document line but exception is thrown

    I'm trying to close a document line, that is, setting LineStatus property to 1 (wich coresponds to 'C' [closed]).
    But i receive this message from SAP: 'can't close a row of this document type' (it's a translation so the message could be slightly different), prompting that this is an error in LineStatus property.
    Any ideas?
    regards
    Edited by: Peter Petrelli on Nov 12, 2008 4:32 PM

    Hi Peter,
    The first thing to test would be if you can close the line manually in the SAP Business One application without using the AddOn.
    - If not and you get the same error it might be system behaviour depending on which form.
    - If yes, there might be a bug in the DI API which should be reported in a SAP Ticket.
    The second thing to test would be if you can close the row
    - in a different document of the same type
    - in the same document type in a different database
    Let us know of your results and more specific information which document you are using.
    Kind Regards,
    Friederike
    SAP Business One Forums Team

  • Tcode FV50: How to find long text in FI Document line item Before Saving.

    Hi,
    How to find long text in FI Document line item.
    During Parking of the FI document through Tcode FV50 i m giving the some text in the long text not in the text field.
    I would like to validate the Long Text Before Saving in user exit "U300" under  the  "Sunstitution" .
    Please anybody can be help me out where exactly this long text is going to be stored or in which internal table or memory id.
    Please give me the answer as soon as possible .
    Note:- Read_Text function module is not useful. Because Read_text useful after saving document.

    Hi Amit,
    In application area FINANCIAL ACCOUNTING , go for node LINE ITEM. Here create a step & maintain the prerequisite as per your requirement & in the check you can mention the code or you can direct it to a custom program like ZFI_RGGBR000.
    Here while maintaining the check you will get structures BKPF & BSEG in which you will get the desired field you are looking for.
    Just try to explore in your system how the other validations are maintained.
    After you are done with all your code, you have to run the regeneration program RGUGBR00.
    Here utmost care should be taken while running regeneration program, you should select all the checkboxes in the selection screen except  GENERATE SETS, GEN SUBSTN ROUTNS IN ALL CLNTS  & TRACE PROG. GENERATE CALLS .
    Hope this make your doubt clear.
    Regards
    Abhii

  • PO item text is copied to the Financial Document line item text

    A user have requested that the PO item text is copied to the Financial
    document line item text, to aid them in analysis of the GR/IR account.
    is there any solution to implement this ?

    There is no standard setting for this requirement. Check with your ABAP team for this.

  • How to define a document line as Withholding Tax Liable?

    Hi,
    Does anyone knows how to manipulate the Withholding Tax liable property in a document line?
    The property "WTLiable" in the Document_Lines object is a read property. So i can't set a value to this field via DI API.
    I'm working with SBO version 2004.
    Kind Regards,
    Ivan

    Luis:
    Thats because you cannot change the WTLiable status in the SBO either.
    To set the Withholding tax, you must change it in the Business Partner master data.
    Harold Gómez V.

  • Deleting Document Line in 2005 SP1

    When attempting to delete a Purchase Order line using the Delete method of the document_lines object generates the following error after the Update method of the Document object is called:  "Invalid valid value in Enum 'BoTaxTypes'"
    The documentation states that Delete returns a value indicating success but actually no value is returned.  I've tried using the delete method without calling update but then nothing on the document changes. 
    The documentation doen't include any instructions on using the delete method so I'm not sure what other steps are necessary to get it to work.  Does anyone out there have any suggestions on how to get this to work properly?

    Thanks to all who have responded.  I have finally received a resolution from development support on this.  They have confirmed the problem and have promised a fix in the Nov 2006 patch release.  In the interim, they have provided me the following workaround:
    Dear Mr. Joe Huffman
    From the information provided in the message I understand that you're
    working with patch level 4.
    I would recommand you NOT to upgrade to patch level 7 since there is a
    regression in this patch and the lines.delete method doesn't work at
    all in this version (6.8.317.7) with no work around!
    We will fix both bugs (the bug you've reported on and the regression
    in November patch.
    Working with patch level 4 (6.8.317.4) I've noticed that from some
    reason in your DB - After the GetByKey method the TaxType field value
    is changed from tt_NO to tt_YES.
    I have a work around which you can use only in case that you can
    set the TaxType field value to tt_NO.
    If it is possible to you than you can use the following code for
    changing the value for tt_YES to tt_NO:
    'Work around - Fix TaxType value
    For iIndex = 0 To TotalRowCount - 1
    oPO.Lines.SetCurrentLine (iIndex)
    oPO.Lines.TaxType = tt_No
    Next iIndex
    RetVal = oPO.Update
    and only after running this code I delete the wanted line:
    oPO.Lines.SetCurrentLine (0)
    oPO.Lines.Delete
    RetVal = oPO.Update
    I hope that this work around will be suitable for you.
    I'm sorry for the inconvenient.

  • Missing object in document lines

    Hi to all,
    I want to create a draft document (type invoice) based on an order document. Now I have the problem, that I can't find an object in the document lines, representing the field 'Text' in RDR1, so how to take over the value of this field to the target document. Any ideas?
    I'm using DI API Version 2004
    Kind regards
    Eduard

    OK, now I understand.
    The thext field you are talking about is not stored in the RDR1 table, it is stored in the RDR10. And the line type should be set to Text. This text lines gives you that possibility.
    I havent tryed to use them using DI API, and a fast search in the help file doesnt give me any info about it.
    Perhaps you could try it with the Recordset object.
    Sorry,
    Ibai Peñ

  • Read to get the last line from a File

    Hi
    I am sending in a clarification , hoping that I get an efficient solution from the group, should somebody have come across this scenario and implemented.
    How to read or get the last line from a text file , which usually have a no of records, without actually reading or looping through all the lines
    I know there is some solution with the RandomAccessFile, but given there can be some encoding issues or so.
    Please let me know if somebody have implemented the same.
    Thanks n advance

    The character encoding could, indeed, be an issue especially with UTF-8. I think what I'd do is to create a byte array with the encoded, expected end of line sequence in it and work on the file in bytes. For example, seek to the last 100 bytes of the file, read those bytes and look for an EOL sequence backwards. If not found read the previous 100, 200, 400 bytes etc. until you do find an end of line. Then seek to after the EOL and read normally. Remember an EOL sequence might cross a boundary.
    UTF-8 would be a problem, especially with a unix format file because you might mistake part of a multi-byte sequence for '\n'. To be reliable on UTF-8 you'd need to go back three characters looking for sequence start markers (has the previous character got the top bit set, or the one before that the first two bits set, or the one before that the top three bits). Or you could just react to an encoding exception and try another position.

  • How to implement one to many relationship between two Document Line Table

    Hi,
    I want to implement the following relationship into user defined tables:
    Example Situation:
    There are tables A, B and C.
    For one record of Table A, there could be multiple records in table B.
    For one record of Table B, there could be multiple records in table C.
    i.e. A(1) -> B(n) [One to many relationship]
         B(1) -> C(n) [One to many relationship]
    finally: A(1) -> B(n) -> C(n)
    How can I achieve this? If I make Table A as Document and table B & C as Document Line and then make them UDO, will it work? Kindly suggest me a solution.
    Regards,
    Sudeshna.

    Hi,
    I think that the database representation is exactly what you ask for. 3 tables, A, B, C. A should have a UDF that is linked to B table, and B should have a UDF that is linked to C table.
    You should manage the database transactions, and the UI to support all this stuff.
    Regards,
    IBai Peñ

  • Document line item text in Clearing document

    Dear All,
    Document line item text
    My client want the vendor invoice line item text(BSIK-SGTXT) to be captured in the corresponding clearing document line item text field(BSAK-SGTXT).
    (i.e) The vendor invoice and its payment clearing document should have the same text in the document line item text filed.
    According to me i can use  a substition rule and a user exit to assign the values. but here comes a problem* i have one clearing document against 3 to 4 vendor invoice documents* so my programming logic has got stucked here? like which vendor invoice line item text the clearing document should pick up?
    is there any other enhancements possible or can some one help me with the programming logic to be applied here.
    Thank you
    Regards,
    Vasanth D

    like which vendor invoice line item text the clearing document should pick up?
    is there any other enhancements possible or can some one help me with the programming logic to be applied here
    Why don't you discuss the issue with your client?  As you said, if you pay 5 invoices in a single run, the payment document item text can't carry all of those texts unless you use the long text.  What is the reason for the requirement?  Perhaps there's another solution.

  • How to Use document.Lines.SetCurrentLine

    Hi there, due to an enormous amount of time spent on this issue, I thought I would share how to use the SetCurrentLine method as posted to me by SAP support:
    It seems very cumbersome, as I have now to do an extra Recorset look up to get all the lines if I want to get the correct index - but at least it works (hopefully).
    Daniel
    SUPPORTS MESSAGE ****
    the way the SetCurrentLine works is as following:
    You do not have to use neither the LineNum nor the VisOrder as your
    parameterfor the setCurrentLine method.
    The system will use the corresponding index (starting at zero)linked to
    that line when running a query on the database and sorting the lines by
    LineNum.
    #,,DocEntry,, Item ,,LineNum,,Price,,VisOrder
    1,,11669,, A1001,,,, 600,00,,
    2,,11669,, A1003,,2,, 3,00,, 2
    3,,11669,, A1005,,3,, 600,00,,1
    See example above, that is the result of querying the database on that
    sales order and sorting by LineNum.
    The order in which the items are displayed in the application is based
    on the VisOrder. In this example items are displayed A1001, A1005 amd
    A1003.
    In order to update Item A1005 I will need to create a recordset, query
    the database and then loop the recordset to find the corresponding item
    and then use that index from the recordset to set the value for the
    SetCurrentLine method. In the example above index 0 from recordset
    points at item A1001, index 1 points at item A1003 and index 2 points at
    A1005 so your code should use setCurrentLine(2) to update item A1005.
    If you try to use LineNum (3 in this case) you will get an error message
    as index 3 does not exist in the recordset collection ( only 3 items
    with indexes 0,1 and 2). If you use visOrder 1(for item A1005) then the
    system will update item A1003 as 1 is the index for A1003 in the
    recordset.
    END OF SUPPORTS MESSAGE ********

    Hi Curtis,
    Your situation sounds a little different to mine, in that I know the LinNum of the documentline that I need to update - that is what the lineNumber variable is...
    To update all the rows, I guess you would just iterate through all the lines sequencially (ie starting at 0 and ending at document.lines.count:
    for(int i = 0; i < doc.Lines.Count; i++)
        doc.Lines.SetCurrentLine(i);
        // do your thing here...
    How do you know what lines you want to update??
    Dan

  • Document line with price zero in SBO 2007 A

    Hi All
    We have a DI API AddOn that occationally has to create a document line with the total price of zero.
    In SBO 2005 A we just set SBODocument.Lines.Price = 0, but that doesn't work in SBO 2007 A.
    In 2007A when we set SBODocument.Lines.Price = 0 it takes the price from the pricelist as though we had not entered a price at all. If we set SBODocument.Lines.Price to something else that zero it does correctly take the price we entered.
    We have tried to set SBODocument.Lines.UnitPrice or SBODocument.Lines.LineTotal to zero in stead but it gives the same result.
    Any help appriciated.
    Rgds
    Jesper Carstensen

    Sorry, my mistake.
    The solution WAS indeed to set SBODocument.Lines.UnitPrice = 0
    Rgds
    Jesper Carstensen

Maybe you are looking for

  • Text determination process in the Delivery Header and item

    Hi Exsperts Please help me to know step wise process of comfiguring the text detremination at the delivery and Item level I have a one scenario The text process was already determined in the Quality  server     it was a correct configuration , but on

  • $ used in variable

    hai gurus what is the use of $ symbol in variable name. thanks sitaram form f_spell_amount using    p_value                     changing p_words.   data: $v_unpack(13) type c,         begin of $i_comp occurs 0,           text(10)    type c,         e

  • HT201363 i have a problem in activating my iphone

    my dad lost his iphone then he deactivated it then few days ha found it but there were a big problem he forgot his apple id account and password and every thing (as he was makeing a passcode b and forgot it so i restore the iphone)i couldnt open it n

  • Logging in a Page Flow

    What are the best practices and recommended method for logging in a page flow? Thanks Girish

  • On my mouse when I scroll up it goes down and vice versa?

    I just updated my mac and now on my mouse (which was fine before) when i scroll up it goes down and when i scroll down it goes up?