cancel
Showing results for 
Search instead for 
Did you mean: 

Create a new Invoice

Former Member
0 Kudos

God, what do I need to create a new invoice.

I got all kind of errors.

I just want to add a new invoice. The first error I'm faced with is "-2028 Customer record not found [INV1.CogsOcrCod][line:7]"

You know I've looked in every CSharp Example to find out but I never get to something specific to what I'm doing

so I'm looking in the SDK Help Center going around by searching word by word until I see something that look like what I'm working on

This is the way I'm helping myself. But each time its a different problem, and since I'm working with SDK the documentation and all that stuff isn't helping much.

There are so many tables and so many fields in each table which lead to a missunderstanding of what I have to do specificly. ITS HARD.

I just dont know a good methodologie. Where do I go to learn all I need about SAP SDK ? Or maybe there's no way out for working with the SDK else than playing with it until you get frustrated

Thank you for your help and your patience.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Yep, I found it after a while. Its the learning curve or curse

Former Member
0 Kudos

hehe

Hey Marc

Adele's example should help you out. If you need it in C# though, give me a shout (I'm doing it all in C# 2005). I'm also very new to this and I understand exactly what you mean about finding help. I tend to keep this forum open in the background most of the day now, and I keep refreshing and reading any post that looks relevant. (Such as this one)

It may be hard now, but, you'll soon be able to find your way around the SAP SDK fairly easily. (And if you've done integration with other packages' SDKs, you'll learn that this one is lightyeards ahead of most of them!!

Good luck!

Kevin

Former Member
0 Kudos

Hi Marc,

We have all been through very frustrating times. To learn more about the SDK you can work through the training material that is available as e-learning. Here's a link to a recent post regarding this.

To post an invoice is fairly straight forward. I have never seen that error you are getting, but maybe it will help if you post your code here. Here is a basic example of how to post an invoice:

        Dim oInvoice As SAPbobsCOM.Documents
        oInvoice = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)
        oInvoice.DocDate = Date.Now
        oInvoice.CardCode = "C1000"
        'Line1
        oInvoice.Lines.ItemCode = "A1000"
        oInvoice.Lines.Quantity = 10
        'Line2
        oInvoice.Lines.Add()
        oInvoice.Lines.ItemCode = "A1001"
        oInvoice.Lines.Quantity = 20
        'Line3
        oInvoice.Lines.Add()
        oInvoice.Lines.ItemCode = "A1002
        oInvoice.Lines.Quantity = 30
        If oInvoice.Add <> 0 Then
            MessageBox.Show("Error: " & oCompany.GetLastErrorDescription)
        End If

Hope it helps,

Adele

Former Member
0 Kudos

Hi Adele,

Thank you for your help. Here's the code Which I think is similar to yours except a few lines and custom objects I did but in general its the same

//----


// Create the Invoice object

//----


SAPbobsCOM.Documents oInvoice = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);

foreach(InvoiceDetail id in Invoice.Lines)

{

//----


// This is important to make sure we put the data in the right line.

//----


oInvoice.Lines.SetCurrentLine(oInvoice.Lines.Count-1);

oInvoice.Lines.AccountCode = AccountCode;

oInvoice.Lines.ItemCode = id.ItemCode;

oInvoice.Lines.Quantity = id.Quantity;

oInvoice.Lines.ItemDescription = id.Description;

oInvoice.Lines.DiscountPercent = id.PercentDiscount;

oInvoice.Lines.Price = id.Price;

oInvoice.Lines.Add();

}

//----


// Since we added lines in the Lines collection, we save the GoodsReceipt

// when all the lines are in thus the oGoodsReceipt.Add below outside the loop

//----


int ErrCode;

string ErrMsg;

int retVal = oInvoice.Add();

//----


// If the addition returns with error, we show it in the status window

// else we list the items transfered...

//----


if(retVal != 0)

{

oCompany.GetLastError(out ErrCode, out ErrMsg);

WebUtilities.WebMessageBox.Show(ErrCode.ToString() + " " + ErrMsg);

}

else

{

WebUtilities.WebMessageBox.Show("Transfer completed...");

}

Former Member
0 Kudos

Hi Marc

Some minor differences I have in my code:

1) I use the "SetCurrentLine" method ONCE, outside of the foreach (before)

2) I use the "Add()" method of [Lines] BEFORE setting values...

3) The abovementioned "Add()" method must not get called the first time, so I basically put a little IF statement in there to avoid this.

Also, I'm not sure you should be setting the ItemDescription? (I might be wrong here, not sure)

Anyway, what is your current error you're getting?

Former Member
0 Kudos

oh wait, what is AccountCode used for? Do you not want to be setting the CardCode here? (Cardcode of a BusinessPartner)

Just a thought...

Former Member
0 Kudos

Hello.

You must choose Account Code or Item Code - one of it.

This what do You want to use is in DocType property.

