on 01-31-2011 5:06 PM
Can anyone show me how I go about updating price list items using the DI API?
Hello
In DI Price lists can be updated via items, so steps would be followed:
1. Get the Item using getbykey
2. Locate the price list by number in a loop
3. update the price of the price list
4. update the item record
here is a simple code for this in c#
Variables:
itemcode = item number type String
price = item new price in the price list, type double
scurrency = currency of the price type string
spurchasepricelist = price list number you would like to update type integer
SAPbobsCOM.Items oMM = null;
oMM = (SAPbobsCOM.Items)globalD.oCompany.GetBusinessObject(BoObjectTypes.oItems);
int lretcode = 0;
if (oMM.GetByKey(itemcode))
{
bool need2update = false;
for (int p = 0; p < oMM.PriceList.Count; p++)
{
oMM.PriceList.SetCurrentLine(p);
if (oMM.PriceList.PriceList.ToString() == spurchasepricelist)
{
price = Convert.ToDouble(oRs.Fields.Item(spuchasepricefield).Value);
oMM.PriceList.Price = price;
oMM.PriceList.Currency = scurrency;
need2update = true;
break;
}
}
if (need2update)
{
lretcode = oMM.Update();
if (lretcode != 0)
throw new Exception(string.Format("(pricelist){0}-{1}", globalD.oCompany.GetLastErrorCode(), globalD.oCompany.GetLastErrorDescription()));
}
}Regards
János
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.