C# 上的 SAP Business One SDK

SAP Business One SDK on C#

如何在 SDK 中更新项目主数据价目表的项目价格?

这是我的示例代码:

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

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!");
}