Sunday, July 3, 2016

Vaidation Account structure by Ledger account and combination value ax 2012

//Vaidation Account structure by Ledger account and combination value

static void ValidateLedgerDimensionByAccStructure(Args _args)
{
   str mainAcctNum = "23010101";
   LedgerAccountValidationContract validationContract;
   LedgerAccountContract           accountContract;
   DimensionAttributeValueContract valueContract;
   FinancialDimensionValidationService service;
   
   List listValueContract = new List(Types::Class);
   // Business Unit
   valueContract = new DimensionAttributeValueContract();
   valueContract.parmName("BusinessUnit");
   valueContract.parmValue("207");
   listValueContract.addEnd(valueContract);  
    // Department
   valueContract = new DimensionAttributeValueContract();
   valueContract.parmName("Department");
   valueContract.parmValue("2");
    listValueContract.addEnd(valueContract);
   // Cost Center
   valueContract = new DimensionAttributeValueContract();
   valueContract.parmName("CostCenter");
   valueContract.parmValue("611");
   listValueContract.addEnd(valueContract);
   
   accountContract = new LedgerAccountContract();
   accountContract.parmMainAccount(mainAcctNum);
   accountContract.parmValues(listValueContract);
   validationContract = new LedgerAccountValidationContract();
   validationContract.parmLedgerAccount(accountContract);
   validationContract.parmValidDate(systemDateGet());
   service = new FinancialDimensionValidationService();
   
   if (service.validateLedgerAccount(validationContract))
   {
       info("Valid");
   }
   else
   {
       info("Invalid");
   }
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...