My Requirement is to Ensure correct defaulting, restriction, and error handling for Legal Entity selection in the Purchase Requisition.
When a user selects a legal entity in the Purchase Requisition header, it should default to each line item.
If no legal entity is selected at the header level, prevent the addition of line items and display an error message: “Please select the legal entity from PR header financial dimension.”
The Legal Entity field in the header can only be modified if there are no line items. If line items exist and the user attempts to change the Legal Entity, display an error message: “Cannot change the legal entity after lines have been added.”
validate write method:-
public boolean validateWrite()
{
boolean ret;
str legalEntity,legalEntityLine;
ret = next validateWrite();
PurchReqLine purchReqLine;
select firstonly purchReqLine order by LineNum desc where purchReqLine.PurchReqTable == this.RecId ;
if (this.DefaultDimension != 0 && purchReqLine.LineNum > 0)
{
legalEntity = this.getDimValue(this.DefaultDimension);
legalEntityLine = this.getDimValue(purchReqLine.DefaultDimension);
if(legalEntity != legalEntityLine)
{
ret = checkFailed(strFmt("The Legal entity at the header level cannot be changed"));
}
}
return ret;
}
To get the dimension values:-
public DimensionValue getDimValue(PurchReqDefaultDimensionValueSet purchReqDefaultDimensionValueSet)
{
DimensionAttributeValueSet DimensionAttributeValueSet;
DimensionAttributeValueSetItem DimensionAttributeValueSetItem;
DimensionAttributeValue DimensionAttributeValue;
DimensionAttribute DimensionAttribute;
;
select RecId from DimensionAttributeValueSet
where DimensionAttributeValueSet.RecId == purchReqDefaultDimensionValueSet
join DisplayValue from DimensionAttributeValueSetItem
where DimensionAttributeValueSetItem.DimensionAttributeValueSet == DimensionAttributeValueSet.RecId
join RecId from DimensionAttributeValue
where DimensionAttributeValue.RecId == DimensionAttributeValueSetItem.DimensionAttributeValue
join RecId from DimensionAttribute
where DimensionAttribute.RecId == DimensionAttributeValue.DimensionAttribute
&& DimensionAttribute.Name == "LegalEntity";
return DimensionAttributeValueSetItem.DisplayValue;
}
No comments:
Post a Comment