cancel
Showing results for 
Search instead for 
Did you mean: 

JournaVouchers doesn't works!

Former Member
0 Kudos
87

I do this:

If (BoJV Is Nothing) Then

Set BoJV = Company.GetBusinessObject(oJournalVouchers)

End If

With BoJV.JournalEntries

.SetCurrentLine (0)

.Lines.Add

.Lines.AccountCode = "61200001"

Calculos

.Lines.Debit = Debito

.Lines.Add

.Lines.AccountCode = AccountCode

.Lines.Credit = Credito

.Lines.Add

Res=.Add

End With

When doing .Add, variable Res get the value=0, but when i go to see the results in SAP, no new journal vouchers are created. Where can be the problem? I've read that journalvocheurs.JournalEntries.lines.ShortName is a mandatory field, but i don't know where to get this value and if it can be the problem, but SAP doesn't gives me any error, the result of add is OK(0) and i don't use this suppossed mandatory field.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

barend_morkel2
Active Contributor
0 Kudos

Hi Natalia,

1.If the vouchers are not added - SBO will return a n error code. You can "catch" by using Company.GetLastError (if the error code returned after the .Add function call is not = 0).

2. Try this:

- Don't set the current line when you are adding (by default SBO does it for you).

-use the lines .Add function only after the 1st journal line e.g.

If (BoJV Is Nothing) Then

Set BoJV = Company.GetBusinessObject(oJournalVouchers)

ELSE

Set BoJV = nothing

Set BoJV = Company.GetBusinessObject(oJournalVouchers)

End If

With BoJV.JournalEntries

.Lines.AccountCode = "61200001"

Calculos

.Lines.Debit = Debito

.Lines.Add

.Lines.AccountCode = AccountCode

.Lines.Credit = Credito

Res=.Add

Answers (1)

Answers (1)

AlexGrebennikov
Active Contributor
0 Kudos

Hi Nata!

hope that thread will help you (it's about JournalEntries, but add-mechanizm is similar):