8.8 Invoice based on Order

Hi all,
I am trying to create an invoice based on a sales order.
I have this code which worked fine in SBO 2007 but now in 8.8 I get -2010 : Internal error
oDoc = (SAPbobsCOM.Documents) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
oDoc.CardCode = sCardcode;
oDoc.Lines.BaseType = 17;
oDoc.Lines.BaseEntry = int.Parse(docentry);
oDoc.Lines.BaseLine = 0;
Can anyone help me with this?
Thanks

Hi Gordon,
It is a variable, but that is not the issue I think.
But just in case: here is the complete code
oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
try
     SAPbobsCOM.Documents oDoc = (SAPbobsCOM.Documents) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
     Matrix matrix = Matrix.GetFromUID(pVal.Form, "10");
     int rowcount = matrix.Rows.Count;
     string prev_docnum = "";
     string docnum = "";
     string docentry = "";
     string cardcode = "";
     int retval = 0;
     for(int i = 0;i <= rowcount-1;i++)
          docnum = matrix.GetValue("11", i);
          cardcode = matrix.GetValue("10", i);
          string regel = matrix.GetValue("12", i);
          string itemcode = matrix.GetValue("8", i);
          if(prev_docnum != docnum)
               if(prev_docnum != "")
                    retval = oDoc.Add();
                    if(retval != 0)
                         int errcode;
                         string errmsg;
                         oCompany.GetLastError(out errcode, out errmsg);
                         StatusBar.WriteError(String.Format("Fout bij verkooporder {0} - {1}: [{2}] {3}",
                              docnum,
                              cardcode,
                              errcode.ToString(),
                              errmsg));
                    else
                         string newdoc;
                         oCompany.GetNewObjectCode(out newdoc);
                         SAPbobsCOM.Recordset oRs = (SAPbobsCOM.Recordset) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                         try
                              oRs.DoQuery(String.Format("SELECT DocNum, convert(varchar(8),DocDate,112), CardName FROM OINV WHERE DocEntry = '{0}'", newdoc));
                              StatusBar.WriteSucess(String.Format("Nieuwe factuur aangemaakt: {0} - {1}",
                                   oRs.Fields.Item(0).Value.ToString(),
                                   oRs.Fields.Item(2).Value.ToString()));
                         finally
                              System.Runtime.InteropServices.Marshal.ReleaseComObject(oRs);
                              oRs = null;
                              GC.Collect();
                    oDoc = null;
                    oDoc = (SAPbobsCOM.Documents) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
               // GET DOCENTRY
               SAPbobsCOM.Recordset oRsDoc = (SAPbobsCOM.Recordset) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
               try
                    oRsDoc.DoQuery(String.Format("SELECT DocEntry FROM ORDR WHERE DocNum = '{0}'", docnum));
                    docentry = oRsDoc.Fields.Item(0).Value.ToString();
               finally
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oRsDoc);
                    oRsDoc = null;
                    GC.Collect();
               oDoc.CardCode = cardcode;
               oDoc.DocDate = DateTime.Now;
          oDoc.Lines.BaseType = 17;
          oDoc.Lines.BaseEntry = int.Parse(docentry);
          oDoc.Lines.BaseLine = int.Parse(regel) - 1;
          oDoc.Lines.Add();
          oDoc.Lines.SetCurrentLine(int.Parse(regel) - 1);
          prev_docnum = docnum;
     // ADD LAST INVOICE
     retval = oDoc.Add();
     if(retval != 0)
          int errcode;
          string errmsg;
          oCompany.GetLastError(out errcode, out errmsg);
          StatusBar.WriteError(String.Format("Fout bij verkooporder {0} - {1}: [{2}] {3}",
               docnum,
               cardcode,
               errcode.ToString(),
               errmsg));
     else
          string newdoc;
          oCompany.GetNewObjectCode(out newdoc);
          SAPbobsCOM.Recordset oRs = (SAPbobsCOM.Recordset) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
          try
               oRs.DoQuery(String.Format("SELECT DocNum, convert(varchar(8),DocDate,112), CardName FROM OINV WHERE DocEntry = '{0}'", newdoc));
               StatusBar.WriteSucess(String.Format("Nieuwe factuur aangemaakt: {0} - {1}",
                    oRs.Fields.Item(0).Value.ToString(),
                    oRs.Fields.Item(2).Value.ToString()));
          finally
               System.Runtime.InteropServices.Marshal.ReleaseComObject(oRs);
               oRs = null;
               GC.Collect();
     oDoc = null;
