Wednesday, 7 October 2015

create financial dimension combination:

create financial dimension combination:
job:



static void FindorcreatefinancialDimesion(Args _args)
{

    DimensionAttributeValue             dimCostcenterVal,dimDepartmentVal,dimCountryVal;
    DimensionAttribute                  dimAttrCostcenter,dimAttrDepartment, dimCountry;
    DimensionAttributeValueSetStorage   davss;
    boolean                             isValidDimension = true;
    DimensionDefault   DefaultDimension;


    davss = DimensionAttributeValueSetStorage::find(DefaultDimension);
    dimAttrCostcenter           =   DimensionAttribute::findByName('CostCenter');
    dimAttrDepartment           =   DimensionAttribute::findByName('Department');
    //dimCountry              =   DimensionAttribute::findByName('Country');

    dimCostcenterVal      =   DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttrCostcenter, "00000021", false , true);
    dimDepartmentVal      =   DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttrDepartment, "00000042" , false, true);
    //dimCountryVal         =   DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimCountry, _mSSalesTable.CountryRegionCode , false, true);



    if(dimCostcenterVal )
    {
        davss.addItem(dimCostcenterVal);
    }
    if (dimDepartmentVal)
    {
        davss.addItem(dimDepartmentVal);
    }
        //davss.addItem(dimCountryVal);
    if(dimCostcenterVal || dimDepartmentVal)
       {
           DefaultDimension =   davss.save();
           //return DefaultDimension;
           info(strFmt("%1",DefaultDimension));
       }
    //else
        // return "";

    //}

}




sales table:


/// <summary>
/// Set the financial dimension based on customer details
/// </summary>
/// <param name="_mSSalesTable">
/// _mSSalesTable
/// </param>
/// <returns>
/// defaultDimension
/// </returns>
/// <remarks>
/// SO order manangement
/// </remarks>
/// <exception cref="Exception::Error">
/// exception
/// </exception>
private static DimensionDefault setFinancialDimension(MSSalesTable _mSSalesTable, SalesTable salesTable)
{
    DimensionAttributeValue             dimAttrRegionVal,dimAtrrSubProgramVal,dimCountryVal;
    DimensionAttribute                  dimAttrRegion,dimAtrrSubProgram, dimCountry;
    DimensionAttributeValueSetStorage   davss;
    boolean                             isValidDimension = true;


    davss = DimensionAttributeValueSetStorage::find(salesTable.DefaultDimension);
    dimAttrRegion           =   DimensionAttribute::findByName('Region');
    dimAtrrSubProgram       =   DimensionAttribute::findByName('SubProgram');
    dimCountry              =   DimensionAttribute::findByName('Country');

    dimAttrRegionVal      =   DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttrRegion, _mSSalesTable.Region, false , true);
    dimAtrrSubProgramVal  =   DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAtrrSubProgram, _mSSalesTable.SubRegion , false, true);
    dimCountryVal         =   DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimCountry, _mSSalesTable.CountryRegionCode , false, true);

    if (!dimAttrRegionVal)
    {
        isValidDimension = false;
        _mSSalesTable.Comments = strFmt("@MPR4954", _mSSalesTable.Region);
    }
    if (!dimAtrrSubProgramVal)
    {
        isValidDimension = false;
        _mSSalesTable.Comments =  _mSSalesTable.Comments + '\n' + strFmt("@MPR4955", _mSSalesTable.SubRegion);
    }

    if (!dimCountryVal)
    {
        isValidDimension = false;
        _mSSalesTable.Comments =  _mSSalesTable.Comments + '\n' + strFmt("@MPR4956", _mSSalesTable.CountryRegionCode);
    }
    if (!isValidDimension)
    {
        ttsBegin;
        _mSSalesTable.selectForUpdate(true);
        _mSSalesTable.update();
        ttsCommit;
        throw error("@MPR4959");
    }


    if(dimAttrRegionVal && dimAtrrSubProgramVal && dimCountryVal )
    {
        davss.addItem(dimAttrRegionVal);
        davss.addItem(dimAtrrSubProgramVal);
        davss.addItem(dimCountryVal);

        return  davss.save();
    }

    return 0;
}


my code in class:

/// <summary>
/// for getting dimension id 
/// </summary>
/// <param name="_dataRecord">
/// 2009 data record
/// </param>
/// <returns>
/// returns financial dimension
/// </returns>
/// <remarks>
/// added by v-irsha for get dimension id
/// </remarks>

public DimensionDefault findDefaultDimId(AxeDataRecord _dataRecord)
{

    DimensionAttributeValue             dimCostcenterVal,dimDepartmentVal;
    DimensionAttribute                  dimAttrCostcenter,dimAttrDepartment;
    DimensionAttributeValueSetStorage   davss;
    boolean                             isValidDimension = true;
    DimensionDefault                    DefaultDimension;


    davss = DimensionAttributeValueSetStorage::find(DefaultDimension);
    dimAttrCostcenter           =   DimensionAttribute::findByName('CostCenter');
    dimAttrDepartment           =   DimensionAttribute::findByName('Department');

    dimCostcenterVal      =   DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttrCostcenter, _dataRecord.value('Dimension2_'), false , true);
    dimDepartmentVal      =   DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttrDepartment, _dataRecord.value('Dimension') , false, true);



    if(dimCostcenterVal )
    {
        davss.addItem(dimCostcenterVal);
    }
    if (dimDepartmentVal)
    {
        davss.addItem(dimDepartmentVal);
    }
    
    if(dimCostcenterVal || dimDepartmentVal)
    {
        DefaultDimension =   davss.save();
        return DefaultDimension;
    }
    else
        return 0;

}








No comments:

Post a Comment