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

Duplicate Item

Hello,

I want to duplicate an item.

The source item is in two warehouses. The destination item should be not in warehouses (phantom item).

The following code doesn't work. Can you help me please?

Dim Artik as String = "OLDITEM"
Dim OITM As SAPbobsCOM.Items
OITM = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)
        OITM.GetByKey(Artik)
    'New Values
        OITM.IsPhantom = SAPbobsCOM.BoYesNoEnum.tYES
        OITM.SalesItem = SAPbobsCOM.BoYesNoEnum.tNO
        OITM.InventoryItem = SAPbobsCOM.BoYesNoEnum.tNO
        OITM.PurchaseItem = SAPbobsCOM.BoYesNoEnum.tNO
        OITM.DefaultWarehouse = ""

        For j As Integer = OITM.WhsInfo.Count To 0 Step -1
            OITM.WhsInfo.SetCurrentLine(j)
             OITM.WhsInfo.WarehouseCode = ""
        Next j

        OITM.ItemCode = "NEWITEM"
        lRetCode = OITM.Add

How can I delete the WhsInfo-Part.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 07:46 AM

    Can you show me a exemple please?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Marcel,

      Because have tried the same, but because you can't delete rows in whsinfo and in this object there is store old itemcode there i suggest use xml for this here is some very old code which i use hope it will helpfull

      oCmp.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode
                                              oItem.SaveXML("C:\itemm.xml")
                                              Dim file As String
                                              Dim xd As New Xml.XmlDocument
                                              xd.Load("c:\itemm.xml")
                                              Dim nod As Xml.XmlNode = xd.SelectSingleNode("/BOM/BO/Items/row/ItemCode[text()='" & oItem.ItemCode.ToString & "']")
                                              nod.InnerText = SAP.GetEditText(oForm.Items.Item("NItem").Specific)
                                              xd.Save("c:\itemm.xml")
                                              'Retrieve the object back from the XML file
                                              oItem2 = oCmp.GetBusinessObjectFromXML("C:\itemm.xml", 0)
                                              ''oItem2.ItemCode = SAP.GetEditText(oForm.Items.Item("NItem").Specific)
                                              oItem2.ItemName = SAP.GetEditText(oForm.Items.Item("NItemName").Specific)
                                              oItem2.Properties(64) = SAPbobsCOM.BoYesNoEnum.tYES
                                              ''oItem2.WhsInfo.WarehouseCode = "01"
                                              Dim lBomItem As Integer
                                              If oItem2.Add() Then
                                                  oCmp.GetLastError(lErrCode, sErrMsg)
                                                  oApp.MessageBox("Error " & ": " & sErrMsg, 1, "OK")
                                              End If
      

  • author's profile photo Former Member
    Former Member
    Posted on Dec 19, 2008 at 06:03 AM

    Hi Marcel,

    In your case you want to create new item.

    and you passed " " as Warehouse

    But in OITM there are only two mandatory fields

    ItemCode and Manufacturer.

    So if you don't want to pass warehouse then don't write that line in your code.

    may be this will help you

    Hepil Doshi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 10:58 AM

    Thank you.

    Add a comment
    10|10000 characters needed characters exceeded

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.