on 09-11-2006 11:54 PM
Hi all,
I got this working for creating A/P invoice drafts but now I am having difficulty creating a A/ R Invoice draft. I keep getting an error message.
"ClassFactory cannot supply requested class"
Here is my code.
if (vCompany.Connect() == 0)
{
SAPbobsCOM.Documents oInvDraft = new SAPbobsCOM.Documents();
oInvDraft = (SAPbobsCOM.Documents)vCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
oInvDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oInvoices;
oInvDraft.DocType = BoDocumentTypes.dDocument_Items;
oInvDraft.CardCode = sSAPCardCode;
oInvDraft.NumAtCard = sRefNo;
oInvDraft.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;
oInvDraft.PaymentGroupCode = -1;
oInvDraft.DocDate = DateTime.Now;
oInvDraft.DocTotal = FormTotal;
oInvDraft.Lines.AccountCode = rReaderLI.GetString(iProdID);
oInvDraft.Lines.Quantity = 1;
oInvDraft.Lines.TaxCode = "exempt";
oInvDraft.Lines.Price = double.Parse(rReaderLI.GetString(iSalePrice));
oInvDraft.Lines.ItemDescription = rReaderLI.GetString(iProd);
oInvDraft.Lines.Add();
}
RetVal = oInvDraft.Add();
}
Anyone have any ideas?
Thanks, Rhonda
Hi, Rhonda!
I suppose the reason is in incorrect adding new lines in a document. The first line doesn't have to be added using "Add" method.
It's the sample from DI help:
'----
vInvoice.Lines.ItemCode = "A00023"
vInvoice.Lines.ItemDescription = "Banana"
vInvoice.Lines.PriceAfterVAT = 2.36
vInvoice.Lines.Quantity = 50
vInvoice.Lines.Currency = "Eur"
vInvoice.Lines.DiscountPercent = 10
'Invoice Lines - Set values to the second line
vInvoice.Lines.Add
vInvoice.Lines.ItemCode = " A00033"
vInvoice.Lines.ItemDescription = "Orange"
vInvoice.Lines.PriceAfterVAT = 118
vInvoice.Lines.Quantity = 1
vInvoice.Lines.Currency = "Eur"
vInvoice.Lines.DiscountPercent = 10
'----
Just use the condition to determine whether it is the 1st line or not...
HTH,
Alexey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Nope. Still getting the same error.
ClassFactory cannot supply requested class
What's weird is the code works when creating an A/P invoice. So if I change
oInvDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oInvoices;
to
oInvDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oPurchaseInvoices;
it works.
I think the error message is odd.
Rhonda
Rhonda, in this part:
SAPbobsCOM.Documents oInvDraft = new SAPbobsCOM.Documents();
oInvDraft = (SAPbobsCOM.Documents)vCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
you initialize oInvDraft object, but you don't have to use <b>new</b> operator to declare a "Documents" object.
Method <b>GetBusinessObject</b> does this.
I've faced the same error in this part.
Have a try like that:
SAPbobsCOM.Documents oInvDraft;
oInvDraft = (SAPbobsCOM.Documents)vCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
But when trying to Add a Draft, you can get new errors, because of incomplete declaring Document properties... (For example, "2028" error i've got, because i didn't define oInvDraft.Series property)...
Regards,
Alexey
Actually I didn't realize it because the connection was working on another application I didn't consider it could be that but it's actually happening here.
SAPbobsCOM.Company vCompany = new SAPbobsCOM.CompanyClass();
string sDB = "testSCNA";
vCompany.Server = "SERVER";
vCompany.CompanyDB = sDB;
vCompany.UserName = "Me";
vCompany.Password = "12345";
vCompany.DbUserName = "user";
vCompany.DbPassword = "password";
if(!vCompany.Connected) {
if(vCompany.Connect() != 0) {
//show error code
}
else {
//I removed the invoice create.
}
The difference is this app is written in C# and the other one was VB.net. Everything else is the same.
Rhonda
Well I now am able to add Invoice drafts (thanks for everyone's suggestions) but I have another question that is driving me crazy. (Why is everything so difficult? I almost feel like SAP wants to keep us in the dark.)
Anyway, the line items include the following:
ItemNo
Item Detail
Free Text
Begin Date
End Date
Quantity
Price after discount
Taxcode
Total
GL Account
How the heck do I add Item Detail, Begin Date and End Date? I'm guessing that Item Detail is some sort of lookup based on the item code.
Some sample code would be most helpful.
Thanks,
Rhonda
User | Count |
---|---|
88 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.