-5002 Error on adding of A/P Invoice and Company.GetLastError returns 0/""

Hi
Hopefuly someone here can help me. I have written a small addon that places orders, Invoices etc between two Companies. One is a sales company and the other a production company.
The problem I am having is at the production company when they do an AR invoice to the sales company I create a AP Invoice (sales company side). This works fine for documents with one line item but not for more. Could someone please try to shed some light on this.
I use the following code :
oGoodsReceipt = oIntercompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseInvoices)
                '// PO header
                oGoodsReceipt.Series = iSeries
                oGoodsReceipt.CardCode = sPartnerCC
                oGoodsReceipt.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO
                oGoodsReceipt.DocDate = oInvoice.DocDate
                oGoodsReceipt.DocDueDate = oInvoice.DocDueDate
                oGoodsReceipt.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items
                oGoodsReceipt.DocObjectCode = SAPbobsCOM.BoObjectTypes.oPurchaseOrders
                oGoodsReceipt.Comments = "Inter Company receipt of Invoice No " & CStr(oInvoice.DocNum) _
                                    & " for Purchase Order " & oInvoice.UserFields.Fields.Item("U_FC_ICDocEntry").Value _
                                    & " " & oPurchaseOrders.Comments
                '// PO Lines
                For i = 0 To oInvoice.Lines.Count - 1
                    If i <> 0 Then
                        oInvoice.Lines.SetCurrentLine(i)
                        oGoodsReceipt.Lines.Add()
                    End If
                    oGoodsReceipt.Lines.BaseType = SAPbobsCOM.BoAPARDocumentTypes.bodt_PurchaseOrder
                    oGoodsReceipt.Lines.BaseEntry = oPurchaseOrders.DocEntry
                    oGoodsReceipt.Lines.Quantity = oInvoice.Lines.Quantity
                    oGoodsReceipt.Lines.ItemCode = oPurchaseOrders.Lines.ItemCode
                    oGoodsReceipt.Lines.BaseLine = oInvoice.Lines.LineNum
                Next i
                RetVal = oGoodsReceipt.Add()

Never mind solved it I was using  "oGoodsReceipt.Lines.ItemCode = oPurchaseOrders.Lines.ItemCode" instead of the Item Code of the Invoice

