📚 SAP Business One SDK Help

Add Method
See Also  Example

Description

Adds a new data line to the object.

Syntax

Visual Basic
Public Sub Add() 

Remarks

You can use this method to add an empty line to the current object. After the line is added, you can set values to the properties of this line.

Note: When a new object is created, it already contains one data line, so you can set the properties of the first line directly without adding a new line. However, if the object contains more than one line, you must use the Add method.

Example

Adding discounts based on item groups (Visual Basic)Copy Code
' Get a business partner
Dim oBP As SAPbobsCOM.BusinessPartners
oBP = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)
oBP.GetByKey("C1")

' Indicate discounts are based on item groups, that is,
' discounts apply to items in the specified groups.
'
' The ObjectEntry property, below, refers to an item group
oBP.DiscountBaseObject = SAPbobsCOM.DiscountGroupBaseObjectEnum.dgboItemGroups

' Add discounts
oBP.DiscountGroups.ObjectEntry = "100"
oBP.DiscountGroups.DiscountPercentage = 10
oBP.DiscountGroups.Add()
oBP.DiscountGroups.ObjectEntry = "101"
oBP.DiscountGroups.DiscountPercentage = 12
oBP.Update()
Adding discounts based on item properties (Visual Basic)Copy Code
' Get a business partner
Dim oBP As SAPbobsCOM.BusinessPartners
oBP = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)
oBP.GetByKey("C1")

' Indicate discounts are based on item properties, that is,
' discounts apply to items with the specified properties.
'
' The ObjectEntry property, below, refers to an item property
oBP.DiscountBaseObject = SAPbobsCOM.DiscountGroupBaseObjectEnum.dgboItemProperties

' Indicate that, if an item has more than one property, apply
' the bigger discount
oBP.DiscountRelations = SAPbobsCOM.DiscountGroupRelationsEnum.dgrHighestDiscount

' Add discounts
oBP.DiscountGroups.ObjectEntry = "1"
oBP.DiscountGroups.DiscountPercentage = 20
oBP.DiscountGroups.Add()
oBP.DiscountGroups.ObjectEntry = "2"
oBP.DiscountGroups.DiscountPercentage = 25
oBP.Update()
Updating/deleting discount (Visual Basic)Copy Code
Dim oBP As SAPbobsCOM.BusinessPartners
Dim oDiscountGroup As SAPbobsCOM.DiscountGroups

oBP = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners)
oBP.GetByKey("C1")

oDiscountGroup = oBP.DiscountGroups
oDiscountGroup.SetCurrentLine(0)
oDiscountGroup.Delete()

oBP.Update()

Example

See Also