SAP Business One SDK on C#

4.5k views Asked by At

How can I update Item's Price on Item Masterdata PriceList in SDK?

that is my sample code:

Try
    Dim aItemMas As SAPbobsCOM.Items
    aItemMas = SAP_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)

    With aItemMas
        .ItemCode = "SMPLE-23456"
        .ItemName = "Sample Test Item222"
        .ForeignName = "01-29992"
        .PriceList.PriceListName(1).GetType()
        .PriceList.Currency = ""
        .PriceList.Price = 100
        .ItemType = SAPbobsCOM.ItemTypeEnum.itItems
        .InventoryItem = SAPbobsCOM.BoYesNoEnum.tNO
        .SalesItem = SAPbobsCOM.BoYesNoEnum.tYES
        .PurchaseItem = SAPbobsCOM.BoYesNoEnum.tNO
        .ItemsGroupCode = 100
        .SalesVATGroup = "ZO"
    End With

    Dim Result As Integer
    Dim ErrNo As Long
    Dim ErrMsg As String = ""

    Result = aItemMas.Add

    SAP_Company.GetLastError(ErrNo, ErrMsg)
    If (ErrNo <> 0) Then
        MsgBox(ErrNo & ": " & ErrMsg, vbCritical)
    End If

Catch ex As Exception
    MsgBox(ex.ToString)
End Try

Please Help me with this I got stock on this

1

There are 1 answers

0
Novice On BEST ANSWER
oItem = ((SAP_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems)));

if (oItem.GetByKey(ItemCode) == true)
{
    oItem.PriceList.SetCurrentLine(Index);
    oItem.PriceList.Price = 1000;
}

oItem.Update();

int ErrNo;
string errMsg;

errMsg = SAP_Company.GetLastErrorDescription();
ErrNo = SAP_Company.GetLastErrorCode();

if (ErrNo != 0)
{
    MessageBox.Show(ErrNo + ": " + errMsg);
}
else
{
    MessageBox.Show("Nice!");
}