AutoSys Workload Automation

 View Only
  • 1.  CAWA DE - create monthly and quarterly date variables

    Posted Jan 30, 2020 01:57 PM
    Does anyone have samples of creating Monthly or Quarterly date variables? Or links to sites that can help me determine the syntax for wording scheduling criteria appropriately? 

    Example of Monthly - 

    Job scans in on the 1/26/2020, and I need to calculate the last Monday of the previous month resulting in 12/29/2019.

    In my example below saying "less 1 month" calculates 30 days from the 26th and creates a variable (26-12-2019). How do I say last Sunday previous month?

    genTime('M2','Sunday this week less 1 month');
    APPL.PSTHRU2=M2DD + "-" + M2MM + "-" + M2YEAR;

    Having fun? I also need a solution for a Quarterly date.

    Same scenario job scans in on 3/22/2020, and I need to calculate back to 12/29/2019.

    genTime('Q2','Sunday this week less 3 months');
    APPL.PSTHRU3=Q2DD + "-" + Q2MM + "-" + Q2YEAR;


  • 2.  RE: CAWA DE - create monthly and quarterly date variables

    Broadcom Employee
    Posted Jan 30, 2020 02:42 PM
    Hey there....
    I did not test this but it may work.... I would want to test out every scenario.... depending on what day the 26th falls on... 
    genTime('M2','Sunday less 4 weeks');
    I think if that is not complex enough we could determine when it should subtract 4 or 5 weeks....... 


    Don


  • 3.  RE: CAWA DE - create monthly and quarterly date variables

    Broadcom Employee
    Posted Jan 31, 2020 08:50 AM
    Hi 
    I will play with this a little bit.  I think I can make it work in every case. I will have to add some logic for the 4 or 5 week scenario. The 3 week does not come into play since subtracting 3 weeks(21 days) from 26th never gets back to the previous month. 

    Today does not look good but I will see if I can test something on Monday.... 


    Don


  • 4.  RE: CAWA DE - create monthly and quarterly date variables

    Broadcom Employee
    Posted Jan 31, 2020 09:30 AM
    Hi, 
    I believe this will satisfy every scenario.
    The logic is this. If it goes back 4 Sundays and it is still in the current month it will go back 5 Sundays to the previous month. 
    I suggest testing it for every scenario... 

    genTime('M2','Sunday less 4 weeks');
    DTE1=M2DD + "-" + M2MM + "-" + M2YEAR;
    if ( M2MM == APPL._SMM )
    {
    genTime('M3','Sunday less 5 weeks');
    DTE1=M3DD + "-" + M3MM + "-" + M3YEAR;
    }


    Don


  • 5.  RE: CAWA DE - create monthly and quarterly date variables

    Posted Jan 31, 2020 10:16 AM
    Hey Don,

    In an effort to keep this simple I worded my request based on last Sunday of month. I figured if I get some very inventive solutions I can run with those and adjust it to my real world need.

    The date being used isn't always the last Sunday (I lied :) ). This is for payroll so I do have situations where I have 3,4 and 5 week spans. In looking real close at the whole year it looks like the month-end date I'm using is the Sunday of the last full week in the month. Feb, Mar, Apr, Jun, Aug, Sep, Nov are 3 week spans.

    Our motto in scheduling has always been if you can say it we can schedule it! I think there are teams who are trying to break us, lol! 

    I really appreciate you advise, thanks!!
    KSki


  • 6.  RE: CAWA DE - create monthly and quarterly date variables
    Best Answer

    Broadcom Employee
    Posted Jan 31, 2020 11:17 AM
    Hi, 
    Added steroids.... 
    I believe the code below will find the LAST LAST SUNDAY OF THE PRIOR MONTH" . It does not matter what day you start with in the month.  This may be what you need.  I suggest testing thoroughly. 

    genTime('M1','Sunday less 1 weeks');
    DTE1=M1DD + "-" + M1MM + "-" + M1YEAR;
    if ( M1MM == APPL._SMM )
    {
        genTime('M2','Sunday less 2 weeks');
        DTE1=M2DD + "-" + M2MM + "-" + M2YEAR;
        if ( M2MM == APPL._SMM )
        {
            genTime('M3','Sunday less 3 weeks');
            DTE1=M3DD + "-" + M3MM + "-" + M3YEAR;
            if ( M3MM == APPL._SMM )
            (
                genTime('M4','Sunday less 4 weeks');
                DTE1=M4DD + "-" + M4MM + "-" + M4YEAR;
                if ( M4MM == APPL._SMM )
                {
                    genTime('M5','Sunday less 5 weeks');
                    DTE1=M5DD + "-" + M5MM + "-" + M5YEAR;
                }
            }
        }
    }


    Don


  • 7.  RE: CAWA DE - create monthly and quarterly date variables

    Posted Feb 04, 2020 06:31 AM
    Thanks everyone for your input. I have my solution.

    /* ZPYR815 - Weekly Dates */
       genTime('W1','Sunday this week');
           APPL.PSFROM1=W1DD + "-" + W1MM + "-" + W1YEAR;
       genTime('W2','Monday this week less 7 days');
            APPL.PSTHRU1=W2DD + "-" + W2MM + "-" + W2YEAR;

    /* ZPYR815 - Monthly Dates */
       genTime('M1','Sunday this week');
         APPL.PSFROM2=M1DD + "-" + M1MM + "-" + M1YEAR;
     /* ZPYR815 - Monthly - Last full week of Month */        
    genTime('M2','Sunday less 1 weeks');
    APPL.PSTHRU2=M2DD + "-" + M2MM + "-" + M2YEAR;
    if ( M2MM == APPL._SMM )
    {
        genTime('M3','Sunday less 2 weeks');
        APPL.PSTHRU2=M3DD + "-" + M3MM + "-" + M3YEAR;
        if ( M3MM == APPL._SMM )
        {
            genTime('M4','Sunday less 3 weeks');
            APPL.PSTHRU2=M4DD + "-" + M4MM + "-" + M4YEAR;
            if ( M4MM == APPL._SMM )
            {
                genTime('M5','Sunday less 4 weeks');
                APPL.PSTHRU2=M5DD + "-" + M5MM + "-" + M5YEAR;
                if ( M5MM == APPL._SMM )
                {
                    genTime('M6','Sunday less 5 weeks');
                    APPL.PSTHRU2=M6DD + "-" + M6MM + "-" + M6YEAR;
                }
      }
     }
    }

    /* ZPYR815 - Quarterly Dates */
       genTime('Q1','Sunday this week');
           APPL.PSFROM3=Q1DD + "-" + Q1MM + "-" + Q1YEAR;
       genTime('Q2','Sunday this week less 12 weeks');
            APPL.PSTHRU3=Q2DD + "-" + Q2MM + "-" + Q2YEAR;



  • 8.  RE: CAWA DE - create monthly and quarterly date variables

    Posted Jan 31, 2020 02:36 PM
    For the last Sunday of the previous month, you can use genTime('LMPM','First Sunday this month less 1 week');

    For the Quarterly date, the following works:
    genTime('temp','today less 2 months');
    genTime('LSPQ','Sunday 01 ' + tempMONTH + ', ' + tempYEAR + ' less 1 week');


    ------------------------------
    Randy Snyder
    Associated Wholesale Grocers
    ------------------------------



  • 9.  RE: CAWA DE - create monthly and quarterly date variables

    Posted Feb 01, 2020 07:31 AM
    Seeing that you actually need the Sunday for the last full week of the month, let me modify my solution.

    For the last Sunday of the previous month, you can use genTime('LMPM','First Saturday this month less 13 days');

    For the Quarterly date, the following works:
    genTime('temp','today less 2 months');
    genTime('LSPQ','Saturday 01 ' + tempMONTH + ', ' + tempYEAR + ' less 13 days');

    ------------------------------
    Randy Snyder
    Associated Wholesale Grocers
    ------------------------------