on 09-04-2008 8:53 AM
HI All,
How to add an item & its details into the SAP db using DI-API(in vb.net).....can anybody give me the coding pls...
regards,
shangai.
Hi Shangai,
When you install the Business One SDK, you install both the help centre and the samples automatically.
The help centre can be found in Start->Programs->SAP Business One->SDK->SDK Help Centre. The samples can be found in the same path.
In the help centre, there are several examples available - for example, I have copy and pasted this from the help centre:
Sub Add_Item()
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim vItem As SAPbobsCOM.Items
Set vItem = vCmp.GetBusinessObject(oItems)
'Set value to mandatory fields:
vItem.ItemCode = "MyNewItem"
'Set Value to other fields
vItem.ItemName = "MyNewItem Name"
vItem.WhsInfo.WarehouseCode = "01"
'Adding the Item
RetVal = vItem.Add
'Checking the result
If RetVal <> 0 Then
vCmp.GetLastError ErrCode, ErrMsg
MsgBox ErrCode & " " & ErrMsg
End If
End Sub
Additionally, the help centre lists every object, method and property including what values are valid, what fields are Mandatory and covers both UI and DI.
The samples are a great resource too for learning the ins and outs of the Business One SDK.
Hope this helps.
Regards
Niall
SAP Business One Forums Team
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Experts,
using DI API iam adding items in item master data...like the below code i want to add the currency,Pricelistcode,pricelist but iam unable to find those properties.....can anybody help me...
vItem.ItemName = "MyNewItem Name"
regards,
shangai.
Edited by: shangai Nights on Sep 4, 2008 5:41 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shangai,
those properties are in the PriceList Child Object of the ItemMaster:
vItem.ItemName = "MyNewItem Name"
vItem.PriceList.SetCurrentLine( "YourPriceListLine") // it will depends on how many pricelists do you have.
vItem.PriceList.Price = "YourPrice"
vItem.PriceList.Add()
Hope it helps!
Marta
Hi,
in the item you have automatically all pricelists.
you don't place the name there.
important is just that you place the line correct.
oItems.PriceList.SetCurrentLine(i)
(be aware that the i starts with 0)
look if the name is the correct name and than set the price
oItems.PriceList.Price
lg David
Hi Shangai,
You don't need to add the PriceListName. All Items have automatically all the PriceLists. (The PriceLists are defined in Inventory/PriceLists/PriceLists.)
With vItem.PriceList.SetCurrentLine( "YourPriceListLine") you are selecting the PriceList to add your price. You can use this value to check that your are takking the correct PriceList.
You can add different prices for the different PriceLists.
dim NLists as integer
NLists = vItem.PriceList.count
for IDlist as integer = 0 to (NLists -1)
vItem.PriceList.SetCurrentLine(IDlist)
if "SALES" = vItem.PriceList.PriceListName then
vItem.PriceList.Price = "your sales price"
else if "PURCHASE" = vItem.PriceList.PriceListName then
vItem.PriceList.Price = "your purchase price"
end if
next
You will have always two lists thar are automatically filled by the system:
- Last Purchase Price
- Last Evaluated Price
Hope it helps!
Marta
Hi,
thanks a lot....your coding works fine....but i have one small doubt in this......while adding items through DI-API in item master data iam able to add item code,item name...etc but if i want to add a new ItemGroup & Manufacturer...then how can i create new one(Define New) & add...
vItem.ItemsGroupCode = Sample Group
When i give vItem.ItemsGroupCode = 100 &
vItem.Manufacturer=1 then it's taking the default type based on cobobox index but i want to create a new item group in the front end itself...
Regards,
Shangai.
Hi Shangai,
the ItemGroups object is not an Item object.
You need to retrieve the ItemGroups directly:
dim oItemGroups as SAPbobsCOM.ItemGroups
oItemGroups = vcmp.getBusinessObject(SAPbobsCOM.BoObjectTypes.oItemGroups)
oItemGroups.GroupName= "Your new group name"
oItemGroups.add()
The code is set automatically by SBO when you insert the new ItemGroup.
oItemGroups.Number
Hope it helps.
Marta
Hi,
I guess u could use the following code....
Dim oitem As SAPbobsCOM.Items
oitem = SBO_Appln.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)
oitem.ItemCode = ""
oitem.ItemName = ""
oitem.ItemType = SAPbobsCOM.ItemTypeEnum.itItems
oitem.Add()
hope it helps..
Regards,
Vasu Natari.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi shangai,
This is an example to add an item with DI API :
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim vItem As SAPbobsCOM.Items
Set vItem = vCmp.GetBusinessObject(oItems)
'Set value to mandatory fields:
vItem.ItemCode = "MyNewItem"
'Set Value to other fields
vItem.ItemName = "MyNewItem Name"
vItem.WhsInfo.WarehouseCode = "01"
'Adding the Item
RetVal = vItem.Add
'Checking the result
If RetVal <> 0 Then
vCmp.GetLastError ErrCode, ErrMsg
MsgBox ErrCode & " " & ErrMsg
End If
Regards
Michael
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.