cancel
Showing results for 
Search instead for 
Did you mean: 

Invoice Vs Draft

Former Member
0 Kudos

I have been trying for several days to create an invoice as a draft and have not had any luck. I decided to switch gears and just try to add the invoice and once I figured out what the data was supposed to look like that I needed to pass in, I had it working in a matter of minutes. So feeling triumphant, I went back and tried the draft again using the same formatted data. It failed. One thing I noticed was when I was getting errors on the invoice is, I was actually getting error descriptions along with the error code but with the draft, all I get is the number with a - in the description field and it's always been a 5002 error.

What are the major differences between the code for invoice and draft? (I have been using the sample code from the SDK Help and modifying the data values where needed. ie. cardcode, etc.) The obvious one is that you have to specify the draft.DocObjectCode to which type of document the draft is. Is there anything else?

I'm at a loss but at least I know I can add invoices. That's a start. If anyone has any ideas or can point to a source of information, I would appreciate it.

Thanks.

Rhonda

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184566
Active Contributor
0 Kudos

Hi

I'm not sure why it is giving that error, could be several things. But what i usually do is start with the bare minimum then work my way onwards and like this you'll find out what is causing the error. Here is sample code that i made and tested, it will add a draft invoice. Very simple and basic. Should work for you as it works by me, just change BP Code and Item code.

Private Sub draft__Invoice()

Dim oInvDraft As SAPbobsCOM.Documents

oInvDraft = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts)

oInvDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oInvoices

oInvDraft.CardCode = "600672"

oInvDraft.Lines.ItemCode = "02SILVTS"

oInvDraft.Lines.Quantity = 1

oInvDraft.Lines.Price = 120

If oInvDraft.Add <> 0 Then

MsgBox(oCompany.GetLastErrorDescription)

End If

End Sub

Hope this helps

Former Member
0 Kudos

I have taken that approach as well several times to try to track down the error. I also just used the code that you posted and I still get the same error. Is there some setting in the system that needs to be set in order to save as a draft? Although, we can save drafts in the UI.

Rhonda

former_member184566
Active Contributor
0 Kudos

Hi Rhonda Bailey

The code i pasted works perfectly on my side. If it doesn't for you then there is something else that is wrong. There is no ticks/settings as far as i know, but you can limit a user in authorizations to have access to drafts. So check that, but if you are a super user that should not be a problem.

Also ensure the di api is the same version as your patch level.

Hope this helps

Former Member
0 Kudos

I figured out what the problem was although I still don't understand it. I changed

SAPbobsCOM.BoObjectTypes.oInvoices

to

SAPbobsCOM.BoObjectTypes.oPurchaseInvoices

and it worked like a charm. I knew it was something other than just the code that was wrong but since I wasn't seeing error messages, it was hard to figure out.

Thanks for you all your input and help.

Rhonda Bailey