Validation on Trade Agreement Journal Posting
Q: How to add Trade agreement Journal Line Posting Validation?
Case Study:
In
My Case of Trade Agreement at the time of journal line posting check the line
in the journal on the basis of six fields relation, ItemRelation, AccountRelation, Currency, InventSiteId, InventLocationId. First, I
have to get the line which record have the highest FromDate and Iterate in the
same Journal Any Record Field Data match with the above mention field data
change the ToDate to one day Previous Date.
Form:
Trade Agreement Journal Lines:
Post Button:
TradeAgreementJournal Form name: PriceDiscAdm
DataSource
1. PriceDiscAdmTrans
2. InventDim
3. EcoResCategory
4. EcoResCategory
5. TmpRetailPriceDiscAdmTrans
6. RetailCategoryContainmentLookup
7. EcoResProductCategory
POST button Controll Name: PriceDiscAdmPost
class: PriceDiscAdmCheckPost
System will validate the below fields
Relation
CN: relation DS: PriceDiscAdmTrans Table: PriceDiscAdmTrans DF: relation
Item Relation
CN: ItemRelation DS: PriceDiscAdmTrans Table: PriceDiscAdmTrans DF: ItemRelation
Account Selection
CN: AccountRelation DS: PriceDiscAdmTrans Table: PriceDiscAdmTrans DF: AccountRelation
Currency
CN: PriceDiscAdmTrans_Currency DS: PriceDiscAdmTrans Table: PriceDiscAdmTrans DF: Currency
Site
CN: InventoryDimension_InventSiteId DS: InventDim Table: InventDim DF: InventSiteId
Warehouse
CN: InventoryDimension_InventLocationId DS: InventDim Table: InventDim DF: InventLocationId
Relation in PriceDiscAdmTrans
PriceDiscAdmTrans.inventDimId == InventDim.inventDimId
Source Code:
[ExtensionOf(classStr(PriceDiscAdmCheckPost))]
final class PriceDiscAdmCheckPost_Extension
{
void postJournal()
{
next postJournal();
str jornalNum = journalNum;
PriceDiscAdmTrans priceDiscAdmTrans,localPriceDiscAdmTrans,delRecordLocalPriceDiscAdmTrans;
InventDim localInventDim,delRecordLocalInventDim;
select firstonly JournalNum,relation,ItemRelation,AccountRelation,Currency,FromDate from localPriceDiscAdmTrans
order by JournalNum,relation,ItemRelation,AccountRelation,Currency,FromDate desc
join inventDimId,InventSiteId,InventLocationId from localInventDim
where localPriceDiscAdmTrans.InventDimId == localInventDim.inventDimId && localPriceDiscAdmTrans.JournalNum == jornalNum;
ttsBegin;
while select forupdate JournalNum,relation,ItemRelation,AccountRelation,Currency,FromDate,ToDate From delRecordLocalPriceDiscAdmTrans
join inventDimId,InventSiteId,InventLocationId from delRecordLocalInventDim
where delRecordLocalPriceDiscAdmTrans.InventDimId == delRecordLocalInventDim.inventDimId && delRecordLocalPriceDiscAdmTrans.JournalNum == localPriceDiscAdmTrans.JournalNum
&& delRecordLocalPriceDiscAdmTrans.relation == localPriceDiscAdmTrans.relation && delRecordLocalPriceDiscAdmTrans.ItemRelation == localPriceDiscAdmTrans.ItemRelation
&& delRecordLocalPriceDiscAdmTrans.AccountRelation == localPriceDiscAdmTrans.AccountRelation && delRecordLocalPriceDiscAdmTrans.Currency == localPriceDiscAdmTrans.Currency
&& delRecordLocalInventDim.InventSiteId == localInventDim.InventSiteId && delRecordLocalInventDim.InventLocationId == localInventDim.InventLocationId
{
if(delRecordLocalPriceDiscAdmTrans.FromDate < localPriceDiscAdmTrans.FromDate && delRecordLocalPriceDiscAdmTrans.RecId != localPriceDiscAdmTrans.RecId)
{
delRecordLocalPriceDiscAdmTrans.ToDate = delRecordLocalPriceDiscAdmTrans.ToDate - 1;
delRecordLocalPriceDiscAdmTrans.update();
}
}
ttsCommit;
}
}
Comments
Post a Comment