Next don`t add line because one line is always added in creating invoice, so if You go to this line:

oInvoice.Lines.Add();

You are adding empty line and with this You are trying to add a document.

Hope it helps.

Regards

Kamil Wydra

Former Member
0 Kudos

This is where I'm at right now

Trying to find out the GLAccount

I dont know nothing but I have to know this number like _SYS0000... something

Why adding an invboice need this account and in which object do I find it

Oh and Thank you for your encouragement in your first post. Its good to read message like that.

I'm a new employe in a consultant box where I have to know SAP and SDK. The funny part is that I have to give results now and I'm practicly learning every steps while I'm doing it.

Former Member
0 Kudos

Hi Marc,

You can find the account codes in the OACT table. This is the ChartOfAccounts object.

Hope it helps,

Adele

Former Member
0 Kudos

Finaly. Here's my code that works

foreach(InvoiceDetail id in Invoice.Lines)

{

//oInvoice.Lines.AccountCode = AccountCode;

oInvoice.Lines.ItemCode = id.ItemCode;

oInvoice.Lines.Quantity = id.Quantity;

oInvoice.Lines.ItemDescription = id.Description;

oInvoice.Lines.DiscountPercent = id.PercentDiscount;

oInvoice.Lines.Price = id.Price;

if(!id.Equals(Invoice.Lines[Invoice.Lines.Count-1]))

{

oInvoice.Lines.Add();

oInvoice.Lines.SetCurrentLine(oInvoice.Lines.Count-1);

}

}

Now does the DiscountPercent goes in the Document lines or in the document. How to know such things. This is the kind of question I'm often facing with. There are so many fields in many tables that looks similar

Former Member
0 Kudos

Hi Marc,

You can have a discount percent on either the total document or on the lines in a document. Say you negotiate a deal with the client that he will get 10% discount off any quantity purchased of a specific item, the discount will go onto that line of the invoice. So you'll have an invoice that looks like this:

Document 0% discount
Line1 0% discount
Line2 10% discount
Line3 0% discount
Line4 0% discount

Say you negotiate a deal with the client that he will get 10% discount off any purchases made, you can set up the document like this:

Document 10% discount
Line1 0% discount
Line2 0% discount
Line3 0% discount
Line4 0% discount

This comes down to exactly the same as a 10% discount on every line:

Document 0% discount
Line1 10% discount
Line2 10% discount
Line3 10% discount
Line4 10% discount

Hope this makes sense,

Adele

Former Member
0 Kudos

I see

So if I set the discount on every lines which is my case, the total in the Document should be calculated automaticly by sap right ?

Former Member
0 Kudos

> Hi Marc,

>

> You can find the account codes in the OACT table.

> This is the ChartOfAccounts object.

>

> Hope it helps,

> Adele

I tried the ChartOfAccounts Object and the Code property returned ""

Not very helpful with an empty string like this

Former Member
0 Kudos

> I see

>

> So if I set the discount on every lines which is my

> case, the total in the Document should be calculated

> automaticly by sap right ?

Hi Marc,

No, that's not the case. You can set it as you wish (on header or lines) and SBO will keep it that way.

Hope it helps,

Adele

Former Member
0 Kudos

> I tried the ChartOfAccounts Object and the Code

> property returned ""

>

> Not very helpful with an empty string like this

When using an account code, you usually just specify the account number in your code, like:

oInvoice.Lines.AccountCode = "100000"

You use the ChartOfAccounts object to modify the chart of accounts itself, like if you want to rename the account 100000 from Capital to Assets. You don't need to ChartOfAccounts object when creating a document, just the code you want to use.

Hope it helps,

Adele

Former Member
0 Kudos

Since adding the invoice added the AccountCode automaticly I don't need to get it anymore.

This is what isn't too funy, not knowing what is automatic and what isn't

Is there a way to know such thing ?

Former Member
0 Kudos

For instence, Do I have to substract the quantity in

OITW and OITM or sap will make the adjustment itself when adding the invoice.

What exactly it does when I add the invoice via the DI API, What do I have to do and what are the actions I don't need to do

These are certainly questions many people are wondering I think.

Former Member
0 Kudos

Hi Marc,

Whatever happens automatically when you post an invoice with SAP Business One itself will happen automatically when you post same with the DI API. If your GL Account Determination is set up correctly then you won't need to specify a GL Account (in either the DI or SBO GUI).

Hope it helps,

Adele

Former Member
0 Kudos

> > I tried the ChartOfAccounts Object and the Code

> > property returned ""

> >

> > Not very helpful with an empty string like this

>

> When using an account code, you usually just specify

> the account number in your code, like:

>

oInvoice.Lines.AccountCode = "100000"

You

> use the ChartOfAccounts object to modify the chart of

> accounts itself, like if you want to rename the

> account 100000 from Capital to Assets. You don't need

> to ChartOfAccounts object when creating a document,

> just the code you want to use.

>

> Hope it helps,

> Adele

Since I have a DiscountPercent on each row. I do

oInvoice.Lines.DiscountPercent = blabla

but when I go in SAP, the DiscountPercent of each row is at 0% is that normal ?