Skip to Content
avatar image
Former Member

Di Add-on update only first line

Hello Experts,

i am trying to update the lines in a journal entry but i update only the first line. The code i am using is the following :

Dim oJournalEntry As SAPbobsCOM.JournalEntries
oJournalEntry = oCompany.GetBusinessObject(BoObjectTypes.oJournalEntries)
Dim rsGetJournal As SAPbobsCOM.Recordset 
rsGetJournal = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
rsGetJournal.DoQuery("SELECT TransID FROM OJDT WHERE TransID='" & TransId & "' ")
rsGetJournal.MoveFirst()
While rsGetJournal.EoF = False
oJournalEntry.GetByKey(rsGetJournal.Fields.Item("TransID").Value.ToString)
oJournalEntry.UserFields.Fields.Item("U_Fldnl").Value = "Y"
Dim rsGetJournalLines As SAPbobsCOM.Recordset 'base table query
rsGetJournalLines = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
rsGetJournalLines.DoQuery("SELECT * FROM JDT1 WHERE TransID='" & TransId & "' ")
rsGetJournalLines.MoveFirst()
While rsGetJournalLines.EoF = False
oJournalEntry.Lines.UserFields.Fields.Item("U_Kca").Value = "BP"
rsGetJournalLines.MoveNext()
End While
lretcode = oJournalEntry.Update
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 28, 2017 at 04:32 PM

    Hi,

    It is happening because you are not providing which line you would like to update. Here is a sample which can help you to understand it correctly:

    SAPbobsCOM.JournalEntries oJE = (SAPbobsCOM.JournalEntries)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries);
    oJE.Lines.SetCurrentLine(0);
    oJE.Lines.UserFields.Fields.Item("U_TEST").Value = "TEST";
    int Update = oJE.Update();
    

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded