Monday, 13 July 2015

Main Account is Displayed  on Purchase Req Form in that Financial Dimension.

Ans: PurchReqLine Table level we can write one method:

 
// Finding the main account from posting profile written


public DimensionDisplayValue MRKPMainAccount(InventTable inventTable)

{

DimensionDisplayValue mainAccount;

DimensionAttributeValueCombination dimensionAttributeValueCombination;

EcoResProduct ecoResProduct;

ItemGroupId itemGroupId;

InventPosting inventPosting;


boolean itemCodeAll,itemCodeGrp,itemCodeCategory,itemCodeTable;

 

ecoResProduct = EcoResProduct::find(inventTable.Product);

itemGroupId = InventItemGroupItem::findByItemIdLegalEntity(inventTable.ItemId, inventTable.DataAreaId).ItemGroupId;


if(ecoResProduct.WW_Category == WW_Category::Stock)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::All

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::InventIssue;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeAll =

true;

}


if (!itemCodeAll)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::GroupId

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::InventIssue;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeGrp =

true;

}

}


if (!itemCodeAll && !itemCodeGrp)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::Category

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::InventIssue;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeCategory =

true;

}

}


if (!itemCodeAll && !itemCodeGrp && !itemCodeCategory)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::Table

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::InventIssue;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeTable =

true;

}

}

}


else if(ecoResProduct.WW_Category == WW_Category::NonStock)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::All

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::PurchPackingSlip;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeAll =

true;

}


if (!itemCodeAll)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::GroupId

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::PurchPackingSlip;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeGrp =

true;

}

}


if (!itemCodeAll && !itemCodeGrp)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::Category

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::PurchPackingSlip;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeCategory =

true;

}

}


if (!itemCodeAll && !itemCodeGrp && !itemCodeCategory)

{


select firstonly inventPosting


where inventPosting.ItemCode == InventPostingItemCode::Table

&& inventPosting.ItemRelation == itemGroupId

&& inventPosting.InventAccountType == InventAccountType::PurchPackingSlip;


if (inventPosting)

{

mainAccount = DimensionAttributeValueCombination::find(inventPosting.LedgerDimension).DisplayValue;

itemCodeTable =

true;

}

}

}


return mainAccount;

}
method ::2
// New method written for updating the Main Account written by ramesh




void


MRKPUpdateDefaultFinancialDim(ItemId _itemId)

{

DimensionAttributeValue dimAttrMAValue,dimAtrrCCValue,dimAtrrDepValue,dimAttrIGValue,dimAtrrProjValue;

DimensionAttribute dimAttrMA,dimAtrrCC,dimAtrrDep,dimAttrIG,dimAtrrProj;

DimensionAttributeValueSetStorage davss;

RecId defaultDimension;

InventTable inventTable = InventTable::find(_itemId,

true);

CustTable custTable;

DimensionDisplayValue mainAccount;

davss = DimensionAttributeValueSetStorage::find(inventTable.DefaultDimension);

mainAccount = this.MRKPMainAccount(inventTable);

dimAttrMA = DimensionAttribute::findByName(

'MainAccount');

dimAttrMAValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrMA,mainAccount,
false, true);


if (dimAttrMAValue)

{

davss.addItem(dimAttrMAValue);

inventTable.DefaultDimension = davss.save();

inventTable.update();

}

}

 
###
Method 3::
/// <summary>

/// Creates the default dimension by using the entity dimension specifiers from the line.

/// </summary>

/// <param name="_currentDefaultDimensionAfterRequisitioner">

/// A <c>boolean</c> for indicating if the current default dimension should be added to the dimension source list

/// after the requisitioner; optional.

/// </param>




public


void setDefaultDimension(boolean _currentDefaultDimensionAfterRequisitioner = false)

{

List dimensionSources =

new List(Types::Class);

ProjTable projTable;

HcmEmployment employee;

VendTable vendor;

InventTable inventTable;


if (!this.isConsumption())

{


return;

}


if (!_currentDefaultDimensionAfterRequisitioner)

{

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(this.DefaultDimension));

}


// Apply defaults from project


if (this.ProjId)

{

projTable = ProjTable::find(this.ProjId);

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(projTable.DefaultDimension));

}


//Employee

employee = HcmEmployment::findByWorkerLegalEntity(this.Requisitioner, this.BuyingLegalEntity);


if (employee)

{

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(employee.DefaultDimension));

}


if (_currentDefaultDimensionAfterRequisitioner)

{

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(this.DefaultDimension));

}


// Vendor


if (this.VendAccount)

{

vendor = VendTable::findByCompany(

this.buyingLegalEntity2DataArea(),

this.VendAccount);

dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(vendor.DefaultDimension));

}


// Product


if (this.ItemId)

{

inventTable = InventTable::findInLegalEntity(this.ItemId,

this.ItemIdDataArea

);

this.MRKPUpdateDefaultFinancialDim(inventTable.ItemId);

// added by ramesh for updating the financial dimension for PR Line;
dimensionSources.addEnd(DimensionDefaultingEngine::getDefaultDimensionSpecifiers(inventTable.DefaultDimension));

}

this.DefaultDimension = DimensionDefaultingEngine::getDefaultDimension(dimensionSources);

}
 

No comments:

Post a Comment