Discussion:
Create PriceDisc using X++
(too old to reply)
Chris (Toronto)
2006-09-15 12:37:01 UTC
Permalink
Hi,

I need to import cost information from a supplier using X++ and I want to
use the trade agreement functionality.

I have created the following test code to setup a purchase trade agreement
for the given vendor and Item.

All of the records get inserted ok and exist in the priceDisc table, but
when I open up the item and view the purchase price trade agreements no
records are visible.

What am I missing?

Chris

--------------------------------------------------------------
static void test(Args _args)
{
PriceDiscTable pricedisctable;
itemId _itemId;
AccountNum _accountNum;
ioCost _ioCost;
;

// Setup variables
_itemId = '100011';
_accountNum = 'VN100003';
_ioCost = 999.99;

ttsbegin;

select forupdate pricedisctable;

priceDiscTable.clear();
priceDiscTable.initValue();
priceDiscTable.ItemCode = TableGroupAll::Table;
priceDiscTable.ItemRelation = _itemId;
priceDiscTable.AccountCode = TableGroupAll::Table;
priceDiscTable.AccountRelation = _accountNum;
priceDiscTable.QuantityAmount = 1;
priceDiscTable.FromDate = today();
priceDiscTable.Amount = _ioCost;
priceDiscTable.Currency = VendTable::find(_accountNum).Currency;
priceDiscTable.SearchAgain = NoYes::Yes;
priceDiscTable.relation = priceType::PricePurch;
priceDiscTable.UnitId = inventParameters::find().DefaultUnitId;
priceDiscTable.CalendarDays = Noyes::Yes;
priceDiscTable.validateWrite();
priceDiscTable.insert();

ttscommit;
}
Volker Leiner
2006-09-15 15:42:02 UTC
Permalink
Hi Chris,

The best way to find out, what's goining wrong is to create a record via the
client interface and compare it to that one you have inserted via X++. Then
you can see the differences easily.

You are missing the inventDimId. If you are not dealing with item locations
etc. then just add this line:
priceDiscTable.InventDimId = InventDim::inventDimIdBlank();

Otherwise you have to set another InventDimId to point to the right
inventory dimension.

By the way: you should modify the last lines of your script, otherwise you
will insert records, which are not validated ok:

if (priceDiscTable.validateWrite())
{
priceDiscTable.insert();
}

--
Cheers,
Volker Leiner
Post by Chris (Toronto)
Hi,
I need to import cost information from a supplier using X++ and I want to
use the trade agreement functionality.
I have created the following test code to setup a purchase trade agreement
for the given vendor and Item.
All of the records get inserted ok and exist in the priceDisc table, but
when I open up the item and view the purchase price trade agreements no
records are visible.
What am I missing?
Chris
--------------------------------------------------------------
static void test(Args _args)
{
PriceDiscTable pricedisctable;
itemId _itemId;
AccountNum _accountNum;
ioCost _ioCost;
;
// Setup variables
_itemId = '100011';
_accountNum = 'VN100003';
_ioCost = 999.99;
ttsbegin;
select forupdate pricedisctable;
priceDiscTable.clear();
priceDiscTable.initValue();
priceDiscTable.ItemCode = TableGroupAll::Table;
priceDiscTable.ItemRelation = _itemId;
priceDiscTable.AccountCode = TableGroupAll::Table;
priceDiscTable.AccountRelation = _accountNum;
priceDiscTable.QuantityAmount = 1;
priceDiscTable.FromDate = today();
priceDiscTable.Amount = _ioCost;
priceDiscTable.Currency = VendTable::find(_accountNum).Currency;
priceDiscTable.SearchAgain = NoYes::Yes;
priceDiscTable.relation = priceType::PricePurch;
priceDiscTable.UnitId = inventParameters::find().DefaultUnitId;
priceDiscTable.CalendarDays = Noyes::Yes;
priceDiscTable.validateWrite();
priceDiscTable.insert();
ttscommit;
}
Chris (Toronto)
2006-09-15 16:35:01 UTC
Permalink
Thanks Volker,

Working great now!

Chris
Post by Volker Leiner
Hi Chris,
The best way to find out, what's goining wrong is to create a record via the
client interface and compare it to that one you have inserted via X++. Then
you can see the differences easily.
You are missing the inventDimId. If you are not dealing with item locations
priceDiscTable.InventDimId = InventDim::inventDimIdBlank();
Otherwise you have to set another InventDimId to point to the right
inventory dimension.
By the way: you should modify the last lines of your script, otherwise you
if (priceDiscTable.validateWrite())
{
priceDiscTable.insert();
}
--
Cheers,
Volker Leiner
Post by Chris (Toronto)
Hi,
I need to import cost information from a supplier using X++ and I want to
use the trade agreement functionality.
I have created the following test code to setup a purchase trade agreement
for the given vendor and Item.
All of the records get inserted ok and exist in the priceDisc table, but
when I open up the item and view the purchase price trade agreements no
records are visible.
What am I missing?
Chris
--------------------------------------------------------------
static void test(Args _args)
{
PriceDiscTable pricedisctable;
itemId _itemId;
AccountNum _accountNum;
ioCost _ioCost;
;
// Setup variables
_itemId = '100011';
_accountNum = 'VN100003';
_ioCost = 999.99;
ttsbegin;
select forupdate pricedisctable;
priceDiscTable.clear();
priceDiscTable.initValue();
priceDiscTable.ItemCode = TableGroupAll::Table;
priceDiscTable.ItemRelation = _itemId;
priceDiscTable.AccountCode = TableGroupAll::Table;
priceDiscTable.AccountRelation = _accountNum;
priceDiscTable.QuantityAmount = 1;
priceDiscTable.FromDate = today();
priceDiscTable.Amount = _ioCost;
priceDiscTable.Currency = VendTable::find(_accountNum).Currency;
priceDiscTable.SearchAgain = NoYes::Yes;
priceDiscTable.relation = priceType::PricePurch;
priceDiscTable.UnitId = inventParameters::find().DefaultUnitId;
priceDiscTable.CalendarDays = Noyes::Yes;
priceDiscTable.validateWrite();
priceDiscTable.insert();
ttscommit;
}
Loading...