Pages

Banner 468 x 60px

 

Wednesday, November 22, 2017

Fetching Financial Dimension Value X++

0 comments

 Fetching Financial Dimension Value X++

static void Get_DimensionDisplayValue(Args _args)
{
    DimensionAttributeValueSetStorage   class_dimStorage;
    DimensionAttributeLevelValueAllView view_dimAttrView;
    DimAttributeOMBusinessUnit          table_OmBusinessUnit;
    str 30                              department, Name;
    PurchTable                          _purchTable;
   
    _purchTable = PurchTable::find('000040');
    class_dimStorage = DimensionAttributeValueSetStorage::find(_purchTable.DefaultDimension);
   
    department = class_dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName('Department').RecId);
   
    name = (select Name from DimAttributeOMDepartment where DimAttributeOMDepartment.value ==
    department).name;
    info(strFmt('Display Value : %1', department));
    info(strFmt('Display name  : %1', Name));
}






static void Fetching_Financial_Dimension_Value(Args _args)
{
    PurchTable                          _purchTable;  
    DimensionAttributeValueSetStorage   class_dimStorage;
    str                                 dimvalue;
   
    _purchTable = PurchTable::find('PO-000007');
    class_dimStorage = DimensionAttributeValueSetStorage::find(_purchTable.DefaultDimension);
   
    info(strFmt('Purchase Order PO-000007, Department : %1',  
    class_dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName('Department').RecId)));
 }

 

 

 

 

Fetching Financial Dimension Value X++

This post shows the code for extracting Financial Dimension value by providing dimension name for each dimension combination which is created and persisted.

The DimensionAttributeValueCombination table contains information about accounts and various dimensions combinations that are used. However, they are stored as a combination ex: (100010-AX-00001- – – -). These values are retrieved through DimensionAttributeValueSetStorage storage class. This class can be used to manipulate these combinations.

The job below helps you in finding out the required values.


static void AI_GetProjectCostCenterValue(Args _args)
{
    ProjTable                           projTable;
    DimensionAttributeValueSetStorage   dimStorage;
    str                                 dimValue;
       
    projTable = projTable::find('000409');
    dimStorage = DimensionAttributeValueSetStorage::find
                 projTable.DefaultDimension);
    
    info(strFmt('Project 000409, Cost Center value : %1',                        dimStorage.getDisplayValueByDimensionAttribute(                      DimensionAttribute::findByName('CostCenter').RecId)));
    
}



Output





.:: SAMPLE ::.
/// <summary>
/// Inserts the record field data into the temporary table.
/// </summary>
/// <param name="_purchOrderTransOrTaxTrans">
/// A <c>Boolean</c> value that indicates whether the transaction has a trans or tax value.
/// </param>
protected void setPurchPurchaseOrderDetails(boolean      _purchOrderTransOrTaxTrans)
{
    DocuRefSearch                       docuRefSearch;
    PurchLine                           purchLine;
    PurchAgreementHeader                purchAgreementHeader;

    // add by adit
    DimensionAttributeValueSetStorage   class_dimStorage;
    DimensionAttributeLevelValueAllView view_dimAttrView;
    DimAttributeOMBusinessUnit          table_OmBusinessUnit;
    str 30                              department, Name;
    //DimensionAttributeValueSet          DAVS;
    DimensionAttributeValueSet          DAVS;

    // end by adit

    //Set the common data from temporary buffer
    purchPurchaseOrderTmp.clear();

    if (this.isPurchConfirmationRequestJournal())
    {
        purchPurchaseOrderTmp.JournalRecId = purchConfirmationRequestJour.RecId;
    }
    else
    {
        purchPurchaseOrderTmp.JournalRecId = vendPurchOrderJour.RecId;
    }

    //VendPurchOrderJour - Body
    if(_purchOrderTransOrTaxTrans == NoYes::Yes)
    {
        //Purch Order Trans
        purchPurchaseOrderTmp.ItemId                 = this.itemId();
        purchPurchaseOrderTmp.PurchaseLineLineNumber = purchLineAllVersions.LineNumber;
        purchPurchaseOrderTmp.Name                   = purchLineAllVersions.Name;
        purchPurchaseOrderTmp.DeliveryDate           = purchLineAllVersions.DeliveryDate;
        purchPurchaseOrderTmp.Qty                    = purchLineAllVersions.PurchQty;
        purchPurchaseOrderTmp.PurchUnitTxt           = this.purchUnitTxt();
        purchPurchaseOrderTmp.PurchPrice             = purchLineAllVersions.PurchPrice;
        purchPurchaseOrderTmp.DiscPercent            = purchLineAllVersions.DiscPercent;
        purchPurchaseOrderTmp.DiscAmount             = purchLineAllVersions.DiscAmount;
        purchPurchaseOrderTmp.LineAmount             = purchLineAllVersions.LineAmount;
        purchPurchaseOrderTmp.CurrencyCode           = purchLineAllVersions.CurrencyCode;
        purchPurchaseOrderTmp.TaxWriteCode           = purchLineAllVersions.ConfirmedTaxWriteCode;

        // add by adit
            purchPurchaseOrderTmp.OrderAccount           = purchTableAllVersions.OrderAccount;
            purchPurchaseOrderTmp.AddressCity            = VendTable::find(purchTableAllVersions.OrderAccount).postalAddress().Address;
            purchPurchaseOrderTmp.Phone                  = vendTable::find(purchTableAllVersions.OrderAccount).phone();
            purchPurchaseOrderTmp.Inwords                = numeralsToTxt(purchPurchaseOrderHeader.Amount) + " [ Rupiah ]";

            select _purchtable where _purchtable.PurchId == purchTableAllVersions.PurchId;
            _purchTable        = Purchtable::find(purchLineAllVersions.PurchId);

            class_dimStorage    = DimensionAttributeValueSetStorage::find(_purchTable.DefaultDimension);

            department          = class_dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName('Department').RecId);
            name                = (select Name from DimAttributeOMDepartment where DimAttributeOMDepartment.value == department).name;
            info(strFmt('Display Value : %1', department));
            info(strFmt('Display name  : %1', Name));
        // end by adit

        if (pdsCWEnabled)
        {
            purchPurchaseOrderTmp.PdsCWUnitId        = purchLineAllVersions.pdsCWUnitId();
            purchPurchaseOrderTmp.PdsCWQty           = purchLineAllVersions.PdsCWQty;
        }

        purchPurchaseOrderTmp.IsUpdated              = this.isLineUpdated();

        if (purchLineAllVersions.MatchingAgreementLine)
        {
            if (!agreementNote)
            {
                purchAgreementHeader = PurchAgreementHeader::find(purchTableAllVersions.MatchingAgreement);
                agreementNote = strFmt("@GLS180177", purchAgreementHeader.DocumentExternalReference ? purchAgreementHeader.DocumentExternalReference : purchAgreementHeader.PurchNumberSequence);
            }
            purchPurchaseOrderTmp.AgreementReferenceNotes = agreementNote;
        }

        //ExternalItemNum
        purchPurchaseOrderTmp.ExternalItemNum        = FormLetter::journalExternalItemId(ModuleInventPurchSales::Purch, purchLineAllVersions.ExternalItemId);

        if (this.isPurchConfirmationRequestJournal())
        {
            if (purchLineAllVersions.IsArchived)
            {
                purchLine = PurchLine::findInventTransId(purchLineAllVersions.InventTransId);
            }
            else
            {
                purchLine.RecId = purchLineAllVersions.RecId1;
            }
            docuRefSearch = DocuRefSearch::newTypeIdAndRestriction(purchLine, vendFormletterDocument.DocuTypePurchOrderConfirmationRequest, DocuRestriction::External);
            purchPurchaseOrderTmp.NotesTrans = Docu::concatDocuRefNotes(docuRefSearch);
        }
        else if ((vendFormletterDocument.DocuOnPurchOrder == DocuOnFormular::Line)
         || (vendFormletterDocument.DocuOnPurchOrder == DocuOnFormular::All))
        {
            if (purchLineAllVersions.IsArchived)
            {
                purchLine = PurchLine::findInventTransId(purchLineAllVersions.InventTransId);
            }
            else
            {
                purchLine.RecId = purchLineAllVersions.RecId1;
            }
            docuRefSearch = DocuRefSearch::newTypeIdAndRestriction(purchLine, vendFormletterDocument.DocuTypePurchOrder, DocuRestriction::External);
            purchPurchaseOrderTmp.NotesTrans        = Docu::concatDocuRefNotes(docuRefSearch);
        }

        purchPurchaseOrderTmp.InventDimQtyPrint     = this.printDimHistory();

        if (insertInventDim)
        {
            purchPurchaseOrderTmp.InventDimStr      = FormLetter::inventDimReport(inventDim, inventDimProductSetup, purchTableAllVersions.LanguageId);
        }

        // RFQId and Quote Number
        purchPurchaseOrderTmp.rfqId                 = this.purchRFQId();
        purchPurchaseOrderTmp.QuoteNumber           = this.purchQuoteNumber();

        purchPurchaseOrderTmp.MCRDropShipComment    = purchLineAllVersions.MCRPurchLineHistory().MCRDropShipComment;
    }
    else
    {
        purchPurchaseOrderTmp.PrintCode             = taxSpec.taxWriteCode();
        purchPurchaseOrderTmp.TaxCode               = taxSpec.taxCode();
        purchPurchaseOrderTmp.TaxBaseAmount         = taxSpec.taxBaseAmount();
        purchPurchaseOrderTmp.TaxBaseQty            = taxSpec.taxBaseQty();
        purchPurchaseOrderTmp.TaxAmount             = taxSpec.taxAmount();
        if (printTaxAmountMST)
        {
            purchPurchaseOrderTmp.TaxAmountMST      = taxSpec.taxAmountMST();
        }
        purchPurchaseOrderTmp.TaxExemptDescription  = taxSpec.taxExemptDescription();

        // <GEEHU>
        if (purchPurchaseOrderHeader.PrintTaxAmountSalesExchangeRate && SysCountryRegionCode::isLegalEntityInCountryRegion([#isoHU]))
        {
            purchPurchaseOrderTmp.TaxAmountMST      = taxSpec.taxAmountMST();
            purchPurchaseOrderTmp.TaxBaseAmountMST  = taxSpec.taxBaseAmountMST();
        }
        // </GEEHU>
    }

    purchPurchaseOrderTmp.PurchOrderTransOrTaxTrans = _purchOrderTransOrTaxTrans;

    purchPurchaseOrderTmp.insert();
}


0 comments:

A financial dimension value is based on the LAND-00013 record and has been used on a transaction. You cannot delete the LAND-00013 record AX 2012

 A financial dimension value is based on the LAND-00013 record and has been used on a  transaction. You cannot delete the LAND-00013 record ...