Skip to Content
author's profile photo Former Member
Former Member

Creating A/R invoice draft

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 12, 2006 at 05:31 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.