Schedule job with JOB_CLOSE until a certain time

Hello all,
I'd like to schedule a background job with JOB_CLOSE until a certain time, i.e. first start time at 10 a.m., repitition period 15 min., last start time 1 p.m.
I tried this using parameter LASTSTRTTM, e.g.:
i_startdate = sy-datum.
i_starttime = '100000'.
i_prdmins = '15'.
i_laststrtdt = sy-datum.
i_laststrttm = '130000'.
CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
      jobcount             = l_jobcount
      jobname              = 'MY_JOB'
      sdlstrtdt            = i_startdate
      sdlstrttm            = i_starttime
      laststrtdt           = i_laststrtdt
      laststrttm           = i_laststrttm
      prdmins              = i_prdmins
    EXCEPTIONS
      cant_start_immediate = 1
      invalid_startdate    = 2
      jobname_missing      = 3
      job_close_failed     = 4
      job_nosteps          = 5
      job_notex            = 6
      lock_failed          = 7
      OTHERS               = 8.
but I didn't succeed - the job didn't stop at 1 p.m. Any hints?
Best regards
Martin Lehmann

Hi Martin,
i_startdate = sy-datum.  " 1st time Job Start Date
i_starttime = '100000'.
i_prdmins = '15'.
i_laststrtdt = sy-datum.  " If Job is not started by this date, then it wont be started once this date is completed
i_laststrttm = '130000'.
What it means is, if i want to start a job by 10th Oct.. & expect that it should be started maximum by 20th Oct.. If its 20th Oct & still the job is not started,... then terminate the job & do not start it..
If the job is already started, then it wont stop.
Hope its clear.
Best regards,
Prashant

