AX中 多公司交易,物料主表价格维护,
1、需求:
集团公司和子公司,采用的公司物料方法创建分公司物料,集团公司对分公司来说就是供应商,分公司对集团就是客户。
集团公司的物料主表的销售价,对应分公司帐套的物料主表的采购价。集团公司的物料主表销售价格一旦更新,分公司的采购价也相应更新,保持一致。
2、实现方式:
//写个类方法
void update(DataAreaId _DataAreaId,itemid itemid)
{
inventtable inventtable;
inventtable inventtable1;
xtTDataArea xtTDataArea;
InventTableModule InventTableModule;
InventTableModule InventTableModule1;
int price;
itemid _itemid;
//总部帐套
changecompany('xx')
{
select InventTableModule where InventTableModule.ItemId == itemid && InventTableModule.moduletype == 1;
price=InventTableModule.Price;
_itemid=InventTableModule.ItemId;
}
//分公司帐套
changecompany(_DataAreaId)
{
ttsbegin;
select forupdate InventTableModule1 where InventTableModule1.ItemId ==_itemid
&& InventTableModule1.ModuleType == 2 ;
if (InventTableModule1)
{
InventTableModule1.Price =price;
InventTableModule1.update();
}
ttscommit;
}
}
3、调用方式
static void xtTDataArea(Args _args)
{
xtTDataArea_update xtTDataArea_update;
xtTDataArea xtTDataArea;
;
//初始化类
xtTDataArea_update = new xtTDataArea_update();
while select xtTDataArea where xtTDataArea.id != 'xx'
{
xtTDataArea_update.update(xtTDataArea.Id,'1011017001');
}
info("OK");
}