Make Flow Wait

 4 Replies
 0 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
SP
Veteran Member
Posts: 122
Veteran Member
    Does anyone have any good suggestions on how to make a flow wait before continuing execution?

    I am working on a flow with multiple webrun nodes and would like the flow to wait until one job is complete before continuing to the next.

    Any help would be greatly appreciated.

    -SP
    Bob Canham
    Veteran Member
    Posts: 217
    Veteran Member
      If you are just looking to pause the execution, I was able to do this using the syscmd node on our AIX server. It has a sleep command that takes the number of seconds, so if you wanted to pause for 30 secs, you can just do a syscmd node with "sleep 30" as the command. This is assuming you're on AIX.

      Otherwise, I also did a loop for one where I queried the job status to determine when the job is done, it would keep looping until it returned something other than WAITING and RUNNING. I used a syscmd with the "jqstatus" command to get status, but I've also heard people use the QUEUEDJOB table in GEN.
      SP
      Veteran Member
      Posts: 122
      Veteran Member
        This is on a Windows. I tried the syscommand but it didn't perform the "sleep 15" at all. However, I was running a shell script first to update another jobs job parameters first, then the next line had the sleep command. I'm sure there is some Execution mode that will accomplish the sleep for me, but as I think this through, I'm not sure that's going to get me what I need.

        I've gone ahead and started down the SQL Query path against QUEUEDJOB. My concern now is making sure I am getting exactly the right QUEUEDJOB record in the even that the job has been submitted more than once today.

        It looks like a simple SELECT STATUS FROM QUEUEDJOB WHERE JOBNUMBER = ( SELECT MAX (JOBNUMBER) FROM QUEUEDJOB WHERE JOBNAME = 'MYJOBNAME') will work.

        At a high level what I have are several custom tokens setup as batch jobs which run scripts to update core Lawson job (IMDBB, GL165, etc...) parameters (change import file names, posting periods, etc...).

        We have over 70+ systems that interface transactions into our GL everyday. This requires one FTE to run the IMDBB, GL165, and GL190's all day. I am about to automate all of it so the FTE can be repurposed and move on to more important work. :-)



        I think I got everything working now.
        Sam Simpson
        Veteran Member
        Posts: 239
        Veteran Member
          Here's a javascript you can add to your pflow.js. Just call the script with mill = time in milliseconds. This is the time that everything paused:

          function startPause(mill, tdiff)
          {
          var lastdate = new Date();
          var currdate = null;
          var tdiff = 0;

          do { currdate = new Date();
          tdiff = currdate-lastdate; }
          while(currdate-lastdate < mill);
          return tdiff;
          }
          SP
          Veteran Member
          Posts: 122
          Veteran Member
            Thanks Sam.  This is perfect.

            I originally thought I would just query queuedjob until the job was complete, but it's amazing how many sql selects can be made while a job runs.  The thread count spiked, so I decided to drop your nice little wait code in the middle of my gen queries and wait 5 seconds each time.  Voila!!  Very Nice.

            Thanks again.


            Posted By Sam Simpson on 02/15/2012 05:02 PM
            Here's a javascript you can add to your pflow.js. Just call the script with mill = time in milliseconds. This is the time that everything paused:

            function startPause(mill, tdiff)
            {
            var lastdate = new Date();
            var currdate = null;
            var tdiff = 0;

            do { currdate = new Date();
            tdiff = currdate-lastdate; }
            while(currdate-lastdate < mill);
            return tdiff;
            }