DI PL16 - Error on GetByKey

I started to get the following error when doing Doc.GetByKey(CurrDocEntry)
The Error:
"Unable to cast object of type 'SAPbobsCOM.CompanyClass' to type 'SAPbobsCOM.ICompany"
any ideas?
Thanks
Moty

thanks trinidad,
the code was working in prev. version pre PL16.
the problem showed up after upgrad to PL16. it went away after i removed and reinstalled the client (which reinstallas the DI API)
thanks
Moty

Similar Messages

  • Error: -5012, Unbalanced Transaction  SBO 2005 A SP1 PL16

    Hi everyone,
    I am working with an add-on program that creates journal vouchers from a 3rd party database.  Before 2005 A SP1, the add-on worked as designed.   Once SP1 was installed, if the add-on tries to create a journal voucher with more than one transaction, the error -5012, Unbalanced Transaction occurs. 
    No Add-on code was changed.  I am using 2005 A SP1, PL16.
    On System Initialization>Document Settings, Per Document tab for Journal Entry, the "Block Unbalanced RC Journal Entry" is unchecked, along with all the other checkbox on this tab. (Form 228, Item 36, OADM, FcNoBlnc)
    On the Journal Voucher Form, Form Settings, Document tab, General tab, the "Allow Unbalanced Transaction if FC" checkbox and the "Allow Multi-Currency Transactions" checkbox are checked by default.  On the Table tab of the Document tab, both "From LC Field" and "From FC Field" are unchecked.
    I know the system currency handing in exchange rate & conversion changed from SP0 to SP1, but I don't know what technical changes I have to make to the DI code or if there is a setting in the program I need to change.   I have searched for this issue, but I have not found a resolution.  I know other areas of the program have had this issue in the pasted, but they have be resolved in previous patches.
    Any help would be greatly appreciated.

    This issue was resolved in 2005 A SP23.  See SAP note 1012754.
    I am now using SP41 and all my transactions are being included as one.  Still trying to fiqure out what the problem is now.
    Edited by: Greg Stratakes on Mar 6, 2008 2:54 PM

  • Goods Receipt PO - GetByKey error

    Hello,
    I have added a user button on Goods Receipt PO. When I click the button I read the document number of the receipt (idocnum). With this number I want to find the correct receipt in the object:
    oGRPO = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes);
    bool bRetCode =  oGRPO.GetByKey(idocnum);
    But bRetCode is false, meaning that it couldn't find the document. Why?
    Thank you,
    Irina

    Hi Irinia,
    You must use the docentry and not the docnum in the getbykey.
    You can use query on opdnto get the docenty
    Select docentry from opdn where docnum=9999
    Regards
    Ad

  • Error while creating a column in master

    Hi all,
    I am using the sap business one 8.8 version.
    I am getting an error while creating a user defined column for a master table.
    The error code is -104.
    The method I had used for creating a master table is as follows.
    *#region Create Table*
            public static bool CreateTable(string TableName, string TableDescription, SAPbobsCOM.BoUTBTableType TableType, SAPbouiCOM.Application oApplication, SAPbobsCOM.Company oCompany)
                SAPbobsCOM.UserTablesMD oUserTableMD;
                int intRecCode;
                bool boolResult = false;
                oUserTableMD = (SAPbobsCOM.UserTablesMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables);
                try
                    if (!oUserTableMD.GetByKey(TableName))
                        oUserTableMD.TableName = TableName;
                        oUserTableMD.TableDescription = TableDescription;
                        oUserTableMD.TableType = TableType;
                        intRecCode = oUserTableMD.Add();
                        if (intRecCode == 0)
                            boolResult = true;
                catch (Exception e)
                    oApplication.MessageBox(e.Message, 1, "Ok", "", "");
                finally
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserTableMD);
                    GC.Collect();
                return boolResult;
            #endregion
    ==================================
    The following is the code for creating a column in the above master
    private static void AddField(string TableName, string ColumnName, string ColDescription, SAPbobsCOM.BoFieldTypes FieldType, int Size, SAPbobsCOM.BoFldSubTypes SubType, string ValidValues, string ValidDescription, string
    SetValidValues, SAPbouiCOM.Application oApplication, SAPbobsCOM.Company oCompany)
    int intLoop;
                string[] strValue, strDesc;
                SAPbobsCOM.UserFieldsMD oUserFieldsMD;
                SAPbobsCOM.Recordset oRecordSet;
                oUserFieldsMD = (SAPbobsCOM.UserFieldsMD)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
                oRecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                try
                    oRecordSet.DoQuery("SELECT COUNT(*) FROM CUFD WHERE TableID = '" + TableName + "' AND AliasID = '" + ColumnName + "'");
                    if (Convert.ToInt16(oRecordSet.Fields.Item(0).Value) == 0)
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecordSet);
                        oRecordSet = null;
                        strValue = ValidValues.Split(Convert.ToChar(","));
                        strDesc = ValidDescription.Split(Convert.ToChar(","));
                        if (strValue.GetLength(0) != strDesc.GetLength(0))
                            throw new Exception("Invalid Values");
                        oUserFieldsMD.TableName = TableName;
                        oUserFieldsMD.Name = ColumnName;
                        oUserFieldsMD.Description = ColDescription;
                        oUserFieldsMD.Type = FieldType;
                        if (FieldType != SAPbobsCOM.BoFieldTypes.db_Numeric)
                            oUserFieldsMD.Size = Size;
                        else
                            oUserFieldsMD.EditSize = Size;
                        oUserFieldsMD.SubType = SubType;
                        oUserFieldsMD.DefaultValue = SetValidValues;
                        for (intLoop = 0; intLoop <= strValue.GetLength(0) - 1; intLoop++)
                            oUserFieldsMD.ValidValues.Value = strValue[intLoop];
                            oUserFieldsMD.ValidValues.Description = strDesc[intLoop];
                            oUserFieldsMD.ValidValues.Add();
                        if (oUserFieldsMD.Add() != 0)
                            UpdateLastErrorDetails(-104, oCompany);
                catch (Exception e)
                { oApplication.MessageBox(e.Message, 1, "Ok", "", ""); }
                finally
                    if (oRecordSet != null)
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecordSet);
                        oRecordSet = null;
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD);
                    GC.Collect();

    Hi,
    I am newly using BI publisher . I am using 10.1.3.4.0 . I am just trying to create a report in test name. that is the first step to create a report where i am getting error. I am using default RPD paint , where all the user and Groups are defined .

  • Error adding Goods Receipt PO based on Purchase Order

    I am working on an add-on that was working against a 2005A version of SAP Business One and I am upgrading it to run against a 2007A Company (PL41)
    I am receiving strange errors when testing the add-on.
    I can add a Purchase order not based on a Goods Receipt PO without any problems but as soon as I specify a base type, entry and line I get either -1 General Error, or the Tried to Read/Write Protected Memory Error.  The error I receive seems to arbitrarily change between the two.
    I have read a few notes on the forums about this but none of them have proven useful in solving my problem.  I have checked the DI-API version on my PC and it is definitely using 8.0.177.0 which matches the version of SBO that I am running.  I have re-installed the DI etc without any success.
    The following is the code snippet which I am using to test:  I have verified that the referenced purchase order is open, contains the correct item, customer etc
    int iResult = -1;
    string sResult = string.Empty;
    string sOutput = string.Empty;
    try
    sOutput += Environment.NewLine + "Connecting to company...";
          sbocoy = new SAPbobsCOM.Company();
          sbocoy.Server = "<insert server name here>";
          sbocoy.CompanyDB = "<insert database name here>";
          sbocoy.LicenseServer = "<insert server name here>:30000";
          sbocoy.UseTrusted = true;
          sbocoy.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2005;
          sbocoy.UserName = "manager";
          sbocoy.Password = "<inser sap user here>";
          iResult = sbocoy.Connect();
          sOutput += Environment.NewLine + "Connected";
          SAPbobsCOM.Documents PO = (SAPbobsCOM.Documents)sbocoy.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders);
          SAPbobsCOM.Documents GoodsReceiptPO = (SAPbobsCOM.Documents)sbocoy.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes);
          sOutput += Environment.NewLine + "Get Purchase Order";
          PO.GetByKey(1402);
          sOutput += Environment.NewLine + String.Format("DocNum: {0}; DocEntry: {1}; ItemCode: {2}; LineNum: {3}", PO.DocNum, PO.DocEntry, PO.Lines.ItemCode, PO.Lines.LineNum);
          GoodsReceiptPO.CardCode = PO.CardCode;
          GoodsReceiptPO.CardName = PO.CardName;
          GoodsReceiptPO.Lines.ItemCode = PO.Lines.ItemCode;
          GoodsReceiptPO.Lines.ItemDescription = PO.Lines.ItemDescription;
          GoodsReceiptPO.Lines.Quantity = 1.0;
          GoodsReceiptPO.Lines.BaseType = int.Parse(PO.DocObjectCodeEx); // If I comment out this and the next two lines the document will add
          GoodsReceiptPO.Lines.BaseEntry = PO.DocEntry;
          GoodsReceiptPO.Lines.BaseLine = PO.Lines.LineNum;
          sOutput += Environment.NewLine + "Adding Goods Receipt...";
          iResult = GoodsReceiptPO.Add();
          sResult = sbocoy.GetLastErrorDescription();
          sOutput += Environment.NewLine + string.Format("Result [{0}] {1}", iResult, sResult);
    catch (Exception ex)
    sOutput += string.Format(Environment.NewLine + "Exception: {0}{1}SBOError: {2}", ex.Message, Environment.NewLine, sbocoy.GetLastErrorDescription());
    The results when I try and reference the purchase order are:
    Connecting to company...
    Connected
    Get Purchase Order
    DocNum: 301396; DocEntry: 1402; ItemCode: SEANTESTITEM; LineNum: 1
    Adding Goods Receipt...
    Exception: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    If I comment out the 3 lines that reference the base document the Goods Receipt Adds and the following is the output...
    Connecting to company...
    Connected
    Get Purchase Order
    DocNum: 301396; DocEntry: 1402; ItemCode: SEANTESTITEM; LineNum: 1
    Adding Goods Receipt...
    Result [0]
    The above code will work correctly if we base a Delivery Note on a Sales Order so it appears to be specifically related to the Purchasing Documents.
    Edited by: Sean Archer on Feb 2, 2009 2:23 PM

    Hi Ganesh,
    Thank you for the reply.
    I ran the add-on against another database and it is working.
    I also verified that the document was failing to create if done via the Data Transfer Workbench so it would appear the issue affects the DI-API irrespective of add-on.
    I will need to do more testing to confirm whether this is a bug with PL41 of 2007A or a corrupt database as you suggest.
    Cheers,
    Sean

  • Error on Production Orders Add-on when 2 or more users at the same time.

    Hi.
    Our add-on creates special production orders (SAPbobsCOM.BoProductionOrderTypeEnum.bopotSpecial) with no problem when used by one user, but if there are two or more users  everyone on his own SAPBO session it starts to throw different errors, we think it may be a concurrence problem due to several transactions.
    Here a short brief of the code sample and the process:
    (error handling and object members not included in the sample)
    oDoc.ProductionOrderType = SAPbobsCOM.BoProductionOrderTypeEnum.bopotSpecial
    If the oDoc.Add() is correct, We get the last production order created and release it:
    Me.sKey = Me.Company.GetNewObjectKey
    oDoc = Me.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders)
    oDoc.GetByKey(Me.sKey)
    oDoc.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposReleased
    oDoc.Update()
    Then we go for an inventory Entry:
    oDoc = Me.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry)
    oDoc.DocDate = Date.Now
    oDoc.Lines.BaseEntry = Me.sKey
    oDoc.Add
    And Finally to close the production order:
    oDoc.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposClosed
    oDoc.Update()
    This works fine when only one user is using the add-on, but in the end there wil be at least eight users simultaneously  working with this add-on
    The test:
    We have four users creating production orders with the  add-on.
    Two of them get the usual success messages and the created documents in SAPBO are all correct.
    The other two users get diferrent errors messages during the process.
    If they wait and try again to run the process it works fine.
    Repeating the test get errors on different users depending on which one started the process first.
    Our client needs to generate beetwen 900 and 1200 production orders per day, so they can't wait until the process is free for each user to work with it.
    The common erros detected are:
    Changing the status of the production order:
    -5002 - The warehouse is not defined for the item.
    -4002 - To generate this document,
               first define the numbering series in the Administration module
    -1029 - Field cannot be updated
    Adding the production order and inventory entry:
    -2038
    -1116
    -5002
    Regards,
    Omar Fonseca

    The start transaction model didn't Fit well with all the process we are doing, but the idea of locking or holding the other users seems to work pretty fine, we are now using a flag to determine if someone is doing the process and put in hold the new ones.

  • "Internal error (-5002) occurred" On Pick List Update Picked Quantity

    Hi Experts,
    I have an SDK program that simply tries to update the Picked Quantity in SAP. Previously it has been working fine, until I try to use the same logic for items managed by Batch or Serial Number.
    In this scenario, I have created a PickList with only 1 row, the item is managed by Serial Number.
    I try to simplify the code as below.
    Dim oBaseDocument As SAPbobsCOM.PickLists
    oBaseDocument = oComp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPickLists)
    BaseDocument.GetByKey(12345)
    oBaseDocument.Lines.SetCurrentLine(0)
    oBaseDocument.Lines.PickedQuantity += 1
    oBaseDocument.Lines.BinAllocations.Add()
    oBaseDocument.Lines.BinAllocations.SetCurrentLine(0)
    oBaseDocument.Lines.BinAllocations.BinAbsEntry = CInt(sBinAbsEntry)
    oBaseDocument.Lines.BinAllocations.Quantity += dXML_Quantity
    oBaseDocument.Lines.SerialNumbers.InternalSerialNumber = sXML_BatchSerialNo      ' <--- ***
    lRet = oBaseDocument.Update
    I have added the *** line for handling the Serial Number, but when it hit the Update command, the SDK returns "Internal error (-5002) occurred".
    I'm not sure what does it means.
    Anyway I tried to remove the *** line and it works fine for item not managed by Batch or Serial, but the issue will remains for the Items managed by Serial or Batch.
    Please advise whether I missed anything in this code.
    Thank you in advance.
    Best Regards,
    Krisma

    Hi Krisma,
    I haven't done this thing practically but error -5002 will occur, if there is any Invalid Object.
    You can check it accordingly.
    Hope it helps.
    Thanks & Regards
    Ankit Chauhan

  • Copy Data from a System Form to another (GetByKey)

    Hi All,
    I 'll try the following: "After the succesful add of a specific Credit Note I want to copy the Cardcode and the Cardname (of this Credit Note) to cardcode and cardname of a Delivery Note".
    I tried the following code without success:
                If (pval.FormType = 179) And (pval.ItemUID = "1") And (pval.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pval.Before_Action = False) And (pval.ActionSuccess = True) Then
                    Dim DocEntry As Integer
                    Try
                        Dim oCredit As SAPbobsCOM.Documents
                        oCredit = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)
                        Dim oDeliv As SAPbobsCOM.Documents
                        'Creation of Business Objects
                        oDeliv = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)
                        oCredit.GetByKey(DocEntry)
                        oDeliv.CardCode = oCredit.CardCode
                        oDeliv.CardName = oCredit.CardName
                    Catch ex As Exception
                        MessageBox.Show(ex.Message)
                    End Try
    Thanks in advance,
    Vangelis

    Hello,
    There are a few errors in the code you've pasted:
    oCredit = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)
    oDeliv = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)
    a) both the above lines are creating delivery notes.
    b) where are you getting the docentry value from, get it from the form using UI-API
    c) you can also get the cardcode / cardname value using UI-API, by referring to the fields on the form, rather than using oCredit object.
    c) you are not calling add/update after writing delivery note
    d) lets be clear that you cannot change cardcode / cardname in already created delivery note, and if you are adding a new delivery note you can not do it by just specifying cardcode / cardname
    Rahul

  • Error while linking user defined table to user defined field using vb6.0

    Hi,
    I am creating a userdefined field on a SAPB1 table(PDN1) using vb 6.0
    I am trying to link this field to a user defined table.
    When i do that i get the following error:
    "The field 'Related table' should consist of 8 alphanumeric chracters with no valid or default values"
    When i try to do the same thing from SAPB1(not using code) there is no such problem.
    My vb code is as follows:
    Set oUserFieldsMD = oCmp.GetBusinessObject(oUserFields)
    oUserFieldsMD.TableName = "PDN1"
    oUserFieldsMD.Name = "OB_Locn"
    oUserFieldsMD.Description = "WH Location"
    oUserFieldsMD.Type = db_Alpha
    oUserFieldsMD.EditSize = 30
    lRetCode = oUserFieldsMD.Add
    If lRetCode <> 0 Then
        oCmp.GetLastError lErrCode, sErrMsg
        MsgBox sErrMsg
        GoTo Err_
    End If
    If Not oUserFieldsMD.GetByKey("PDN1", 0) Then
        MsgBox "Error"
        GoTo Err_
    End If
    oUserFieldsMD.LinkedTable = "OB_TEST"
    lRetCode = oUserFieldsMD.Update
    Your help will be much appreciated.
    Thanks.

    Great Sébastien!
    Looks like we could not survive here one day without your contribution
    Best regards,
    Frank
    PS: For readers of this thread who don't understand why
    EditSize
    must be "8":
    This is the size of the
    Code
    field in the user-defined table to which the new field OB_Locn (in the DB it will be U_OB_Locn) is linked to...
    So, it should be preferrably of the same size.

  • Error in updating Sales Order

    Hi
    I have a problem here that i need to be solved.
    I am using SDK to update the SO in a UDF field. Something like confirmation of the particular item in a text format after checking.
    But i keep getting this error
    <i>Violation of PRIMARY KEY constraint 'RDR1_PRIMARY'. Cannot insert duplicate key in object 'RDR1'</i>
    This only happens to certain SO.
    My code is something like this
    <i>SOUpdate = m_company.getbusinesobject(SAPbobsCOM.BoObjectTypes.oOrders)
    if SOupdate.GetByKey(key) = true then
    dim iCOunt as integer
    icount = SOupdate.Lines.Count
    For iCount = 0 To SOupdate.Lines.Count -1
    SOUpdate.Lines.SetCurrentLine(iCount)
    SOupdate.Lines.Userfields.Fields.Item("I_oriSO").value = "Confirm"
    Next
    End if
    SOUpdate.Update</i>
    Any help is welcomed
    Thanks

    I see your loop runs from zero. Why are you doing that? If memory serves me correctly row 0 is the column headings.....so row 1 is the first row of data and the actual row you should start from....
    The rest looks good from a glance

  • Error while Upgrading to PL10 from 2007A

    I got an error at the last database during the 'Pre-Upgrade Check'. The error says...
    Integrity check failed due to non-consecutive TransSeq on OINM for the same document row [SAP Note: 1344231].
    The log file says....
    09/11/2010  14:18:43:154027      UpgradeWizard     Note               I     Technical     ID: 27 # #     MID=-1     BOID=-1     BO=     UserID=     G:\SAP_8.8_Upgrade_Files\88PL10_Upgrade\Wizard\Upgrade.exe     Version=8.80.229     Area=     PID=5296     TID=152     D:\depot\BUSMB_B1\8.8_REL\SBO\8.8_REL\Application\SolutionPatch\Component\Logger.cpp     105
    09/11/2010  14:18:43:154027      UpgradeWizard     Note               I     Technical     Check: OINM integrity check for having same document row with non-consecutive TransSeq in OINM # #     MID=-1     BOID=-1     BO=     UserID=     G:\SAP_8.8_Upgrade_Files\88PL10_Upgrade\Wizard\Upgrade.exe     Version=8.80.229     Area=     PID=5296     TID=152     D:\depot\BUSMB_B1\8.8_REL\SBO\8.8_REL\Application\SolutionPatch\Component\Logger.cpp     105
    09/11/2010  14:18:43:154027      UpgradeWizard     Note               I     Technical     Desc: (27) Check OINM integrity if exists same document line with non-consecutive TransSeq in OINM; SAP Note: 1344231 # #     MID=-1     BOID=-1     BO=     UserID=     G:\SAP_8.8_Upgrade_Files\88PL10_Upgrade\Wizard\Upgrade.exe     Version=8.80.229     Area=     PID=5296     TID=152     D:\depot\BUSMB_B1\8.8_REL\SBO\8.8_REL\Application\SolutionPatch\Component\Logger.cpp     105
    09/11/2010  14:18:43:154027      UpgradeWizard     Note               I     Technical     Begin time: 20101109 2:18:38PM # #     MID=-1     BOID=-1     BO=     UserID=     G:\SAP_8.8_Upgrade_Files\88PL10_Upgrade\Wizard\Upgrade.exe     Version=8.80.229     Area=     PID=5296     TID=152     D:\depot\BUSMB_B1\8.8_REL\SBO\8.8_REL\Application\SolutionPatch\Component\Logger.cpp     105
    09/11/2010  14:18:43:247777      UpgradeWizard     Note               I     Technical     Same document line with non-consecutive TransSeq exist in OINM # #     MID=-1     BOID=-1     BO=     UserID=     G:\SAP_8.8_Upgrade_Files\88PL10_Upgrade\Wizard\Upgrade.exe     Version=8.80.229     Area=     PID=5296     TID=152     D:\depot\BUSMB_B1\8.8_REL\SBO\8.8_REL\Application\SolutionPatch\Component\Logger.cpp     105
    09/11/2010  14:18:43:247777      UpgradeWizard     Note               I     Technical     End time: 20101109 2:18:38PM # #     MID=-1     BOID=-1     BO=     UserID=     G:\SAP_8.8_Upgrade_Files\88PL10_Upgrade\Wizard\Upgrade.exe     Version=8.80.229     Area=     PID=5296     TID=152     D:\depot\BUSMB_B1\8.8_REL\SBO\8.8_REL\Application\SolutionPatch\Component\Logger.cpp     105
    09/11/2010  14:18:43:247777      UpgradeWizard     Note               I     Technical     Test result: Error # #     MID=-1     BOID=-1     BO=     UserID=     G:\SAP_8.8_Upgrade_Files\88PL10_Upgrade\Wizard\Upgrade.exe     Version=8.80.229     Area=     PID=5296     TID=152     D:\depot\BUSMB_B1\8.8_REL\SBO\8.8_REL\Application\SolutionPatch\Component\Logger.cpp     105
    Can anyone help. I tried to look up many places for this SAP note or on the details of the error, but no clue.

    Hi,
    Recommended patch level upgrade is SAP B1 8.8 SP00 PL15. you can read the info from this thread:
    Upgrade from 2007A PL47 to 8.8 PL16
    if you need fast, you can download it and upgrade your 2007A version to the PL. I am not sure if the PL15 can be solved the current upgrade problem but you may try. if not success, you have to log message to SAP support as Gordon's suggested.
    JimM

  • Error  -10  while closing a Production Order with DI API

    Hi,
    I've been trying to close some production orders using this code:
    Dim oProdOrder As SAPbobsCOM.ProductionOrders
            Try
                oProdOrder = Me.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductionOrders)
                If oProdOrder.GetByKey(intDocEntry) Then
                    oProdOrder.ProductionOrderStatus = SAPbobsCOM.BoProductionOrderStatusEnum.boposClosed
                    If oProdOrder.Update <> 0 Then
                        Me.Company.GetLastError(intError, sErrMsg)
                        If (0 <> intError) Then
                            sErrorMsg = sErrorMsg & "Production Order Close Error: " & CStr(intError) & "," & sErrMsg & _
                                ". DocEntry: " & oProdOrder.ProductionOrderOriginEntry & vbCrLf
                        End If
                    End If
                End If
    ...But I keep getting the same error every time I try: -10,Date out of reference date range, '_SYS00000005340'
    The error doesn't show when I close the Order with BO's Form. And I've checked the exchange rate for the posting and due date of the document (and also for my current date) and there seems to be no problem with it.
    I'm currently working with SAP BO 2004A PL 45.
    Anybody has a suggestion? a workaround?
    I'll appreciate any help you can give me.
    Thanks in advance...
    Alfredo

    Alfredo,
    just in case,
    what is the previous state of the production order (planned, released,...)?
    before you try to close the order, update the status to released:
    If oProdOrder.GetByKey(newID) Then
    'Cambio di stato dell'ordine da 'Planned' a 'Released'
                    oProdOrder.ProductionOrderStatus = boposReleased
    oProdOrder.Update
    I found this code in a DI API application written for 2004A. It was commented out so I suspect it didn't work.
    'Chiusura dell 'ordine
            'SelProductionOrder.ProductionOrderStatus = boposClosed
            'ret = SelProductionOrder.Update
            'If ret <> 0 Then
            '    sboCompany.GetLastError nErr, errMsg
            '    MsgBox "Errore " & nErr & " - " & errMsg
            'End If
    Hope this helps

  • Error trying to use multiple lines from a PO in a Goods Receipt PO

    I get the following error when I try to add 2 lines from a PO to a single Goods Receipt PO (code below):
    -5002 One of the base documents has already been closed  [PDN1.BaseEntry][line: 1]
    I can create the Goods Receipt PO if I use 1 line or lines from multiple PO's???
                   SAPbobsCOM.Documents poReceipt2 = (SAPbobsCOM.Documents)_diApi.SboCompany.GetBusinessObject(BoObjectTypes.oPurchaseDeliveryNotes);
                   poReceipt2.CardCode = "ALL";
                   poReceipt2.DocDueDate = DateTime.Now;
                   poReceipt2.Lines.Quantity = 5;
                   poReceipt2.Lines.ItemCode = "HAMSHA";
                   poReceipt2.Lines.BaseEntry = 11;
                   poReceipt2.Lines.BaseLine = 0;
                   poReceipt2.Lines.BaseType = 22;
                   poReceipt2.Lines.Add();
                   poReceipt2.Lines.Quantity = 5;
                   poReceipt2.Lines.ItemCode = "LAMFIL";
                   poReceipt2.Lines.BaseEntry = 11;
                   poReceipt2.Lines.BaseLine = 1;
                   poReceipt2.Lines.BaseType = 22;
                   poReceipt2.Add();
    Any help is appreciated!
    Thanks,
    Daniel

    Hi Louis, thanks for the post...
    However the PO document that I am refercing definately has both lines open, if I use 1 of those lines it works fine, but the error occurs if I use 2 lines from the same PO.  I am also definately using the docentry not the docnum for the GetByKey() method.
    Can anyone run the same basic logic through the DI API?  That is create a PO with 2 lines on it, then run the code as above to make a Goods Receipt PO and reference the 2 lines from the 1 PO document?  (It works if I add multiple lines referncing lines from multiple PO docs??)
    Thanks,
    Dan
    Message was edited by: Daniel Archer

  • Error when trying to update UserField in 9.0 PL11

    Hi experts,
    I'm currently tring to update userfield in the table ORDR,RDR1,OWTR and WTR1 using the DI API and each time an error occurs.
    For the ORDR and OWTR table the error description is
    Cannot drop the index 'dbo.OIEI.OIEIMRO_SO', because it does not exist or you do not have permission
    For the RDR1 and WTR1 table the error description is
    Cannot drop the index 'dbo.IEI1.IEI1MRO_SO', because it does not exist or you do not have permission
    Do you know why this error occurs and why sap try to drop an index in the table OIEI or IEI1 when i'm updating a field in ORDR or RDR1?
    Thanks.
    Best regards

    hi.
    you have to use get by key method for updating the user defined fields..like below..
    sales order i am upating.
        Dim vOrder As SAPbobsCOM.Documents
                        vOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
                  Dim s As String
                        If vOrder.GetByKey(150) Then
    'here  150 is the  doc entry i am going to update the  fields.
    Header:
    oDocument.UserFields.Fields.Item("U_XYZ").Value = "Test";
    Line:
    oDocument.Lines.UserFields.Fields.Item("U_XYZ").Value = "Test;
    Somet times you have to convert it to string.
    myVar = oDocument.UserFields.Fields.Item("U_XYZ").Value.ToString();
    MessageBox.Show(s)
                        End If

  • Error while cancel Purchase Order

    Hello everyone.
    I'm trying to cancel a Purchase Order which has a Purchase Delivery Note.
    First I cancel the Purchase Delivery Note and than I try to cancel the Purchase Order, but I'm having the following error: "The requested action is not supported for this object."
    If I manually cancel the Purchase Delivery Note, I can successfully cancel the Purchase Order by code.
    Here is the code I'm using:
    Documents lDocumento = Globals.AddOn.ConexaoAuxiliar.GetBusinessObject(BoObjectTypes.oPurchaseDeliveryNotes);
    lDocumento.GetByKey("DocEntry");//DocEntry is just an example
    Documents lCancelamento = lDocumento.CreateCancellationDocument();
    if (lCancelamento.Add() != 0)
         throw new Exception(Globals.AddOn.ConexaoAuxiliar.GetLastErrorDescription());
    Then I try to cancel the Purchase Order:
    Documents lDocumento = Globals.AddOn.ConexaoAuxiliar.GetBusinessObject(BoObjectTypes.oPurchaseOrders);
    lDocumento.GetByKey("DocEntry");//just an example..
    if (lDocumento.Cancel() != 0)//if can't cancel, try to close
         if (lDocumento.Close() != 0)//if can't close, show error..
              throw new Exception(Globals.AddOn.ConexaoAuxiliar.GetLastErrorDescription());
    SAP 9 PL 10

    Hi Leandro,
    Sorry, I missed that bit. But that brings to mind, you create the cancellation document, but apparently you do not explicitly cancel the purchase delivery note.
    Could you please test that ? So for example:
    if (lCancelamento.Add() != 0)
      if (lDocumento.Close() != 0)
    //etc.
    Could you also please test commenting out the code that closes the purchase order, and then check from the B1 client that the delivery was closed and linked to a Returns document ?
    Regards,
    Johan

Maybe you are looking for