Upload report data to a UD table

I use this type of a routine to do this. It is post processing in GetList of the baq, because it uses UpdateExt. You could run the 4 BAQS from a scheduled function and add data using the same keys. I got the function from the forum.

/* Update UD28 for WIP Charting */

Ice.Diagnostics.Log.WriteEntry(" In Update UD28");

using (var updater = this.getDataUpdater("Ice", "UD28"))
{
  var resultQuery = result.Results;
  //.Where(row => !string.IsNullOrEmpty(row.RowMod) && row.RowMod != "P");

  DateTime todaysDate = DateTime.Now;

    Ice.Diagnostics.Log.WriteEntry($"Updating wip Today is {todaysDate} ");
    foreach (var ttr in resultQuery)
    {
      string saveDateKey = String.Format("{0:MM-dd-yy}",todaysDate);

        var ds = new Ice.Tablesets.UpdExtUD28Tableset();

        // Query to object mapping
        //{
        var UD28 = new Ice.Tablesets.UD28Row
        {
          Company = Constants.CurrentCompany,
          Key1 = "WIP",
          Key2 = ttr.PartClass_ClassID,
          Key3 = ttr.Calculated_FiscalPD,
          Key4 = ttr.Calculated_FiscalQtr,
          Key5 = saveDateKey,

        };


        UD28.SetUDField<System.Decimal>("Number01" , ttr.Calculated_WipMtl);

        UD28.SetUDField<System.Decimal>("Number02" , ttr.Calculated_WIPLabor);
        UD28.SetUDField<System.Decimal>("Number03" , ttr.Calculated_WIPBrdn);
        UD28.SetUDField<System.Decimal>("Number04" , ttr.Calculated_WIPFOH);
        UD28.SetUDField<System.Decimal>("Number05" , ttr.Calculated_WIPTotal);
        UD28.SetUDField<System.Decimal>("Number06" , ttr.Calculated_WIPDays);

        UD28.SetUDField<System.DateTime?>("Date01" , todaysDate);
        
        UD28.SetUDField<System.String>("ShortChar01" , ttr.PartClass_ShortChar01);
        UD28.SetUDField<System.String>("ShortChar02" , ttr.Calculated_ProdGroup);

        ds.UD28.Add(UD28);

      BOUpdErrorTableset boUpdateErrors = updater.Update(ref ds);
      //      if (this.BpmDataFormIsPublished()) return;
      Ice.Diagnostics.Log.WriteEntry($"Updating  Today is {saveDateKey} WIP { Math.Round(ttr.Calculated_WIPTotal,2)} for period {ttr.Calculated_FiscalPD}");
    
    }

}
1 Like