Similar Messages

  • Error While Adding Service A\P Invoice

    Hi Expert,
    I am getting an Error while adding the service A\P invoice The error is:
    System.NullRefernce Exception :- Object Reference not set to an instance of an object. At CXS_TDS_BAL.clsAPInvoice
    I also Restarted my  TDS Addon but still getting same error
    Thanks & Regards,
    Pankaj Sharma

    Hi Pankaj Sharma,
    Your question belongs to Add-on forum.  Check it there to see if there are similar issues solved or not.  If not, post it there.
    Thanks,
    Gordon

  • Error - Unhandled Exception While making AR invoice and AP invoice

    Hello Expert,
    while making AP Invoice from user's computer after entering 2/3 invoice   , SAP raises an error "
    and close SAP Business One but when user is connected through Terminal Server then there is no problem to add  document.
    while making AR Invoice from user's computer after entering 2/3 invoice   , SAP raises an error "
    and close SAP Business One but when user is connected through Terminal Server then there is no problem to add document.
    Please assist me regarding these issues.

    Dear Chintan,
    SAP Business One 9.1 (9.10.140) PL: 04  (32-bit)
    Regards,
    Mizan

  • Error when addin an AR Reserve Invoice

    Hi all
    A client was adding an AR Reserve Invoice and got the following error:
    {SQL Native Client}{[SQL Server}Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <=, >, >= or when the subquery is used as an expression. (CINF)

    Dear Jerusha,
    It seems AR Reserve invoice is calling a query that has to be modified.
    Please report ths issue to SAP Business One Support.
    Regards
    Preety Goel
    Business One Forums Team

  • "Post Invoice and Payment seperately"

    Hi Guys,
    I need help on resolving this issue.
    We are posting a vendor downpayment using F-48.
    We are then doing a vendor invoice and subsequently clearing the open items using F-58. But we are getting the following error while posting
    "Deferred Tax : Post Invoice and Payment seperately $1"
    Thanks,
    Srikanth.

    hi,
    Do you have two tax codes setup up.  One tax code to post with the invoice and another one which is used for transferring when the invoice payment is made.  Please check that you are using the right tax code setup for the posting with the invoice.
    Regards
    Girish BP

  • DI API error while adding AP Invoice (Using serial Nos.)

    Hi,
    Im getting the following DI API error when adding an AP Invoice which has serial numbers and i cant seem to find any logical fault in the code.
    " [PCH1.WhsCode][line: 4] , 'This entry already exists in the following tables (ODBC -2035) "
    If anybody has encountered this error and found a solution kindly let me know.

    Hi Vivek,
    Are you trying to add same document number, serial number or so on?
    "entry exist " means like "duplicate key problem", I guess.
    Basically, whscode column in PCH1 table allows duplicating.
    So, I think serial number is duplicated among same item code.
    Hope this useful for you.
    Regards,
    Hyunil Choi.

  • Error on Adding AR Invoice

    Hi Experts,
    We have error on adding AR invoice (AR), Delivery (AR), Goods Receipt PO (AP), AP Invoice (AP). Please help on this error..
    below is the error message:
    [microsoft] [SQL Native Client] [SQL Server] Conversion failed when converting the nvarchar value '65002 0' to data type int. (CINF)
    Thanks,
    John

    Hi Jon,
    What Rahul meant was, if you have certain user defined fields or tables in SAP B1, these user defined fields can have some data or queries. This data or data returned by queries may have some strange characters in them. So he asked you to disable all your FMS fields and then test to ensure the error.
    I found one more link, they have similar problems as yours due to Store Procedures they had and migrated from 2007A to 8.8. Could this be your situation? Please read through this link - [Microsoft][SQL Native Client][SQL Server]Conversion failed when converting and note the SAP B1 notes.

  • Internal Error when adding Invoice from DI-API

    Hello All,
    I am trying to add an invoice using DI-API. I hv populated the object using XML and than adding it. Upon adding the error Internal Error (-10) is coming. I hv checked everything but am certainly missing something. Following is the XML of the invoice and the code to add it
    <?xml version="1.0" encoding="utf-16" ?>
    <BOM>
      <BO>
        <AdmInfo>
          <Object>13</Object>
          <Version>1</Version>
        </AdmInfo>
        <OINV>
          <row>
            <U_EntryId>1</U_EntryId>
            <DocType>I</DocType>
            <DocDate>20110923</DocDate>
            <DocDueDate>20111023</DocDueDate>
            <CardCode>JM0004</CardCode>
            <CardName>GAYAN BHARTI</CardName>
            <NumAtCard></NumAtCard>
            <DiscPrcnt>0.000000</DiscPrcnt>
            <DocTotal>755.000000</DocTotal>
            <Comments></Comments>
            <U_BranchTrans>1</U_BranchTrans>
            <SlpCode>-1</SlpCode>
            <IsICT>N</IsICT>
            <Series>40</Series>
            <TaxDate>20110923</TaxDate>
            <TrackNo></TrackNo>
            <SeqCode>0</SeqCode>
            <U_SlpName></U_SlpName>
            <U_WebCreated>N</U_WebCreated>
            <U_Territory></U_Territory>
            <U_InvType>C</U_InvType>
          </row>
        </OINV>
        <INV1>
          <row>
            <ItemCode>A003</ItemCode>
            <Dscription></Dscription>
            <Quantity>5.000000</Quantity>
            <DiscPrcnt>0.000000</DiscPrcnt>
            <WhsCode>JSP-FG</WhsCode>
            <PriceBefDi>11.000000</PriceBefDi>
            <TaxCode>NonTax</TaxCode>
            <U_WebCreated>N</U_WebCreated>
            <U_RetQty></U_RetQty>
            <U_SaleQty></U_SaleQty>
            <U_LineType>S</U_LineType>
          </row>
          <row>
            <ItemCode>A005</ItemCode>
            <Dscription>Ace Visual Dictonary 2</Dscription>
            <Quantity>10.000000</Quantity>
            <DiscPrcnt>0.000000</DiscPrcnt>
            <WhsCode>JSP-FG</WhsCode>
            <PriceBefDi>70.000000</PriceBefDi>
            <TaxCode>NonTax</TaxCode>
            <U_WebCreated>N</U_WebCreated>
            <U_RetQty></U_RetQty>
            <U_SaleQty></U_SaleQty>
            <U_LineType>S</U_LineType>
          </row>
        </INV1>
      </BO>
    </BOM>
    Program Code to add
                Dim oSapObject As SAPbobsCOM.Documents
                oCompany.XMLAsString = True
                oSapObject = oCompany.GetBusinessObjectFromXML(Body, 0)
                If oSapObject.Add <> 0 Then
                    Throw New Exception(oCompany.GetLastErrorDescription & " [" & oCompany.GetLastErrorCode & "]")
                End If
    Any help would be greatly appreciated. This is sort of urgent and needs to be done immediately.
    Regards,
    Rahul Jain
    PS: The error is coming on oSapObject.Add - it is able to read the invoice from XML, the error comes when trying to add it. All relevant values mentioned in XML are present in the database, and I am able to add an Invoice from the UI.
    Edited by: Rahul Jain on Sep 24, 2011 1:29 PM

    I realize this might not be to much help but everytime I have ever gotten an internal error code it has always turned out to be a SQL error. For instance there could be something in transaction notification that doesnt jive with your submission or something along those lines. Perhaps you could try a more simplified invoice as a test such as just send one item with a price and no UDFs .
    Sorry if that is not much help.

  • Adding a delivery, -5002 error

    We have an addon that adds a Delivery. It always worked good, but recently it gives an error for only 2 Business partners (so for all others it works fine). I think it goes wrong since we have the 2005 version of SAP Business One.
    This is the error:
    Error code: -5002
    Error message: [ODLN.DocRate], 'Federal Tax ID - The ID Country Code [80] is not valid'
    Any idea what it can be or where to look?

    Search the forum and you'll find the answer. For instance:
    Re: Error Code -5002

  • Error while adding A/P Credit Memo!

    Error while adding A/P Credit Memo..........
    'G/L Accounts' (OACT) (ODBC-2028) Message - 131-183
    Please advice me .....
    Thanks...

    Hi
    Check this thread this may help you.
    [Re: AP Invoice - No Matching Account Error]
    Regards
    Balaji

  • Error Code :-5002 Error Message :Enter valid currency  , '51100000-01-001-0

    Hi all,
             I have found a error "Error Code :-5002 Error Message :Enter valid currency  , '51100000-01-001-01'" while adding the DELIVERY document.
    I have made a customer and assign then "EURO" currency and add delivery document then it prompts error.
    Could anyone solve this problem. is there any setting which i am missing..??
    Regards
    Sandesh

    HI Sandesh,
    Check Sap note :1252328
    and also check below thread of similar issue:
    Re: 'Invalid Currency' error when attempting to deliver order
    Hope this will solve your issue.
    Thanks,
    Neetu

  • Error:Invoice and receipt must be paid exactly

    Hi
    I m receiving an error while adding A/R invoice
    Invoice and receipt must be paid exactly[message 131-45]
    and pop up window of payment is opened.I want to pay to customer only after adding sales invoice not before adding.
    How to get rid of it?

    Hi,
    Check your Customer (BP). This problem may occur because of that customer may be a cash and carry customer.
    Cheers,
    Senthil Maruthappan.

  • - 5002 error!!!

    hey All,
    Does anyone know why this code would throw the - 5002 error with just a dash for the error description? it works for an update of an existing purchase order but throws the error when I am creating a new PO. Any ideas?
    if (update)
        thisDoc.GetByKey(Int32.Parse(currentPO));
        thisDoc.Lines.Add();
       thisDoc.Lines.ItemCode = currentItemCode;
        thisDoc.Lines.ItemDescription = myItem.ItemName;
         //TODO ADD IN SALES ORDER AND PO NUMBER LINKS salesOrderNum
         //Set values to the fields
         thisDoc.CardCode = currentVendor;
         //Invoice Lines - Set values to the second line
                   //poDoc.Lines.UserFields.Fields.Item("U_ShipFrom").Value = shipFrom;
         thisDoc.Lines.Quantity = Double.Parse(qty);
         thisDoc.Lines.Price = Double.Parse(cost);
         thisDoc.Lines.BaseEntry = Int32.Parse(salesOrderNum);
         thisDoc.Lines.BaseLine = soLineNum;
         thisDoc.Lines.BaseType = 17; // 17 is sales order;
                   //poDoc.Lines.UserFields.Fields.Item("U_PQR").Value = pqr;
                   //poDoc.Lines.UserFields.Fields.Item("U_LogNotes").Value = logNotes;
         int returnVal;
         if (update)
         //Update the purchase order
              returnVal = thisDoc.Update();
         else
              returnVal = thisDoc.Add();

    Hi Curtis
    I'm not sure if you can base a PO on a sales order, didn't realize you were doing that earlier. If you go to Purchase Order, you can't base it on sales order. The only way you can do it through the front end is if you tick the Purchase order box on Sales order form.....the system then creates one for you.
    I tried on my own code that works perfect with invoice based on sales order. But as soon as i say PO based on Sales Order it gives the same error code. The description says something like the BP Codes are different. Now for this it must be different because it's not a customer anymore but a vendor/supplier. But all other circumstances the bpcodes would be the same for docs that are based on previous docs. I'm not sure if we can do it based. You might have to just create the PO without basing it on the sales order.
    Hope this helps

  • Error while adding a 'Ext No' field to Activities Search Result List on UI

    Hi Experts,
    The requirement is to add a new display field u2018External Nou2019to the activities SEARCH Result list.
    At the moment activities are displayed with start date, end date and category, now the user want to display External No as well.
    The details for that
    Target:
    Component:BT126S_APPT
    View:bt126s_Appt/ApptSR
    Context Node:BTQRACT
    New attribute 'EXTERN_ACT_ID' to be added to the context node.
    Source: component: BT125H_TASK
    View: BT125H_TASK/TaskDetailsOV
    ContextNode:BTACTIVITYH
    Attribute:Struct.Extern_Act_Id
    BOL Relation:
    BOL ENTITY: BTQRAct
    BOL Attribute: BTADVSAct -> BTOrderHeader -> BTHeaderActivityExt/EXTERN_ACT_ID
    When i tried to added the attribute to the context node BTQRACT, it gave me the error 'method CL_BT126S_A_APPTSR_CTXT CREATE_BTQRACT DOES NOT EXIST.
    please give me some inputs.
    Regards
    Krishna

    Hi steve,
    Still my issue was not resolved, could you help me to find the exact error.I have enhanced the component, view and context node, still i couldn't able to add attributes to the context node BTQRACT.I tried to add several fields, but it is giving the same error 'METHOD CL_BT126S_A_APPTSR_CTXT' CREATE_BTQRACT DOES NOT EXIST'. I have checked the OSS messages and found 2 relavant to this component. I have implemented both the Sap Notes 1363752, 1226612. Still after implementing the OSS note, i am getting the same error.My guess is one of the method is missing. Please help me out?
    Regards
    Krishna

  • Error while adding a connector for SSL..help!!!

    i'm getting this error when i added a connector for SSL and restarted tomcat
    my connector tag is
    <Connector keystorePass="kalima" scheme="https" port="8443" sslProtocol="TLS" redirectPort="-1" enableLookups="true" keystoreFile="Mykeystore" protocol="TLS" keystore="C:\Documents and Settings\santhoshyma\Mykeystore" clientauth="false" algorithm="SunX509" keypass="changeit" secure="true" keytype="JKS">
          <Factory className="org.apache.coyote.tomcat5.CoyoteServerSocketFactory" keystorePass="kalima" keystoreFile="C:\SSLTest\Mykeystore"/>
        </Connector>
    LifecycleException:  Protocol handler instantiation failed: java.lang.NullPointe
    rException
            at org.apache.coyote.tomcat5.CoyoteConnector.initialize(CoyoteConnector.
    java:1368)
            at org.apache.catalina.core.StandardService.initialize(StandardService.j
    ava:609)
            at org.apache.catalina.core.StandardServer.initialize(StandardServer.jav
    a:2384)
            at org.apache.catalina.startup.Catalina.load(Catalina.java:507)
            at org.apache.catalina.startup.Catalina.load(Catalina.java:528)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:250)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:424)

    The question is answered in CRM 7.0 forum:
    Getting error while adding a custom field (with input help) through AET

Maybe you are looking for

  • Bootcamp and external hard disk?

    ok so i'm going to be getting a mbp in the next week and was wondering whether boot camp can be set up on an external disk? this would be very helpful for me as it would allow me to be able to get a 128gb ssd in my macbook and keep that clean with ju

  • HT1338 How do I upgrade my OS X?

    I'm running OS X 10.5 but when I go to the Apple menu and select Software Update it says my Mac is up to date...how do I upgrade my OS X? Lazar

  • Why does Adobe Elements 12 destroy my Olympus makernotes section of the metadata

    I downloaded the trial version of Adobe Elements 12 and pointed it to a test folder with some of my Olympus OM-D E-M1 photos.  I viewed the file properties from within Elements which showed all of the camera info, exposure, aperture, lens used, camer

  • Grid Console and Configuration Change Console?

    I have installed Grid Console 10.2.0.5, and now I'm looking at the Configuration Change Console URL (http://www.oracle.com/technology/software/products/oem/htdocs/config_control.html) wondering if I also need to install this as well. It appears that

  • Creating new project

    When viewing movie in event library, the preview screen shows the entire picture as filmed, but when I move the film to the project library, the preview screen shows the top of the film cut off. How do I adjust or fit so that everybody's heads are no