Tuesday, 16 July 2013

Dimension (DP class)

/// <summary>
/// Inserts common data into the template table buffer.
/// </summary>
protected void setPurchPurchaseOrderHeader()
{
DocuRef DocuRef;
purchTable purchTable;
DimensionAttributeValueSetStorage dimStorage;
Counter i;
DimensionAttributeValueSet dimAttrValueSet;
DimensionAttributeValueSetItem dimAttrValueSetItem;
DimensionAttributeValue dimAttrValue;
DimensionAttribute dimAttr;
Common dimensionValueEntity;
//VendPurchOrderJour VendPurchOrderJour;
int64 PurchRecid,PurchDim,TableId;
PurchIdBase purchID;
str st,c;
this.initializePurchPurchaseOrderHeader();
/*while select purchTable
{
dimStorage = DimensionAttributeValueSetStorage::find(PurchTable.DefaultDimension);
//PurchPurchaseOrderHeader.DimValue2 = DimensionAttribute::find(dimStorage.getAttributeByIndex(1)).Name;
PurchPurchaseOrderHeader.DimValue1 = dimStorage.getDisplayValueByIndex(1);
PurchPurchaseOrderHeader.Dim = DimensionAttribute::find(dimStorage.getAttributeByIndex(1)).Name;
while select DocuRef where DocuRef.RefRecId == purchTable.RecId && DocuRef.RefCompanyId == purchTable.dataAreaId
&& DocuRef.RefTableId == purchTable.TableId
PurchPurchaseOrderHeader.Notes1 = DocuRef.Notes;
}*/

while select PurchTable{
// if(purchTable.PurchId == VendPurchOrderJourloc.PurchaseOrderId)
purchID = VendPurchOrderJour::findbyPurchaseOrderId(PurchPurchaseOrderHeader.PurchaseOrderId).PurchId;
PurchRecid = purchTable::find(purchID).RecId;
PurchDim = purchTable::find(purchID).DefaultDimension;
TableId = PurchReqLine::findByPurchId(purchID).PurchReqTable;
c = PurchReqTable::find(TableId).PurchReqId;
PurchPurchaseOrderHeader.PurchReqId = c;
while select DocuRef where DocuRef.RefRecId == PurchRecid && DocuRef.RefCompanyId == purchTable.dataAreaId
&& DocuRef.RefTableId == purchTable.TableId
{
PurchPurchaseOrderHeader.Notes1 = DocuRef.Notes;
}
dimAttrValueSet = DimensionAttributeValueSet::find(PurchDim);
// Find all of the ‘value set items’ linked against the ‘value set’
while select dimAttrValueSetItem where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId
{
// Find the dimension ‘value’ (DimensionAttributeValue) that the set item points to.
dimAttrValue = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);
// Find the underlying attribute.
dimAttr = DimensionAttribute::find(dimAttrValue.DimensionAttribute);
// Use the helper class to obtain a reference to the underlying entity (can be anything)
dimensionValueEntity = DimensionDefaultingControllerBase::findBackingEntityInstance(
curext(),
dimAttr,
dimAttrValue.EntityInstance);
if(dimAttr.Name == “CostCenter”)
{
PurchPurchaseOrderHeader.Dim = dimAttr.Name;
PurchPurchaseOrderHeader.DimValue1 = dimAttrValue.getValue();
}
//info(dimAttr.Name + ‘ ‘ + dimAttrValue.getValue());
}
}
purchPurchaseOrderHeader.insert();
}


No comments:

Post a Comment