Similar Messages

  • Schedule Job with Job_close after successful job doesn't work

    Hi guys,
    I'm using FM CLOSE_JOB with parameters : 
                JOBCOUNT             = w_JobId
                JOBNAME              = w_JobName
                PREDJOB_CHECKSTAT    = 'X'
                PRED_JOBCOUNT        = w_oldJobId
                PRED_JOBNAME         = w_oldJobName
    I have about 9 jobs wich must run the one after the others. The first start without PRED* parameters, but the 8 others one are filled with CHECKSTAT, and previous job name and id.
    It works fine for the side "the one after the others", BUT, wathever the previous job give as result (cancelled or finished), the next one starts whereas I pass the parameter CHECKSTAT to X.
    Any ideas of the problem and how to solve it?
    Thanks in advance for your answers.

    Here my code with explanation :
    REPORT  YCOMJ023.
    start-of-selection.
    "Initialization of my vars
    w_StepCount = 0. >> number of steps maxi in a job
    w_jobCount = 1.  >> number to see easier in SM37 the job order
    CONCATENATE pe_name '_STEPS' w_jobCountC INTO w_JobName. (example : TOTO_STEP1)
    CONDENSE w_JobName NO-GAPS.
    "I open my first job
      CALL FUNCTION 'JOB_OPEN' (OPEN job TOTO_STEP1)
        EXPORTING
          jobname          = w_JobName
        IMPORTING
          jobcount         = w_JobID
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
    "We keep in memory first job IDs to close it at the end of the prg
      w_firstjobName = w_JobName.
      w_firstjobID = w_JobID.
    "imagine you do the bellow code in a loop and it makes several jobs TOTO_STEP2 TOTO_STEP3 TOTO_STEP4...
    ADD 1 TO w_StepCount.
    IF w_StepCount GT 250.
        "I call close job eatch time I reach 250 steps
         PERFORM fx_jobclose.
    ENDIF.
    submit RKGALKEUB to sap-spool and return
                                       without spool dynpro
                                       spool parameters print_parameters
                                            VIA JOB w_JobName NUMBER w_JobID
    "End of the programmI close the current Job and the first one :
    "Current
            CALL FUNCTION 'JOB_CLOSE'
              EXPORTING
                JOBCOUNT             = w_JobId
                JOBNAME              = w_JobName
                PREDJOB_CHECKSTAT    = 'X'
                PRED_JOBCOUNT        = w_oldJobId
                PRED_JOBNAME         = w_oldJobName.
    "First one + launch with STRIMMED
            CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT             = w_firstjobId
              JOBNAME              = w_firstjobName
              STRTIMMED            = 'X'
            EXCEPTIONS
              cant_start_immediate = 1
              invalid_startdate    = 2
              jobname_missing      = 3
              job_close_failed     = 4
              job_nosteps          = 5
              job_notex            = 6
              lock_failed          = 7
              OTHERS               = 8.
    *&      Form  fx_jobclose
    *       text
    FORM fx_jobclose.
      "Step to zero to do a new loop after this form
      w_StepCount = 0.
      DATA : w_job_released TYPE CHAR1.
      "If the flag IsFirst, we don't do nothing, because it's the first JOb, and it should not be closed
      IF w_IsFirst = 'X'.
        "Flag is set to blank
        w_IsFirst = ''.
      ELSE.
          "Else it mean we are closing a job with predecessor :
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT             = w_JobId
              JOBNAME              = w_JobName
              PREDJOB_CHECKSTAT    = 'X'
              PRED_JOBCOUNT        = w_oldJobId
              PRED_JOBNAME         = w_oldJobName
              "SDLSTRTDT            = sy-datum
              "SDLSTRTTM            = sy-timlo
            IMPORTING
              JOB_WAS_RELEASED = w_job_released.
      ENDIF.
      "Vars get the value of current job, witch will become the older one
      w_oldJobId = w_jobID.
      w_oldJobName = w_JobName.
    "I make the new TOTO_STEPX job name
      ADD 1 TO w_jobCount.
      w_jobCountC = w_jobCount.
      CONCATENATE pe_name '_STEPS' w_jobCountC INTO w_JobName.
      CONDENSE w_JobName NO-GAPS.
      "I open the new job
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobname          = w_JobName
        IMPORTING
          jobcount         = w_JobId
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
    ENDFORM.                    "fx_jobclose
    I hope my code is clear enought, I tried to delete the superfluities code.

  • Scheduling jobs with condition-after job programatically

    Hi,
    Could anybody please tell me how can we schedule jobs from programs(prgramatically) with condition-start after job(after a particular job completed) like we have the same option in sm36.
    Thanks,
    Rahul.

    Hello Rahul,
    Check the following Link Page Number 41.
    "Sample Program: Wait for Predecessor Job with
    JOB_CLOSE"
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCDWBLIB/BCDWBLIB.pdf
    Regards,
    Abhishek Jolly

  • Event based scheduler job - 2 events at the same time only 1 run

    Hi,
    i converted our dbms_job - jobs to the newer package dbms_scheduler.
    It is a 10.2.0.4 patch 23(8609347) database on an windows server 2003 R2 Enterprise x64 Edition SP2.
    The Jobs(about 130) are nothing special ... only some statistics, matview-refreshes and so on.
    For the notification of failed jobs and jobs which run over the max_run_duration i downloaded and installed the job notification package.
    The jobs are assigned to different departments and the corresponding developer teams in our company.
    I created a notification job for each department and if a job fails we (the database administrators) and the corresponding deverlopers will be informed.
    Now i ascertained that only 1 email will be send if 2 jobs of the same department fails at the same time.
    The emailer-jobs are auto-generated by the job notification package. I only modified them to look after all jobs of special department and not only after one job. (--> event_condition ... object_name LIKE 'XXX%')
    example for dba-jobs(copy of the script output of TOAD):
    SYS.DBMS_SCHEDULER.CREATE_JOB
           job_name        => 'DBA_JOBS_EMAILER'
          ,start_date      => NULL
          ,event_condition => tab.user_data.object_name LIKE ''DBA%'' AND tab.user_data.event_type in (''JOB_FAILED'',''JOB_OVER_MAX_DUR'')'
          ,queue_spec      => 'SYS.SCHEDULER$_EVENT_QUEUE, JOB_FAILED_AGENT'
          ,end_date        => NULL
          ,program_name    => 'SYS.EMAIL_NOTIFICATION_PROGRAM'
          ,comments        => 'Auto-generated job to send email alerts for jobs "DBA%"'
        );I thought that a queue is used to manage all events from the scheduler jobs. So i made a test with 2 dba jobs and simulated a failure at the same time but i received only one mail.
    So what is happend with the second event? I looked for the events in the qtab(SCHEDULER$_EVENT_QTAB) which belongs to the event queue(SYS.SCHEDULER$_EVENT_QUEUE) and no event was missing.
    So i think the emailer job has to run 2 times.
    Is anyone able to explain or to find my mistake?
    I know that the easiest way is to create one emailer job for each normal job but i think this is a little bit costly because all the arguments are the same for one department.
    Thanks & Regards

    Thanks for your fast answer.
    You are right with the "enabled => TRUE;" part and i only forgot to post it.
    So the Job is enabled (otherwise it would not send any mail). Because it is sending one mail i think it is also not necessary to hand over a job_type.
    Additionally the job starts a program ... so it is right to set the job_type='STORED_PROCEDURE' isn't it?
    And also right ... i already added the agent as subscriber to the queue.
    Anyway i think the whole thing do what it have to do. So in my oppinion there are no big mistakes in creating the job or at adding the subscriber.
    There are also no problem in raising the events by itself and enqueue them in the scheduler event queue.
    There is only a problem when 2 jobs fails (or run out ouf max duration) at exactly the same time.
    If i understand it right:
    The agent/subscriber will find the "JOB_FAILED"-event for the first Job in the queue and starts the emailer Job.
    The agent will also find the "JOB_FAILED"-event for the second Job and wants to start the emailer Job again.
    I don't know if this is really the problem but perhaps the emailer-job can not be started in consequence of the second event because ist is already running.
    I also don't know if this is a mistake of the agent or of the emailer-job by itself.
    I only want that it runs two times (one run for each event). I my case it also doesn't matter which email is send at first.

  • How to Schedule Jobs to only run during a time window

    I have a long running task that needs to schedule jobs to process data.
    I only want these scheduled jobs to start during a specific window of time each day, probably 10:00 PM to 6:00 AM.
    If the scheduled jobs do not begin during the specified time frame, they must wait until the next day to start running.
    Each scheduled job will only be executed once and then auto dropped.
    How should I go about creating these scheduled jobs?

    Hi Jeff,
    I agree that the documentation isn't clear enough about the purpose of windows.
    You can indeed use windows for changing the resource plan, but you can also use them for scheduling your jobs.
    I did a simple test in real-time to illustrate the latter.
    At around 10.30 am today I created a table that will populated by a job:
    CREATE TABLE TEST_WINDOW_TABLE(EVENT_DATE DATE);
    Then, I created a window whose start_date is today at 10.40 am :
    dbms_scheduler.create_window(
                                 window_name     =>'TEST_WINDOW',
                                 resource_plan   => NULL,
                                 start_date      => to_date('10/04/2014 10:40:00', 'dd/mm/yyyy hh24:mi:ss'),
                                 repeat_interval => NULL,
                                 duration        =>interval '5' minute
    You can see that this window doesn't have a resource plan, and its repeat interval is NULL (so it will be opened only once).
    The window will stay open for 5 minutes.
    Finally, I created a one-off job whose schedule is the previously created window:
    DBMS_SCHEDULER.create_job (
                               job_name      => 'TEST_WINDOW_JOB',
                               job_type      => 'PLSQL_BLOCK',
                               job_action    => 'BEGIN insert into test_window_table values (sysdate); COMMIT; END;',
                               schedule_name => 'SYS.TEST_WINDOW',
                               enabled       => true,
                               auto_drop     => true
    Checking the user_scheduler_job_log before 10.40 would return no rows, which mean the job hasn't started yet since the window was not open.
    Now, from 10.40, it shows one entry:
    SQL> select log_date, status from user_scheduler_job_log where job_name = 'TEST_WINDOW_JOB';
    LOG_DATE                                                                         STATUS
    10/04/14 10:40:02,106000 +02:00                                                  SUCCEEDED
    The TEST_WINDOW_TABLE has also got the row:
    SQL> select * from TEST_WINDOW_TABLE;
    EVENT_DATE
    10/04/2014 10:40:02
    Voilà.
    In your case, since you want to run the jobs daily between 10 pm and 6 am (duration of 8 hours), the window would look like this:
    dbms_scheduler.create_window(
                                 window_name     =>'YOUR_WINDOW',
                                 resource_plan   => NULL,
                                 repeat_interval => 'freq=daily;byhour=22;byminute=0;bysecond=0',
                                 duration        =>interval '8' hour
    For your jobs, you may need to specify an end_date if you want to make sure the job gets dropped if it couldn't run in its window.

  • How to schedule job with spool list recipient in CPS ?

    Dear Guru,
    i import job with spool list recipient from r3 to cps and schedule in CPS, job is finished but there is no spool send to the recipient ?
    Please advise ?
    Best regards,
    Supat Jupraphat.

    What job definition did you use? SAP_AbapRun? SAP_AbapRunPrint? SAP_AbapRunPrintExt?
    Do you have XBP 2.0 or 3.0 in the SAP system? (check SE38 > INITXBP2)
    Have you loaded the CPS transport files in the SAP system?
    Note that using spoollist recipients either involves SAP_AbapRunPrintExt in combination with XBP3.0
    OR
    It involves SAP_AbapRun or SAP_AbapRunPrint and XBP 2.0 using transportation files in the SAP System.
    Please check the section of the CPS admin guide called: "Enhanced SAP Interfaces with Redwood Transports"
    Regards,
    David

  • Schedule Jobs with multiple steps via ABAP Program

    Hi,
    I need to schedule multiple programs via background jobs on a daily basis. Since all these jobs are to be run as a single job, the various programs have to be run as steps in a major job.
    I am however not very clear on how this can be done via an ABAP program ( the idea of a program is that various parameters to be passed to each program in the step can be entered dynamically rather than via variants).
    I am using the JOB_OPEN and JOB_CLOSE functions and submitting the programs with selection screen parameters dynamically passed to create a job. I need to do this for various programs as a job step (WITHOUT Variants being defined).
    Can anyone suggest any ideas for this? I have tried out JOB_SUBMIT Function but am not very confident I know what exactly it is for as it asks for a variant.
    Thanks very much,
    Preet

    Hi Preet,
    just to be sure: you know, that variants can be dynamical, too?
    It's quite usual to assign dynamical current date, but it's also possible to add / subtract value and even define own functionality.
    Maybe it's easier to implement a dynamical selection and handle static jobs.
    If you try to plan a job (online or with JOB_SUBMIT), you have to use variants - you can create (or change) them dynamical in beforehand. Only SE38, F8, F9 is creating a temporary variant, so that no saved variant is necessary.
    But if you end up creating variants dynamical, you can change one existing variant, too. Then you can use a static job definition (with periodical starting rule).
    So: have a look, if dynamic variants are enough, otherwise change variants per job.
    Regards,
    Christian

  • KM Scheduler job with MDM APIs

    Hi,
    I am trying to write a background job that makes use of MDM APIs. I created a Portal Application Project and put in the required code. I added the required MDM jar fiels in to the java build path. How ever, I don't know how to add Library Reference with value "com.sap.mdm.tech.mdm4j" since this is not a Webdynpro project. Without this the KM Scheduler fails to run the job thowing an exception ''NoClassDefFoundError...".
    Can any one tell me how do I go about?
    Thanks,
    Sudheer

    Trying to post the question under different category

  • Schedule job with dependencies in another job

    Hi All,
             I Have a job in sm36 schedule but I want to create a new job and will be started after my first job,
       for exemple : I have a job Test1 started in 30 and 30 minutes and I create a new job test2 that this job has to executable after the job test1, I can to do this but my slave job only executable one time, I need that this job stay continued always after job test1 and don't finish.
    Thank for Help.
    Regards,
    Osvaldo Antonio dos Santos

    Hi,
    I am afraid your reqmt may not be possible.
    You can very well run one job after another job by maintaining the After event parameters in SM36. However you cannot enable a job run for ever. Once there is no input meeting the selection criteria, teh job will finish.
    Instead of thinking of enabling the job for ever, you can maintain the jobtest2 as after event of jobtest1.
    After that you can create jobtest3 using the same variant of jobtest2 and schedule it to run once in 15 min or 30min or so.
    Hope this helps you
    Pls reward if it is of some help to you

  • Schedule Job with Abap

    Hi Experts
    Im executing jobs thru abap program, but now I need schedule this job.  Does anybody know how can I do it?  Can you show me the abap code or function module?
    Thank you in advance!

    Hi Ram,
    I have a front-end screen where the end-user select date &time for schedule this job. Now Im using
    FUNCTION 'JOB_SUBMIT',
    EXPORTING
            authcknam = sy-uname
            jobcount  = p_job
            jobname   = 'BUNDLE_EXECUTE'
            report    = 'UPC_BUNDLE_EXECUTE'
            variant   = l_seq.
    but I dont know how send the date and time in order to schedule the job.  
    Does I need use other function?
    Thank you!

  • How to schedule job with a system user BTC_100

    Hi,
    Someone setup the background job user BTC_100 as a system user (not a dialog nor service user). I need to schedule a new job and want to have the createBy as BTC_100 instead of my own ID.
    I got error (Please logon as a dialog user) when tried to logon as BTC_100.
    Do people usually set up their background job ID as a system ID? How can I schedule a new job as BTC_100?
    Many thanks in advance!
    -Serine

    Hi Prince,
    Besides the step owner, I wanted to have the job owner to be BTC_100 as well. Otherwise when I run SM37 and search for job, I'll have to put my ID instead of keep it as BTC_100.
    From SUIM, I see BTC_100 has been changed from dialog to SYSTEM so maybe I have to change it to dialog first, create the job and then change it back to SYSTEM?
    thanks!
    -Serine

  • Schedule job to run daily at specific times

    Hello,
    Not sure if this is the correct forum to post my question. If not, please advise which forum to use.
    How can I setup a background job which runs daily day, but only runs between a specific time?
    Our request is to have a job to run daily between 0700 - 1700 - then end and restarts again at 0700 the next day. How can we do this?
    Kind regards

    Check this
    https://forums.sdn.sap.com/search.jspa?threadID=&q=backgroundANDjobANDschedule&objID=f50&dateRange=all&numResults=15
    PS Please make a search this forum before posting

  • Get AM from POJO (to run as scheduled job) with ADFBC?

    In JDev 10.1.3.2 I am trying to write a java class (app) that will be run by a CRON job. This app must get a handle to a view object, execute it's query and do something with the results (send emails)...
    I am assuming I need an app module and need to get the view object from the app module, but cannot figure out just how to do this. I tried:
    MyAppModImpl am = new MyAppModImpl();
    ViewObject vo = am.findViewObject("MyViewObject");
    but the vo is null.
    Am I going about this in the wrong way?
    Thanks,
    Ginni

    Thanks Shay. I got it working, like this:
    String amDef = "org.aero.kas.evc.expirations.ExpirationService";
    String config = "ExpirationsServiceLocal";
    ApplicationModule am =
    Configuration.createRootApplicationModule(amDef, config);
    //ExpirationsServiceImpl am = new ExpirationsServiceImpl();
    ClearancesExpiringThisMonthImpl vo = (ClearancesExpiringThisMonthImpl)am.findViewObject("ClearancesExpiringThisMonth");
    vo.executeQuery();
    RowSet rowSet = vo.getRowSet();
    I tested it and it's all good! Amazing!
    Now, when I deloy this beast to OAS 10.1.2 on Unix, apparently I'll need to have an admin write a Cron job to make the app run on the first of each month. What info do I need to give them? I've never deployed an app yet... this will be our very first one.
    Thanks!

  • Scheduling Jobs with email notifications.

    Hi,
    Using the information which i got from internet i created procedure and also below job to run on server.
    Procedure name : refresh_tapas_rs
    BEGIN
    DBMS_SCHEDULER.create_job (
    job_name => 'TAPAS_REFRESH',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN refresh_tapas_rs; END;',
    start_date => '24-APR-13 11.40.00AM',
    repeat_interval => NULL,
    --'freq=hourly; byminute=0; bysecond=0;',
    end_date => NULL,
    enabled => TRUE,
    comments => 'Job defined entirely by the CREATE JOB procedure.');
    END;
    It's working fine.
    i wanted to add few more things into this.
    1. this should run - every Sunday morning 10 AM.
    2. once this is completed my manager should get email with status immediately.
    please help me to add this functionality.

    995263 wrote:
    Hi,
    Using the information which i got from internet i created procedure and also below job to run on server.
    Procedure name : refresh_tapas_rs
    BEGIN
    DBMS_SCHEDULER.create_job (
    job_name => 'TAPAS_REFRESH',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN refresh_tapas_rs; END;',
    start_date => '24-APR-13 11.40.00AM',
    repeat_interval => NULL,
    --'freq=hourly; byminute=0; bysecond=0;',
    end_date => NULL,
    enabled => TRUE,
    comments => 'Job defined entirely by the CREATE JOB procedure.');
    END;
    It's working fine.
    i wanted to add few more things into this.
    1. this should run - every Sunday morning 10 AM.
    2. once this is completed my manager should get email with status immediately.
    please help me to add this functionality.I believe below should help you:
    BEGIN
       DBMS_SCHEDULER.create_job (
         job_name        => 'TAPAS_REFRESH',
         job_type        => 'PLSQL_BLOCK',
         job_action      => 'BEGIN refresh_tapas_rs; END;',
         start_date      => '24-APR-13 11.40.00AM',
         repeat_interval => 'freq=weekly; byday=sun; byhour=10; byminute=0; bysecond=0;',
         end_date        => NULL,
         enabled         => TRUE,
         comments        => 'Job defined entirely by the CREATE JOB procedure.');
      send_email (relevant_parameters);  --> You need to have this procedure, to Send mails, in your database. You can get many ready to use samples online.
    END;
    /

  • How to schedule a job to run only in a  time window

    Hi,
    I need to schedule a job to run every day but sundays from 7am to 6pm. I managed to get it to start at seven like this
    FREQ=WEEKLY;BYDAY=TUE,WED,THU,FRI,SAT;BYHOUR=7;BYMINUTE=0;BYSECOND=0
    how can I set the job to stop at 6pm?
    thanks in advance

    Yes, as far as I could tell you create a resource plan to allocate processor resources, assign a resource plan to the window, then assign the job to a job class which is in turn assigned a resource group within that resource plan. Then when the window is active, it sets the active resource plan for the database so the job will run using this until the window deacivates the resource plan. Unfortunately because the resource plan is database wide, it means you could only really have one time window active at any one time within which to run jobs, I don't think two windows could overlap.
    Easier to work within jobs, but its a shame the job doesn't end itself, rather than having to have the second job, although the second job does enable you to engage in some communication between jobs to cleanly end it, rather than stop it dead. I have a job that runs until a set time each day, but it just works on a loop that sleeps for a few minutes each time, checking for file arrival and processing it, and sending a notification e-mail if it reaches its end time without the file arriving.

Maybe you are looking for

  • Can't send email from iBook but can from iMac

    I have a iMac hardwired to the Internet with Leopard. I also have a Powerbook with Leopard and a iBook with the previous operating system. My hardwired iMac is the only computer that can send email through the my smtp server for work. It is offsite a

  • Using multiple iphones 1 computer

    hello i have done a search but cannot find an answer to my question. i have an iphone 3g (which is slowly dying) and i am going to upgrade to an iphone 4 or 4s as the carrier in my area has a promotion but i still want to use my old iphone as an ipod

  • Reading the output from a object running in the local machine.

    Reading the output from a object running in the local machine. By using a signed applet i am lunching a small application that returns an image object, how to read that without storing it in the hard disk. Which means i need to read the image object

  • N97 to unlock side button need to be pulled two ti...

    Hello, I´m bored because the N97 side lock button need to be pulled two time for each time I would unlock the gadget. On the first time "nothing occurs" it remain with a black screen, on the second one, it unlock as expected. Someone has experienced

  • Is it possible to have a selectManyListBox within ui:repeat ?

    Can I have a selectManyListBox within a <ui:repeat> or that is completely wrong ? I can displayed the values properly , however I cant retrieve the selected items in my list. An error is displayed "myform:j_idt117:0:j_idt119:0:_t121: Validation Error