Using X++ Code batch Terminate and copy the purchase price

Sometimes,The purchasing staff would like to Batch Terminate and copy the purchase price on Trade agrement - > Purchase prices.

So,I wrote a batch jobs used to solve this problem!

Wrote by Jimmy on April 25th 2011

 

static void Jimmy_PriceChangeVendorAndCopyPrice(Args _args)
{
int i;
priceDiscTable priceDiscTable,insetPriceDS;
test test;
Transdate Todate
= systemdateget() - 1;
Transdate FromDate
= systemdateget();
;

while select test order by ItemId
{
ttsbegin;
while select forupdate priceDiscTable
where priceDiscTable.ItemCode == TableGroupAll::Table
&& priceDiscTable.AccountCode == TableGroupAll::Table
&& priceDiscTable.relation == PriceType::PricePurch
&& priceDiscTable.Module == ModuleInventCustVend::Vend
//&& priceDiscTable.QVS_Default == Noyes::No
&& priceDiscTable.AccountRelation == "30076"
&& priceDiscTable.ItemRelation == test.ItemId
&& (systemdateget() >= PriceDiscTable.fromDate || !PriceDiscTable.fromDate) &&
(systemdateget()
<= PriceDiscTable.toDate || !PriceDiscTable.toDate)
{
i
++;
insetPriceDS.data(priceDiscTable);
insetPriceDS.AccountRelation
= "35033";
insetPriceDS.FromDate
= FromDate;
insetPriceDS.Comment
= "Copy 30076 price by Jimmy Xie";
insetPriceDS.modifiedField(fieldnum(priceDiscTable,AccountRelation));
insetPriceDS.insert();

priceDiscTable.QVS_Default
= Noyes::No;
priceDiscTable.ToDate
= Todate;
priceDiscTable.Comment
= "Terminate 30076 price by Jimmy Xie";
priceDiscTable.modifiedField(fieldnum(priceDiscTable,QVS_Default));
priceDiscTable.update();

}
ttscommit;
}

/*update main vendor account and purchase group
while select test order by ItemId
{
ttsbegin;
while select forupdate priceDiscTable
where priceDiscTable.ItemCode == TableGroupAll::Table
&& priceDiscTable.AccountCode == TableGroupAll::Table
&& priceDiscTable.relation == PriceType::PricePurch
&& priceDiscTable.Module == ModuleInventCustVend::Vend
&& priceDiscTable.QVS_Default == Noyes::Yes
&& priceDiscTable.AccountRelation == "35033"
&& priceDiscTable.ItemRelation == test.ItemId
//&& priceDiscTable.Comment == "Terminate 30076 price by Jimmy Xie"
&& priceDiscTable.FromDate == todatys
&& (systemdateget() >= PriceDiscTable.fromDate || !PriceDiscTable.fromDate) &&
(systemdateget() <= PriceDiscTable.toDate || !PriceDiscTable.toDate)
{
i++;
priceDiscTable.modifiedField(fieldnum(priceDiscTable,QVS_Default));
priceDiscTable.update();

}
ttscommit;
}
*/
info(int2str(i));
}

 

posted @ 2011-04-25 16:27  Fandy Xie  Views(657)  Comments(0Edit  收藏  举报