catch(Exception ex)
     StatusBar.WriteError(ex.Message);

Similar Messages

  • Error : Add Delivery/Invoice based on order

    Hello
    I try to add deliveries (or invoices) based on a range of orders (via SDK). Everything works fine, except for one order, where I get the error message:
    "-5002 Quantity falls below minimum stock [DLN1.ItemCode][Line:2]"
    If I try to add a delivery (or an invoice) based on the same order in SBO itself (so not via SDK), I also get a message concerning the minimum stock, but I have the option to continue and ignore the message.
    Is it possible via the SDK to work around this message and to let SBO know that it doesn't bother me that we fall below minimum stock?
    Thank you very much
    Iris Spenninck

    Hello Iris,
    When sth. works in the application - showing a warning or not - it should also work through DI API.
    Anything else is a bug that you should report to SAP Support via SAP Service Marketplace!
    Regards,
    Frank

  • Trying to create a Invoice based on Order need help Error -5002

    the dreaded -5002 error is haunting me too! and I could not find a matching solution for this in the forum....
    I need help quickly on this. I am trying to create invoices for some orders so the Base - Target relationship is retained. The orders I pick are all Open (DocStatus   = O and the lines are all Open LineStatus = O)
    here is my code
    oInvoice.Lines.BaseEntry = 48
    oInvoice.Lines.BaseLine = 0
    oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
    oInvoice.Lines.ItemCode = "A00001"
    oInvoice.Lines.ItemDescription = "IBM Infoprint 1312"
    'adding Line
    oInvoice.Lines.Add
    oInvoice.Lines.BaseEntry = 48
    oInvoice.Lines.BaseLine = 1
    oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
    oInvoice.Lines.ItemCode = "A00002"
    oInvoice.Lines.ItemDescription = "IBM Inforprint 1222"
    'adding Line
    oInvoice.Lines.Add
    lRetCode = oInvoice.Add
    If lRetCode <> 0 Then
        gObjCompany.GetLastError lErrCode, sErrMsg
        MsgBox (lErrCode & " " & sErrMsg)
    End If

    Indika,
    Only set your base types...
    (not items & description)
    oInvoice.Lines.BaseEntry = 48
    oInvoice.Lines.BaseLine = 0
    oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
    oInvoice.Lines.ItemCode = "A00001"
    oInvoice.Lines.ItemDescription = "IBM Infoprint 1312"
    'adding Line (to fill the second item line)
    ' the 1st line item is there by default
    oInvoice.Lines.Add
    oInvoice.Lines.BaseEntry = 48
    oInvoice.Lines.BaseLine = 1
    oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
    oInvoice.Lines.ItemCode = "A00002"
    oInvoice.Lines.ItemDescription = "IBM Inforprint 1222"
    'DO NOT Add THIS line
    ' (only if you want to add a 3rd line item)
    '''oInvoice.Lines.Add -> Don't add this
    lRetCode = oInvoice.Add
    If lRetCode <> 0 Then
        gObjCompany.GetLastError lErrCode, sErrMsg
        MsgBox (lErrCode & " " & sErrMsg)
    End If
    remember to add :
    oInvoice.CardCode = "your BP"
    oInvoice.DocDueDate = Now
    oInvoiceDoc.CardCode = txtDOCBPCode.Text

  • Creation of invoices based on orders

    Hi All,
    Can anybody explain me about below point:
    <b>The System's orders listed are in OPEN status and ready to Invoice.
    Please create Invoice against these orders</b>
    Can anybody tell me steps in creating the <b>Invoice from the given Sales Order's</b>.
    The way i am doing is:
    <b>1. Goto VA02 given Open Sales Order and then Hit Enter.
    2. Then from Menu Path Sales Document -> Billing hit on Billing
    3. It will then take us to VF01 screen with all the data filled in.
    4. Then i am hitting on the SAVE Button then an Invoice Number is getting created.</b>
    <b>Is it the way to create Invoice from Order.</b>
    Can anybody give your sujjestions!
    Thanks in advance.
    Thanks,
    Deep.

    Hi!
    To create an invoice for an SD order, is reuiring the correct customizing for that order type.
    Invoices can be made from orders, or deliveries.
    The standard way to create an invoice, is to call the transaction VF01, then enter the reference document number in the table (order or delivery).
    The way, you wrote is correct also.
    Regards
    Tamá

  • Synch of invoice based on delivery (without Delivery doc)

    I've created in SBO Invoice based on Order (without Delivery document). Such Invoice act like delivery document and make stock postings. Why my order after synchronization doesn't change status to <i>send</i>? I've checked SHIPMENT table and there is no such document like my invoice.

    Hello John,
    I think the most simple way is to create a delivery first in SBO. After you have created all your deliveries you can use the Document Genaration Wizard to create all your invoices. After that you can use the option Document Printing to print all the invoices.
    This way you only have to enter all the information once and the information (delivery) will be synchronized with Webtools.
    Tim

  • Creation of A/R Down Payment Invoice  based on Sales Order not logical

    When creating a A/R Down Payment Invoice based on a Sales Order you
    have the option to create multible ones. Which by itself could be
    usefull to create one of 50 % for a certain day and decide they need to
    pay another 25 % at a later date.
    But SBO does not track what already have been posted. Therefore you can
    create a sum more then a 100% without warning or blockage.
    Tested this in SBO 2007 A SP:00 PL:00
    Scenario:
    Sales - AR>Sales Order
    Create and post a Sales Order
    Sales - AR>A/R Down Payment Invoice
    Create an A/R Down Payment
    Select the BP and copy the Sales Order
    Set DPM to 40%
    Post the A/R Down Payment
    Sales - AR>A/R Down Payment Invoice
    Create an A/R Down Payment
    Select the BP and copy the Sales Order
    Set DPM to 100%
    Post the A/R Down Payment
    Sales - AR>A/R Down Payment Invoice
    Create an A/R Down Payment
    Select the BP and copy the Sales Order
    Set DPM to 70%
    Post the A/R Down Payment
    Making the total for the Sales Order 210% worth of Down Payment
    Invoices without warning/blocking. I would expected that you would only
    be able to set the rest sum %. For instance first scenario I entered
    60% therefore setting the second Down Payment Invoice to a max of 40%
    Untill you have used up the 100% and you cannot select the Sales Order
    in question..
    If multible users do the same work, SBO doesn't show that it has
    already been done. Same if you forgot you already created it you can
    still create one. Plus sometimes it will happenyou create the Down
    Payment Invoice and not paying attention you create the first one with
    a 100% and later with the intended percentage..

    Hello Petronella,
    you are right that B1 is not checking the total value of DP created from the Sales Order.
    The logic and checking procedure here is only between Sales Order -> Delivery/Invoice.
    DP Invoice is considered as transaction related to document the receipt of the money (parallel to the sales process). Between the moment of basing of DP to Sales Order it is still possibility to adjust Sales Order as there is no posting behind Sales Order.
    The question is what would be a checking  procedure in case that on Sales Order there is based Delivery and DP? What would be the system priority to take into a consideration?
    Regards,
    Martin Slavik
    Regional Solution Manager

  • Calculate due on date in incoming invoice based on p.date of purchase order

    We would like to calculate due on date in incoming invoice based on posting date of purchase order position. We want to be able to see the posting date of the purchase order lines from miro transaccion. Then we would add 85 days to calculate the due on date. I have tried to create an "item list variant" from OLMRLIST transaccion (Customizing - Logistics invoice verification) and add the posting date but it is not possible to access this value.
    Thanks in advance.

    Hi,
    have a look at badi MRM_PAYMENT_TERMS.
    Check as well OSS Note 1156325 - BAdIs in the Logistics Invoice Verification environment
    Best regards.

  • Create an AP Invoice based on a Purchase Order using SDK

    Hi,
    What are the steps to create an AP Invoice based on a Purchase Order using DI API?
    Which methods of which objects to use and what parameters to pass?
    Thanks.

    Hi Rajesh,
    Here is a sample to create an Invoice based on a Sales Order. The same way you can change as per your requirement:
    SAPbobsCOM.Documents oInvoice = default(SAPbobsCOM.Documents);
                oInvoice = (SAPbobsCOM.Documents)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
                oInvoice.CardCode = "C000003";
                oInvoice.DocDueDate = DateAndTime.Now;
                oInvoice.Lines.BaseType = Convert.ToInt32(SAPbobsCOM.BoObjectTypes.oOrders);
               oInvoice.Lines.BaseEntry = Convert.ToInt32(3616);
               oInvoice.Lines.BaseLine = 1;
                oInvoice.Lines.Quantity = 3;
                oInvoice.Lines.Add();
                oInvoice.Lines.BaseType = Convert.ToInt32(SAPbobsCOM.BoObjectTypes.oOrders);
                oInvoice.Lines.BaseEntry = Convert.ToInt32(3616);
                oInvoice.Lines.BaseLine = 2;
                int kth = 0;
                kth = oInvoice.Add();
                if (kth != 0)
                    int irrcode;
                    string errmsg;
                    SBO_Company.GetLastError(out irrcode, out errmsg);
                    Program.oMainSAPDI.ShowMessage(errmsg, BoStatusBarMessageType.smt_Error);
    The main thing to remember is Base Type, Based Entry and Base Line.
    Hope it helps.
    Thanks & Regards
    Ankit Chauhan

  • Cannot query AR invoices based on the purchase order number in R 12 1.3

    Hi,
    We need to query invoices based on the purchase order number, However when we try to Ct+F11 get the message *"Please fill in selective criteria in at least one of the following fields for performance reasons: GL Date, NUmber,Bill to etc."*
    Is this a new feature or a bug?
    Thanks and Regards,
    MPH

    Hi All,
    I found the solution in the following note.
    *How to prevent Blind Query or Query on Non Indexed Column in Transaction, Receipts, Collections forms? [ID 753222.1]*
    Thanks and Regards,
    MPH

  • How to generat multiple invoices based on per employee/contractor/services?

    Hello Experts / Dina,
    I am in situation where customer is in business of body shopping and charges to his final customer based on individual invoice / per employee /contracor & customer services. This was happening in legacy system but after the implementation of Oracle Project costing and Oracle Project billing, customer is not able to generate invoices per employee services. Rather consolidated invoices are getting generated.
    How to achieve this functionality in oracle project billing?
    Lets take example - On Project P1 for customer ABC, 3 below employees are working on different task for 3 months.
    Now after one month employees have been billed as shown below.
    Emp 1 - 1000 USD - for 100 Hrs
    Emp 2 - 2000 USD - for 200 Hrs
    Emp 3 - 1000 USD - for 50 hrs
    Now @ end of the month when invoice is getting generated is 1 invoice including 3 lines of amount total 4000 USD. There is problem; customer wants that there should be 3 different invoices per employee shoud generated based on above mentiond 3 diff lines for customer ABC.
    I guess with oracle projects billing - You can split the invoice based on Accrue through date ( which is not possible in this case ) and agreement ( which is also not possible in this case ) and different currency ( which is again not possible in this case) - I may be wrong when saying it is not possible. plz correct me if I am wrong.
    even I guess billing extension wont work. So is there any way to achive this?
    Right now only option i am thinking is let single invoice of 4000 USD with 3 different lines should pass to AR and while priniting the invoice customer can create 3 diff prints which includes individual lines. and while applying receipts on the single invoice in the system, customer can apply the receipts to indivual lines.
    but I am not sure about AUDIT issues.. Can some one think about any AUDIT issues comes to this approch or issues with TAX rounding amount issues ?
    Infact I would like to solve this issue with the help of Oracle Projects billing and not with custom invoice print program. I guess someone from you experts can figure it out to generate muiltple invoice based on employees / suppliers / contractors / materials etc.
    A suggestion on Extension / customization / seeded functionality of Oracle Project billing on thi issue would be gr8 help.
    Please help.
    Thanks
    Edited by: oracle_samba on Jan 7, 2013 1:06 AM
    Edited by: oracle_samba on Jan 7, 2013 1:07 AM

    Hi Dina,
    First of all thanks for your update :-) Your solution looks much promising.
    I thought of using billing extension but rejected on the ground that I would end up in generating events based on employee for their corsponding billig amounts so finally generating a consolidated invoice only in One GDI run. But what i was missing was pre-processing extension and running the extention in loop based on employee count.
    I am fully sure business would not have any issues of auto approving and releasing invoice upon generation. But my question is "is it possible to just approve the invoice & not release it using auto approve and release extension?" The reason is I think when GDI runs it only deletes Unapproved invoice & spare Approve invoices. - So please suggest.
    Also please validate my understanding about your solution with an existing example -
    As with the current example, there are 3 EMP presents so need to run GDI 3 times and develop pre-processing ext in a such a way that at each time it will put on hold on all the billable items except EMP1, and EMP2 and EMP3 on each consecutive run respectivly. And ensure that Auto Approve and release extension should be used in order to avoid overriding previously generated invoice? Am I right ?
    Many Many thanks for solution !!!
    Regards,
    :-)

  • Excise Invoice- Based on Billing Plan

    Dear All,
    Here in my client's place, we have a requirement like,
    For a project-XYZ we create one sales order with materials A,B & C.
    For this sales order we maintain billing plan 50% = X1 Rupees ,
                                                                    25% = X2 Rupees ,
                                                              and 25% = X3 Rupees.
    When project is finished 50% we create billing with X1 amount with reference of sales order and then we create excise invoice based on this billing document (NO delivery) and send it with material.
    And for second billing for X2 amount SAP is not allowing to create excise invoice and throws message like modvat utilization has been done already.
    Kindly suggest how to proceed and how to create excise invoice for remaining two amounts.
    Thanks & Regards

    Hi ,
    Thanks for your responce...
    Is there any transaction code for removing the billing block automatically in the sales order and how can i indentify the date category as per billing plan..
    Thank you very much..
    Thanks in advance.
    Regards,
    KV

  • Creation of Invoice based on Qty wise

    Hi SD Experts,
    I want to know how to split invoice based on quantity?
    --Sales order A material is 5 qty
    --Delivery is created with qty 5
    --Now I need to create 5 invoices for a qty of 1 each.
    Regards
    Pradeep

    Hi Pradeep,
    Go Vov7 and select the item category  for which you want the invoice split. There select the appropriate billing quantity option (I guess it should be K, please recheck as i am not accessing the system now). After this when you will create the invoice you can change the invoice quantity.
    If you need the process auto mated then create new copy control routine with the help of abaper by copying the standard routine.
    Hope this will help you.
    Do revert back to the forum if have some concerns.
    Thanks and Regards,
    Atulkumar Dagade

  • Creating an invoice based on a delivery via DI API

    Hi,
    Each time a user creates a delivery (not always based on a sales order), the add on I have developed creates an invoice based on it. This happens without any issue in most cases but I am receiving the following two errors on the client site and have not been able to recreate the issue here...
    One of the base documents has already been closed  [INV1.BaseEntry][line: 1]
    Number of items drawn is greater than open quantity  , 'Item A'
    Does anyone have any idea what could be causing this?
    Thans for any help,
    Robin

    Hi Thomas,
    Thanks for teh reply but unfortunately this is not the case - for example...
    A delivery which is returning this error for Item A, has a quantity of 20 but has 7400 in stock, so it is not going into a negative quantity.
    The only way I could get this error ("Number of items drawn is greater than open quantity"), not using the add on but working within B1, was to create a delivery note, then create an invoice based on it, increase the quantity of the item on the invoice, and the error displays in B1 on the info bar at the bottom.
    I cannot see how the user can affect this, as when they are creating the Delivery, the Invoice creation is automatic (triggers on the add button after the Delivery has been successfully added), and they don't even see the Invoice form.
    Robin

  • Invoice Based on Material

    Hi Experts,
    I have a new customer requirement, Customer does not want invoices based on the order They want invoices on monthly basis and based on the material means like they want the invoice for all the orders with material A  for the month of April 2011.
    I tried to search something logical in forum but was not able to find it, any suggestions will be appreciated.
    Regards,
    Jain

    HI
    Better you go for yr customised programme where u can have option to enter material and check delivery table and get all delivery no for that particular material and then do billing and invoice. Take help of your ABAPer give him your requirement with logic for monthly billing and sure he will be able to write a customised programme to fulfill yr requirement.
    In short,  Here is the way..... Get a customised programme where you select all dliveries for a partuicular period by date range,  from delivery table based on material and call VF01 ( as u know billing is based on payer. Payer must be same for all deliveries. U can add to check payer criteria as well with material) and then invoice.
    Have a nice day!
    Thanks
    DK:)
    Edited by: Dwarkesh Thakkar on Jun 24, 2011 12:17 PM

  • Intercompany Invoice Based on Goods Receipt

    Hello,
    I am running the following intercompany scenario : Purchase order - replenishment delivery - internal billing document.
    - Ordering organization : Cpy A / Sales org A / Plant A
    - Supplying organization : Cpy B / Sales org B / Plant B
    Standard SAP issues an invoice based on the goods issue, which makes perfect sense.  My client's requirement is to trigger the intercompany invoice from the goods receipt at Plant A.

    Hi
    Please check the VTFL Copy control settings.In VTFL check  Data VBRK/VBRP routine feild.For your requirement you may have to change the subroutine
    If standard subroutines are not meeting your requirement,you may have to add new logic to the subroutine with the help of your ABAP team.
    Regards
    Srinath

Maybe you are looking for