cancel
Showing results for 
Search instead for 
Did you mean: 

Di Add-on update only first line

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

Answers (0)