Friday, 24 June 2016

Change or Create Dimension for a particular Customer



Change or Create Dimension for a particular Customer: 



The below is the job to either create or modify customer dimensions...

static void setDefaultDimensionToCustomer(Args _args)
{
   CustTable custTable;
  Struct struct = new Struct();
  container ledgerDimension;
  DimensionDefault DimensionDefault;
  ;

  struct.add('Department', '00000031');
    struct.add('CostCenter', 'OU_3566');
  ledgerDimension += struct.fields();
  ledgerDimension += struct.fieldName(1);
  ledgerDimension += struct.valueIndex(1);
  ledgerDimension += struct.fieldName(2);
  ledgerDimension += struct.valueIndex(2);
  ttsBegin;
  DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
  custTable = CustTable::find('1101', true);   //1101 is Customer
  custTable.DefaultDimension = DimensionDefault;
  custTable.update();
  ttsCommit;

}



1 comment: