ProcessFlow - Moving Workunits to History - For a date range Query

 1 Replies
 0 Subscribed to this topic
 27 Subscribed to this forum
Sort:
Author
Messages
Saurabh
Veteran Member
Posts: 94
Veteran Member
    Hi All

    We would like to move all the Completed Workunits in Processflow into History table which are older than currentdate i.e currdate() -7 .

    Does anyone know if i can use the date option when calling the following as with the purge

                     MoveWorkUnitToHistory Move  ...

    Thanks
    Saurabh

    Norm
    Veteran Member
    Posts: 40
    Veteran Member

      Haven't tried that approach, but here's a perl script we use to accomplish the same thing.  The key is the assignment of the @lasmon array, which gets set to 31 days ago:

      my @lasmon = localtime(time() - 31*86400);

      A lot of the code is getting zero-fill on month and day and I don't even know if that's required.  I just lifted that section of code from a co-worker and I don't tend to mess with what's not broken.

      If you're going to use this, remember to change appropriately for your setup, especially the $TMP and $pl variables, which probably won't work for you as-is

       

      #!/usr/bin/perl
      use strict;
      my $GENDIR = join '/', split /\\/, $ENV{GENDIR};
      my $LAWDIR = join '/', split /\\/, $ENV{LAWDIR};
      my $TMP = "$LAWDIR/cchs/temp";
      my $pl = substr($LAWDIR,2,3);

      my @lasmon = localtime(time() - 31*86400);
      $lasmon[5] = $lasmon[5] + 1900;
      $lasmon[4] = $lasmon[4] + 1;
      if( $lasmon[4] < 10 )
      { $lasmon[4] = "0$lasmon[4]"; }
      if( $lasmon[3] < 10 )
      { $lasmon[3] = "0$lasmon[3]"; }
      my $purgedate = "$lasmon[4]/$lasmon[3]/$lasmon[5]";

      my $rdate = `date "+%m/%d/%Y"`;
      chomp($rdate);

      print "Run Date <$rdate>, Purge Thru <$purgedate>\n";
      print "perl $GENDIR/bin/batch.pl MoveWorkunitToHistory move -outputFileName $TMP/pwf.purged -processThruDate $purgedate\n";
      system("perl $GENDIR/bin/batch.pl MoveWorkunitToHistory move -outputFileName $TMP/pwf.purged -processThruDate $purgedate");
      exit;