How to check missed schedules of custom scheduler?

Hello,
I have created a custom scheduler that has been running fine, but it depends on SQL Server Agent service. I want it to process missed schedules after a potential downtime.
CREATE TABLE [dbo].[Schedules](
[Id] [int] NOT NULL,
[Frequency] [int] NOT NULL,
[Time] [time](0) NOT NULL,
[Days] [int] NOT NULL
) ON [PRIMARY]
GO
INSERT INTO Schedules VALUES (1,1,'01:00:00',16);
INSERT INTO Schedules VALUES (2,1,'23:30:00',62);
INSERT INTO Schedules VALUES (3,1,'18:00:00',127);
INSERT INTO Schedules VALUES (4,2,'01:00:00',16);
INSERT INTO Schedules VALUES (5,2,'02:30:00',8);
INSERT INTO Schedules VALUES (6,2,'23:30:00',127);
GO
The following is the query I run every minute to capture the schedules to run at that minute.
DECLARE @dt datetime,
@tm time(0),
@wd int;
SELECT @dt = CONVERT(char(16),Getdate(),121); --Zero out seconds and milliseconds
--SELECT @dt = CONVERT(char(16),'2014-02-25 09:39:25.443',121);
SELECT @tm = CAST(@dt as time(0));
SELECT @wd = DATEPART(weekday,@dt) -1; -- Sunday=0, Monday=1,...,Saturday=6
SELECT Id, Frequency, Time, Days
FROM Schedules
WHERE
(frequency = 2 --Daily
AND days & power(2,@wd) <> 0
AND datepart(hour,time) = datepart(hour,@tm)
AND datepart(minute,time) = datepart(minute,@tm))
OR
(frequency = 1 --Hourly
AND datepart(minute,time) = datepart(minute,@tm));
Now, I need to create a query/sproc which will returns schedule ids between two dates. I will populate the dates; the datetime of last executed schedule (id) as @StartDate, and maybe GetDate() as @EndDate. I can later run that sproc as a strtup sproc for
SQL Agent service.
usp_FindMissedSchedules @StartDate, @EndDate;
No simple approach comes to my mind.
Thanks,
Kuzey

You can do this by creating a CTE that will include one row for every minute of every day between @StartDate and EndDate and then cross joining it to your Schedules table.  So
Declare @StartDate datetime = '20140218 10:07';
Declare @EndDate datetime = GetDate();
With cte As
(Select DateAdd(minute, 1, @StartDate) As EachMinute
Union All
Select DateAdd(minute, 1, c.EachMinute) As EachMinute
From cte c
Where c.EachMinute < GetDate())
Select s.Id, s.Frequency, s.Time, s.Days, c.EachMinute As ShouldHaveBeenRunAt
From cte c
Cross Join dbo.Schedules s
WHERE
(frequency = 2 --Daily
AND days & power(2,DateDiff(day, '18991231' /* because Dec 31, 1899 was a Sunday */, c.EachMinute) % 7) <> 0
AND datepart(hour,time) = datepart(hour,c.EachMinute)
AND datepart(minute,time) = datepart(minute,c.EachMinute))
OR
(frequency = 1 --Hourly
AND datepart(minute,time) = datepart(minute,c.EachMinute))
Order By c.EachMinute, s.Id
Option(MaxRecursion 0);
I used a different method to determine Sunday = 0, Monday = 1, etc.  It can be problematic to use DATEPART(weekday ...) to determine the day of the week.  The value returned by DATEPART depends on the value of DATEFIRST.  And the default value
of DATEFIRST depends on the language set on the user's PC.  If someone who has a PC set up as English UK runs DATEPART(weekday...) for a Saturday date, they don't get 7 as the result, they get 6.
A safe way to the Sunday = 0, Monday = 1, etc is to do DateDiff(days, ...), divide by 7 and take the remainder (that"s what the % 7 does in the above code) where you use a date that is a Sunday.  This is what I did in the code above.  You can pick
any Sunday, I choose Dec 31, 1899.  That way your code works no matter what the value of DATEFIRST is.
Tom

Similar Messages

  • How to check IDOC Serialization for custom idoc

    In one of my interfaces, we are receiving idocs ARTMAS, INFREC, COND_A and ZMD_ARTHIER in ECC system.Last one is customized one in which basically we have to assign one article to an article hierarchy. So this idoc will contain only article no, hierarchy id and node level in which article will be assigned.
    Now here we have to implement idoc serialization so that if ARTMAS in any case fails then INFREC, COND_A and ZMD_ARTHIER idocs should not be posted. We will be using RBDSER04 program for inbound processing.
    My concern is that whether we have to do any special coding for serialization check in custom function module for the last idoc ZMD_ARTHIER.
    If yes, please please let me know how to do handle that in custom inbound function module.
    Edited by: suman pandit on May 19, 2009 10:47 AM

    Hi,
    you need to create a serialization group (in customizing) and assign all the IDocs (in specific order) to this group incl. your custom IDoc.
    When data is transfered first a SERDAT01 IDoc will be sent, after this your IDocs have to follow in specific order. At last again a SERDAT01 follows and triggers the processing in the destination system.
    Regards,
    Kai

  • How to check the scheduled process chain in SM37

    Hi Experts,
    Can anyone tell me how do I check whether my process chain has been scheduled or not.
    I checked in sm37 all the jobs that are under released status. Im getting about 10 jobs.
    I dont know which one is belogs to my process chain as they do not have the process chain names.
    Can anyone please let me know how do I confirm whether one of the released jobs below to my process chain.
    Thanks in advance.

    Hi,
    To find this out, in sm37, select the job and click on step button in toolbar. You would find the program name RSPROCESS.
    Click on this job and then go to menu bar and select goto-> variant.
    In the variant, you can see the process chain that has been used for this job.

  • Authorizations in CRM 2007 - How to check missing authorization objects?

    Hi,
    In our project we are currently busy with the set up of authorizations.
    I did create the necessary PFCG and Business roles.
    For the PFCG roles, I did create all of them by copy of the standard SAP_CRM_UIU_FRAMEWORK so that the user can  access to the web layout.
    Now I need to give authorizations for other CRM objects, my question is: How can I see which objects are missing to displaying or creating activities in the new WEB Layout?
    In the old days we used the SU53 to check the authorization objects that were missing, how can we do it now in this new release? I tried it and didn't worked out.
    Thx
    Regards
    Hugo

    Hi,
    For report CRMD_UI_ROLE_PREPARE you have to input a business role - not a PFCG role. Are you doing that?
    Are you getting no results at all in ST01 or are all results just with return code 0?
    You have to remember to set a filter for your user in ST01 before activating the trace. Another thing to check is if you are using several application servers. I would imagine the trace has to be activated on the same application server as the Web UI. You can change the application sever in SM51.
    /Anders

  • How to check schedule line PO text before PO saving.

    How can i check the schedule line PO text before po saving. My idea is add a trigger in user exits. but i don't know how to check this data. I can't check the table stxh or stxl because those data are stored after PO saved. I think before that the data is stored in memory or somewhere. Could you give me some advise? thanks

    Hi
    Search for a correct user exit or BADI and you can check the text of the PO schedule line
    Use the READ_TEXT fun module to fetch the text by passing the parameters OBJECT,OBJECTNAME,ID and LANGUAGE and fetch it and check it
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • How to check the all scheduled concurrent programs.

    Hi All,
    APPS : 11.5.10.2
    DB:9.2.0.8
    how to check the all scheduled concurrent programs at a time, is their any script for this?
    Thanks a million in advance.

    Hi,
    Please refer to the following threads.
    How to know The request is scheduled or not??
    How to know The request is scheduled or not??
    Need Report or Query to see all scheduled jobs
    Need Report or Query to see all scheduled jobs
    Regards,
    Hussein

  • How to View the Scheduler in ODI Console

    Hi
    In ODI Studio, we may Schedule a Scenario and also, we may view all Schedules process from the Agents (View Schedule option).
    My colleagues are going to use ODI Console, but we cannot find out HOW to View the Schedule in ODI Console.
    In Oracle documentation about FDMEE, we can read the following: If you want to cancel a specific instance of a schedule, use the ODI Studio or ODI Console... see the PDF document in attachment.
    Regards
    Claude

    To display the schedule for one agent:
    In Topology Navigator expand the Agents node in the Physical Architecture accordion.
    Select the Physical Agent you want to update the schedule.
    Right-click and select View Schedule.
    The Schedule Editor appears, displaying the schedule for this agent.
    Check: http://docs.oracle.com/cd/E17904_01/integrate.1111/e12643/running_executions.htm#ODIDG634
    HTH -
    Jasmine

  • How to disable forward scheduling in Sales order

    Hi SD Experts,
    Can you please provide the solutions for the below requirements.
    Requirement details are below:
    How to disable forward scheduling in sales orders....
    For My sales order type i already configured in customizing that delivery scheduling should only carry out backward scheduling.
    The results is tht no forward scheduling in carried out when material is i stock .. this is ok...
    But when there is no stock and ATP indiates an expected inward movemnt, the system ignores the indicator and carries out forward scheduling anyway.
    Is there any possibility to change this behaviour?
    Appreciate any help....
    Regards
    Sudheer

    Hi
    If you do not want the system to switch to forward scheduling automatically, you can specify per plant in Customizing for MRP, in the IMG activity Parameters for determining the basic dates that the system is to continue the backward scheduling calculation even if the resulting start date lies in the past.
    Thanks & Regards
    Bhaskar

  • How to enable Manufacturing scheduling  moduel in R11.5.10.2

    We have multi node environment, new requirement is setup Manufacturing scheduling
    module , EBS 11i with 10g DB in OEL4.3,please do share me MOS.
    Edited by: appsguyflorence on Jan 2, 2012 2:05 PM

    We have multi node environment, new requirement is setup Manufacturing scheduling
    module , EBS 11i with 10g DB in OEL4.3,please do share me MOS.You can enable it from OAM (License Manager).
    How to check if certain Oracle Applications product/module is implemented? [ID 443699.1]
    How To Use OAM To License JA (Asia/Pacific Localizations), JE (European Localizations), JG (Regional Localizations) and JL (Latin-American Localizations) in Oracle Applications ? [ID 351900.1]
    Page 3-7, License Manager -- http://docs.oracle.com/cd/B25516_18/current/acrobat/11iadutil.pdf
    Thanks,
    Hussein

  • HOW TO CREATE PRODUCTION SCHEDULING PROFILE

    PLEASE
    TELL ME HOW TO CREATE PRODUCTION SCHEDULING PROFILE
    EXPLAIN IN STEPS
    THANKS

    Hi,
    Check the below link and the screen shot:
    http://wiki.sdn.sap.com/wiki/display/ERPLO/Production+Order+Type+Selection
    Hope it will help you.
    Regards,
    Alok Tiwari

  • How to activate  QIN scheduler

    Hi,
    Can any tell me how to activate QIN scheduler,the status is inactive.
    We are having queue problems in Inbound Queue.
    We are working on PI 7.1.
    Sunil

    hi,
    >>Can any tell me how to activate QIN scheduler,the status is inactive.
    this is the normal status as it gets activated only for a few seconds each run
    so it's difficult to see the active status
    but this is not a problem for sure
    check out SMQ1/SMq2 for issues and not the scheduler
    Regards,
    Michal Krawczyk

  • Availability check on schedule lines of contract

    Hi,
    We have maintained 2 line items (L1 and L2) with same material (M1) in contract. Also these two line items have schedule lines maintained.
    e.g.
    L1  :  S1,S2
    L2 :   S3,S4
    Now we create a sales order in reference to line item L1 and do an availability check.  The ATP does not show schedule lines for S1,S2 in availability overview. only S3,S4 quantities is taken into consideration for ATP calculation.
    We have activated availability check at schedule line level.
    Any pointers as to why S1,S2 requirements are not shown in availability overview
    P.S.  If we create a sales order in reference to line item L2 ,then the ATP does not show schedule lines for S3,S4 in availability overview. only S1,S2 quantities is taken into consideration for ATP calculation.
    Any pointers will be highly welcome.
    Thanks.

    Hi,
    Sorry, for Sch. AV check is not activated but TR is activated.
    For material ATP is activated- check in MM03
    Chidambaram

  • How to create a  schedule program in java

    Hello Friends ,
    Can any one provide me with an example how to create a schedule program using java.util.timer etc . I am in need of a program which should run as a schedule job that searches for a file in a directory and read the latest files from that directory in every minute of time as a schedule job .
    Thanks
    mahesh

    I don't feel like writing my own example, but google will be happy to provide you with an example.

  • HOW TO STOP A SCHEDULING A PROCESS CHAIN IN SAP BPC

    Hello Expert,
    Can Any 1 tell me  how to stop a scheduling of a process chain in sap bpc ??

    Hi Neeraj,
    Your question is not clear.
    If you are asking - How to delete a schedule which runs a process chain/DM package from EPM, then please go to Data Manager -> click View Status arrow -> select view schedule status -> select the schedule, right click and choose delete schedule.
    Neha

  • How to check Le field is missed?

    Hi,
    When the protocol is T=1, I have problem with Le field.
    When the card recieve Case 2 format command without Le(like '00B2010C' - Read Record) , how to check the Le field is missed?
    I tried below but not working.
    if(APDU.getProtocol() == APDU.PROTOCOL_T1 && apduBuffer[ISO7816.OFFSET_LC] != 0 && apdu.setIncomingAndReceive() != 0){
              ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
    I look forward your feedback.
    Many thanks in advance!
    글 수정: user11280436
    글 수정: user11280436

    Hi,
    You should check the response from apdu.setOutgoing() to see what value was passed in as Le. This will return the number of bytes expected by the terminal.
    You only need to call apdu.setIncomingAndReceive() if the INS expects data. You can also use it to ensure that there was no data passed in (returns 0).
    Cheers,
    Shane

Maybe you are looking for

  • Video uploaded to an iPad from a camera

    It says under the tech specs that the iPad can import (with camera connection pack) photos and VIDEOS from your camera. I have a Canon camera that shoots 1080P video...the iPad doesn't list 1080P video as a supported type... 1) What happens to those

  • Forcing a user's password to be expired

    I am trying to test my customized change password page. I have updated the URL in the LS_CONFIGURATION table. How can I force a user to produce the change password page so I can test my customized change password page?

  • My camera stays black and I cannot use. Anyone know how to fix this?

    HOw do you fix your camera app when it just stays black and will not reset

  • Sys & system passwords unknown

    I installed 9i on my home computer for personal, educational use. SYS and SYSTEM passwords were changed, but now are lost. Do I need to uninstall & reinstall the database in order to correct the problem?

  • FTP to Multiple Servers?

    This question was asked many moons ago, and never got much response. I administer several sites that load balance between 2 servers. So I need to upload my sites to both Server A and Server B, maintaining identical directory structures, etc. I'd like