How to run a job in 1 session only?

Hi,
although I searched the forum and found some proposals close to my issue, I would like to ask just in case to be sure I have correct answer:
[Q] I have a program (with attached transaction code) which usualy runs as a task in background job, but may be started in foreground also. What I need is to prevent possiblity to start it in two paralel sessions (as per server context, not per frontend).
Is it possible and what is the proper way to do that?
Many thanks in advance.
Regards,
Ivaylo Mutafchiev

Yes, I believe that this is achieved by placing a lock on the program name during execution. Here is a sample.
report zrich_0001 .
call function 'ENQUEUE_E_TRDIR'
exporting
*   MODE_TRDIR           = 'X'
   name                 = sy-repid
*   X_NAME               = ' '
*   _SCOPE               = '2'
*   _WAIT                = ' '
*   _COLLECT             = ' '
* EXCEPTIONS
*   FOREIGN_LOCK         = 1
*   SYSTEM_FAILURE       = 2
*   OTHERS               = 3
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
check sy-subrc = 0.
Regards,
Rich Heilman

Similar Messages

  • How to run a job in background programatically after 10 sec

    Hi Forum,
    Can anyone tell me How to run a job in background programatically after 10 sec..
    Thanks in advance

    Hi,
    Here is the example code
    *Submit report as job(i.e. in background) 
    data: jobname like tbtcjob-jobname value
                                 ' TRANSFER TRANSLATION'.
    data: jobcount like tbtcjob-jobcount,
          host like msxxlist-host.
    data: begin of starttime.
            include structure tbtcstrt.
    data: end of starttime.
    data: starttimeimmediate like btch0000-char1.
    * Job open
      call function 'JOB_OPEN'
           exporting
                delanfrep        = ' '
                jobgroup         = ' '
                jobname          = jobname
                sdlstrtdt        = sy-datum    " You need to give the Date for execution the Job
                sdlstrttm        = sy-uzeit    " You need to give the Time for execution the Job
           importing
                jobcount         = jobcount
           exceptions
                cant_create_job  = 01
                invalid_job_data = 02
                jobname_missing  = 03.
      if sy-subrc ne 0.
                                           "error processing
      endif.
    * Insert process into job
    SUBMIT zreport and return
                    with p_param1 = 'value'
                    with p_param2 = 'value'
                    user sy-uname
                    via job jobname
                    number jobcount.
      if sy-subrc > 0.
                                           "error processing
      endif.
    * Close job
      starttime-sdlstrtdt = sy-datum + 1.
      starttime-sdlstrttm = '220000'.
      call function 'JOB_CLOSE'
           exporting
                event_id             = starttime-eventid
                event_param          = starttime-eventparm
                event_periodic       = starttime-periodic
                jobcount             = jobcount
                jobname              = jobname
                laststrtdt           = starttime-laststrtdt
                laststrttm           = starttime-laststrttm
                prddays              = 1
                prdhours             = 0
                prdmins              = 0
                prdmonths            = 0
                prdweeks             = 0
                sdlstrtdt            = starttime-sdlstrtdt
                sdlstrttm            = starttime-sdlstrttm
                strtimmed            = starttimeimmediate
                targetsystem         = host
           exceptions
                cant_start_immediate = 01
                invalid_startdate    = 02
                jobname_missing      = 03
                job_close_failed     = 04
                job_nosteps          = 05
                job_notex            = 06
                lock_failed          = 07
                others               = 99.
      if sy-subrc eq 0.
                                           "error processing
      endif.
    Regards
    Sudheer

  • How to run 3 job(a,b,c) parallel in unix shells script and after will complete d will start  and we have to handle the error also

    how to run 3 job(a,b,c) parallel in unix shells script and after will complete d will start  and we have to handle the error also

    032ee1bf-8007-4d76-930e-f77ec0dc7e54 wrote:
    how to run 3 job(a,b,c) parallel in unix shells script and after will complete d will start  and we have to handle the error also
    Please don't overwhelm us with so many details!  
    Just off the top of my head ... as a general approach ... something like
    nohup proca
    nohup procb
    nohup procc
    while (some condition checking that all three procs are still running ... maybe a ps -ef |grep  )
    do
    sleep 2
    done
    procd
    But, we'd really need to know what it is you are really trying to accomplish, instead of your pre-conceived solution.

  • How to run the job using DBMS_SCHEDULER

    How to run the job using DBMS_SCHEDULER
    pleas give some sample Iam very new to DBMS_SCHEDULER

    Hi
    DBMS_SCHEDULER
    In Oracle 10g the DBMS_JOB package is replaced by the DBMS_SCHEDULER package. The DBMS_JOB package is now depricated and in Oracle 10g it's only provided for backward compatibility. From Oracle 10g the DBMS_JOB package should not be used any more, because is could not exist in a future version of Oracle.
    With DBMS_SCHEDULER Oracle procedures and functions can be executed. Also binary and shell-scripts can be scheduled.
    Rights
    If you have DBA rights you can do all the scheduling. For administering job scheduling you need the privileges belonging to the SCHEDULER_ADMIN role. To create and run jobs in your own schedule you need the 'CREATE JOB' privilege.
    With DBMS_JOB you needed to set an initialization parameter to start a job coordinator background process. With Oracle 10g DBMS_SCHEDULER this is not needed any more.
    If you want to user resource plans and/or consumer groups you need to set a system parameter:
    ALTER SYSTEM SET RESOURCE_LIMIT = TRUE;
    Baisc Parts: Job
    A job instructs the scheduler to run a specific program at a specific time on a specific date.
    Programs
    A program contains the code (or reference to the code ) that needs to be run to accomplish a task. It also contains parameters that should be passed to the program at runtime. And it?s an independent object that can referenced by many jobs
    Schedules
    A schedule contains a start date, an optional end date, and repeat interval with these elements; an execution schedule can be calculated.
    Windows
    A window identifies a recurring block of time during which a specific resource plan should be enabled to govern resource allocation for the database.
    Job groups
    A job group is a logical method of classifying jobs with similar characteristics.
    Window groups
    A window groups is a logical method of grouping windows. They simplify the management of windows by allowing the members of the group to be manipulated as one object. Unlike job groups, window groups don?t set default characteristics for windows that belong to the group.
    Using Job Scheduler
    SQL> drop table emp;
    SQL> Create table emp (eno int, esal int);
    SQL > begin
    dbms_scheduler.create_job (
    job_name => 'test_abc',
    job_type => 'PLSQL_BLOCK',
    job_action => 'update emp set esal=esal*10 ;',
    start_date => SYSDATE,
    repeat_interval => 'FREQ=DAILY; INTERVAL=10',
    comments => 'Iam tesing scheduler');
    end;
    PL/SQL procedure successfully completed.
    Verification
    To verify that job was created, the DBA | ALL | USER_SCHEDULER_JOBS view can be queried.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_abc FALSE 0
    Note :
    As you can see from the results, the job was indeed created, but is not enabled because the ENABLE attribute was not explicitly set in the CREATE_JOB procedure.
    Run your job
    SQL> begin
    2 dbms_scheduler.run_job('TEST_abc',TRUE);
    3* end;
    SQL> /
    PL/SQL procedure successfully completed.
    SQL> select job_name,enabled,run_count from user_scheduler_jobs;
    JOB_NAME ENABL RUN_COUNT
    TEST_ABC FALSE 0
    Copying Jobs
    SQL> begin
    2 dbms_scheduler.copy_job('TEST_ABC','NEW_TEST_ABC');
    3 END;
    4 /
    PL/SQL procedure successfully completed. Hope it will help you upto some level..!!
    Regards
    K

  • How to run a job (program in it) every 48 hours

    Dear All,
    Can you please tell me how to run a job every 48 hours. I am not able to find suitable job option.
    Thanks and regards,
    Atanu

    Hi,
    1. Go to SM36 give the job name i.e. ZABC_MYJOB
    2. Click on Steps (Upper left corner - 2nd Button) and assign the ABAP report name .i.e. RSUSR002, Check and Save.
    3. Click on Start Condition (Upper left corner - Ist Button), click Date/Time and specify the Start Date and Time.
    4. Select "Periodic Job" and click on Period values now click on Other Period
    5. Now input 1 in the Minute Box. , and check and save.
    6. Again Check and Save. and Again Check and Save.
    7. Now save the job.
    This job will run after every 1 minut
    (OR) try the below steps.
    you can setup your job in order to start after an event.
    After that you can get the event triggered from the Operating System:
    - log into you Operating System with the SIDadm user id (at the Operating System level) and go to directory /usr/sap/SID/SYS/exe/run
    - Run the SAPEVT executable as follows :
    sapevt YOUR_EVENT -t pf=/usr/sap/SID/SYS/profile/DEV_DVEBMGS00_server001 nr=01
    This will raise the event, and cause the job scheduled within SAP to execute.
    In this way you can use the O.S. (u201Ccrontabu201D for example) functionalities in order to schedule your job between 9am to 6pm.
    Regards
    Shweta

  • How to run the job under sys id

    Hello ,
    I wanted to run a job under sys id ( Batch user ) , as my authorisation is not sufficiant to run the repoting agent - Precalculation. Where as Batch user have all the roles for the same .
    I am in my login screen , and i wanted to run the job under batch user id ...could you please let me know how can i do it ?
    Regards,
    Manoj

    Hi,
    Try to schedule the job in background and see.
    Thanks,
    JituK

  • HOW TO RUN BODS JOB THROUGH UNIX SCRIPT

    Dear Experts
    Please provide me the way how to call a job by a script .
    I have used Export Execution Command as recommended by below links
    http://scn.sap.com/docs/DOC-34648
    http://scn.sap.com/community/data-services/blog/2012/08/22/sap-bods--running-scheduling-bods-jobs-from-linux-command-line-using-third-party-scheduler
    But I am not able to locate .sh  file in unix server .
    This is required to call a job after completion of parent job.
    Thanks
    Anupam

    You can check the status in "SAP Business Objects Data Services management Console", Below are the steps
    Login in SAP Business Objects Data Services management Console
    Click on Batch Job
    Select the local repository
    Then check your Job Execution status from there
    For your second query there are two ways one is do the same activity what you have done in DEV.
    below are the steps
    Login in SAP Business Objects Data Services management Console and export the Jobs using export execution command from batch job
    SHELL Scripts will be exported in Job Server Log
    Move that SHELL script as per your location
    Update the User environment variable same as DEV only difference is SID is changed
    Thanks,
    Daya

  • How to run a job every month

    Hi guys,
    I know it's not right to ask others to create code for me, but I searched for a while and still blank. Can someone show me how to run myPackage.myProcedure every first day of the month (eg, Jan 1, Feb 1, March 1).
    I am thinking use this function, but I don't see how..
    DBMS_JOB.SUBMIT (
    job OUT BINARY_INTEGER,
    what IN VARCHAR2,
    next_date IN DATE DEFAULT sysdate,
    interval IN VARCHAR2 DEFAULT 'null',
    no_parse IN BOOLEAN DEFAULT FALSE,
    instance IN BINARY_INTEGER DEFAULT any_instance,
    force IN BOOLEAN DEFAULT FALSE);
    Any suggestions are welcome,
    Thank you
    Mike

    How come the first test works and the second test cannot find the procedure?? I am very confused now.. Also, how do I post code with indents? LOL
    SQL> DECLARE
    4 begin
    5 PRICE_PKG.CREATE_BUFFER_TBL;
    6 end;
    7 /
    PL/SQL procedure successfully completed.
    SQL> DECLARE
    2 v_Job NUMBER;
    5 BEGIN
    6 DBMS_JOB.SUBMIT(
    7 v_Job,
    8 PRICE_PKG.CREATE_BUFFER_TBL,
    9 LAST_DAY(SYSDATE)+1,
    10 TO_CHAR(TRUNC(LAST_DAY(SYSDATE)+1) + (6/24))
    11 );
    12 END;
    13 /
    PRICE_PKG.CREATE_BUFFER_TBL,
    ERROR at line 8:
    ORA-06550: line 8, column 36:
    PLS-00222: no function with name 'CREATE_BUFFER_TBL' exists in this scope
    ORA-06550: line 6, column 4:
    PL/SQL: Statement ignored

  • How to run a job?

    Hi,
    I have a report which should regularly delete a directory on an app server.
    How to run this report as a job every 10 minutes?
    Thanks a lot,
    Olian

    Hi Olian,
    Follow the below steps:-
    1) execute SM36, give the job name.
    2) Click on "Start condition" on the top
    3) Select the approriate triggering way for e.g. if your report should start immediately then press "immediate" .
    4) Select the "Periodic job" check box
    5) Click on "Period values" and then click on "Other Period"
           give the time you wish to give like provide 10 in the   
           minute(s) field.
    6) Save!! it will work
    Also go to "Step" option on the SM36 to provide the report name which you want to execute.
    Thanks and revert back if you need more info.
    Harry

  • Launchd: How to Run a Job Only When Waking?

    I want to run a script when the computer wakes from sleep. I've read everything I can find about launchd and cannot find a solution.
    I tried RunAtLoad, but it did not run the script when the computer woke from sleep.
    Is there a parameter for launchd that will run a job only when the computer wakes from sleep?
    I know other parameters like StartInterval will run any "queued" jobs when the computer wakes up, but I'm looking for a parameter that runs the job only when the computer wakes up.
    Any help is appreciated.
    Thanks
    Brett

    Sorry, but there is no capacity for that built into launchd.  You might be able to hack something together (I've tried before, with some limited success), but it will be easier and more stable to use sleepwatcher. 

  • How to run a job automatically with file watcher

    Hi,
    I want to execute below job automatically when the file arrived in the oracle directory path..
    I am able to run the job manually.
    version details
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    "CORE 11.2.0.3.0 Production"
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    BEGIN
        SYS.DBMS_SCHEDULER.CREATE_JOB (
                job_name => '"UPN_COMMON"."EMPJOBS"',
                job_type => 'STORED_PROCEDURE',
                job_action => '"UPN_COMMON"."INS_EMP"',
                number_of_arguments => 0,
                start_date => TO_TIMESTAMP_TZ('2013-09-30 09:22:20 America/New_York','YYYY-MM-DD HH24.MI.SS TZR'),
                event_condition => '(1=1)',
                queue_spec => '"UPN_COMMON"."FILE_WATCHER"',
                end_date => TO_TIMESTAMP_TZ('2013-09-30 10:52:20 America/New_York','YYYY-MM-DD HH24.MI.SS TZR'),
                job_class => '"SYS"."DEFAULT_JOB_CLASS"',
                enabled => FALSE,
                auto_drop => FALSE,
                comments => 'TESTING A PROCEDURE',
                credential_name => NULL,
                destination_name => NULL);
        SYS.DBMS_SCHEDULER.SET_ATTRIBUTE(
                 name => '"UPN_COMMON"."EMPJOBS"',
                 attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_OFF);
        SYS.DBMS_SCHEDULER.SET_ATTRIBUTE(
                 name => '"UPN_COMMON"."EMPJOBS"',
                 attribute => 'max_run_duration', value => INTERVAL '1' MINUTE);
        SYS.DBMS_SCHEDULER.SET_ATTRIBUTE(
                 name => '"UPN_COMMON"."EMPJOBS"',
                 attribute => 'schedule_limit', value => INTERVAL '1' MINUTE);  
        SYS.DBMS_SCHEDULER.enable(
                 name => '"UPN_COMMON"."EMPJOBS"');
    END;

    >I want to execute below job automatically when the file arrived in the oracle directory path..
    the code which results in the file arriving in the Oracle directory path needs to be enhanced to invoke the desired PL/SLQ procedure.
    file arrival is OS operation that Oracle knows nothing about &  is totally & completely oblivious to this event

  • How To Run Background Job on Specific Date of Every Month

    Hi,
    I am looking for an option there we can Run Background job On Specific Date!
    Example: Task Name: Zprg1 > each month of "18", and same I want to repeat after 3 Days means on "22", then want to repeat after 5 days means on "28"
    please suggest.

    Hi swapZ,
    this is very easy:
    1. Schedule the Job Zprg1 on the 18th of this month and enter a mothly period:
    2. copy this job to new name  Zprg1_plus3 and repeate the action of point 1 with the date 22.04.2015.
    3. copy this job to new name  Zprg1_plus5 and repeate the action of point 1 with the date 28.04.2015.
    You will get thre jobs running every month on 18. 22. and 28.
    Best regards
    Willi Eimler

  • How to schedule a job Monday thru Friday only

    How can I schedule a job Monday thru Friday only?  I tried to use a Factory Calendar but we do not have any M-F calendars setup.  If I need to create a new factory calendar, how can I create on without any holidays?
    Thanks.
    Ryan

    Hi
    see this
    Create a Variant for the Program and
    Schedule JOB in background:
    Go to SM36 create a Job
    enter Program and Variant for that program in STEP..
    click on Start Condition
    Click on DATE and TIME enter date scheduled Start and END times
    click on Period Values
    Click on HOURLY/WEEKLY etc
    CLick on RESTRICTIONS also to use further criteria.
    so your job will be scheduled and run as per your requirement.
    and in SM37 Transaction check the status of that JOB
    Check this link for scheduling jobs..
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c4/3a7f87505211d189550000e829fbbd/content.htm
    Regards
    Anji

  • Run a job every 30min but only from 6am to 6pm

    I have a job that runs every 30 mins to process orders, and email failures. I only want this job to run from 6or 7am to 6pm M-F. I have other jobs that run once a day starting 1 minute past midnight. and and 4am. I do not want any conflicts as the both read the same tables. Using Enterprise Manager in 10g, I can only see how to schedule a job to repeat and start and stop but I want it to resbmit the schedule.
    Is this possible or will I have to schedule a 25 jobs to run ever 24hrs?
    thanks
    bj

    The job that runs every 30 minutes processes orders and changes the status, the midnight job runs the same stored procedure and then does a data reconciliation at the start before running accounting. The conflict could be data conflict. If both job start after midnight, the order job uses the order end date which would be the day before and an order that should be included in the nightly accounting run will not be. Although the system by default does not allow a user to enter an order end date outside of the 6AM to 6PM time range, we have had people use SQL*Plus to fix something and change the end date to 11:45PM thinking they entered 11:45AM.
    I think I have found an answer to my problem. I will have a job run a PL/SQL block that if the time is right execute the procedure. So far my test of the script by using a shorter time frame is working.
    my new job would look like this:
    begin
    If to_char(sysdate,'HH24:MI:SS') >= '06:00:00' and to_char(sysdate,'HH24:MI:SS') <= '18:00:00'then
    proc_fb_process_ord();
    end if;
    end;
    my test case is :
    DECLARE
    v_sender VARCHAR2 (100) := '[email protected]';
    v_recipients VARCHAR2 (1000) := '[email protected]';
    v_subject VARCHAR2 (250) := 'NG-DB01 TEST';
    v_message VARCHAR2 (4000);
    begin
    case
    when to_char(sysdate,'HH24:MI:SS') >= '12:00:00' and to_char(sysdate,'HH24:MI:SS') <= '12:30:00'then
    v_message := to_char(sysdate,'HH24:MI:SS')||' Between Time';
    when to_char(sysdate,'HH24:MI:SS') < '12:00:00' then
    v_message := to_char(sysdate,'HH24:MI:SS')||' Before Time';
    when to_char(sysdate,'HH24:MI:SS') > '12:30:00'then
    v_message := to_char(sysdate,'HH24:MI:SS')||' After Time';
    end case;
    demo_mail.mail (v_sender, v_recipients, v_subject, v_message);
    end;
    /

  • Running Chain Job in Restricted Session

    I have my normal jobs running is Restricted Session
    DBMS_SCHEDULER.SET_ATTRIBUTE('job_name', 'ALLOW_RUNS_IN_RESTRICTED_MODE', TRUE);
    I did the same for my chain job. The chain job starts but the first step doesn't start until out of restricted session.
    I get this if I try to set_attribute on a program
    ORA-27469: ALLOW_RUNS_IN_RESTRICTED_MODE is not a valid program attribute
    ORA-06512: at "SYS.DBMS_ISCHED", line 4436
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 2925
    Is there some way to run the steps of a chain in restricted session?
    11gR2

    Greg Here is an example I created for you. It is very close to what I am doing and I was able to duplicate the problem with it.
    -- replace sch_util.send_mail()   with your own PL SQL code.
    DECLARE
    v_job_name VARCHAR2(32) := 'example_job';
    v_chain_name VARCHAR2(32) := 'example_chain';
    BEGIN
    --drop chain and job
    BEGIN
      DBMS_SCHEDULER.DROP_CHAIN(v_chain_name,TRUE);
    EXCEPTION WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE('Error DROP_CHAIN ' || v_chain_name);
    END;
    BEGIN
      DBMS_SCHEDULER.DROP_JOB(v_job_name, TRUE);
    EXCEPTION WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE('Error DROP_JOB ' || v_job_name);
    END;
    --create all the programs for chain
    DECLARE
      v_pl_sql VARCHAR2(4000) := 'BEGIN sch_util.send_email(''example chain step 1'', ''Hellow world 1''); END;';
      v_prog_name VARCHAR2(32) := 'example_1_prog';
    BEGIN
      --drop program
      BEGIN
       DBMS_SCHEDULER.DROP_PROGRAM(v_prog_name);
      EXCEPTION WHEN OTHERS THEN
       DBMS_OUTPUT.PUT_LINE('Error DROP_PROGRAM ' || v_prog_name);
      END;
      --create program
      DBMS_SCHEDULER.CREATE_PROGRAM (
         program_name           => v_prog_name,
         program_action         => v_pl_sql,
         program_type           => 'PLSQL_BLOCK',  
         enabled                => TRUE,
         number_of_arguments    => 0,
         comments               => 'example chain step 1');
      DBMS_SCHEDULER.SET_ATTRIBUTE (
         name                   => v_prog_name,
         attribute              => 'max_run_duration',
         value                  => interval '240' minute );
    END;
    DECLARE
      v_pl_sql VARCHAR2(4000) := 'BEGIN sch_util.send_email(''example chain step 2'', ''Hello world 2''); END;';
      v_prog_name VARCHAR2(32) := 'example_2_prog';
    BEGIN
      --drop program
      BEGIN
       DBMS_SCHEDULER.DROP_PROGRAM(v_prog_name);
      EXCEPTION WHEN OTHERS THEN
       DBMS_OUTPUT.PUT_LINE('Error DROP_PROGRAM ' || v_prog_name);
      END;
      --create program
      DBMS_SCHEDULER.CREATE_PROGRAM (
         program_name           => v_prog_name,
         program_action         => v_pl_sql,
         program_type           => 'PLSQL_BLOCK',  
         enabled                => TRUE,
         number_of_arguments    => 0,
         comments               => 'example chain step 1');
      DBMS_SCHEDULER.SET_ATTRIBUTE (
         name                   => v_prog_name,
         attribute              => 'max_run_duration',
         value                  => interval '240' minute );
    END;
    -----------------------------Start Chain Definition -----------------------------------
    DBMS_SCHEDULER.CREATE_CHAIN (
         chain_name            =>  v_chain_name,
         comments              =>  'Example chain!');
    --- define steps for this chain.
    DBMS_SCHEDULER.DEFINE_CHAIN_STEP(v_chain_name, 'example_step1', 'example_1_prog');
    DBMS_SCHEDULER.DEFINE_CHAIN_STEP(v_chain_name, 'example_step2', 'example_2_prog');
    -- define corresponding rules for the chain.
    DBMS_SCHEDULER.DEFINE_CHAIN_RULE(v_chain_name, 'TRUE', 'START example_step1');
    DBMS_SCHEDULER.DEFINE_CHAIN_RULE(v_chain_name, 'example_step1 SUCCEEDED', 'START example_step2');
    DBMS_SCHEDULER.DEFINE_CHAIN_RULE(v_chain_name, 'example_step2 COMPLETED', 'END');
    -- enable the chain
    DBMS_SCHEDULER.ENABLE(v_chain_name);
    --- create a chain job to start the chain 
    DBMS_SCHEDULER.CREATE_JOB (
         job_name        => v_job_name,
         job_type        => 'CHAIN',
         job_action      => v_chain_name,
         start_date    => '6-AUG-2014 9.35.00 AM AMERICA/CHICAGO',
         enabled         => FALSE);
       DBMS_SCHEDULER.SET_ATTRIBUTE(v_job_name , 'max_run_duration' , interval '4' hour);
       DBMS_SCHEDULER.SET_ATTRIBUTE(v_job_name, 'raise_events',DBMS_SCHEDULER.JOB_FAILED);
       DBMS_SCHEDULER.SET_ATTRIBUTE(v_job_name, 'ALLOW_RUNS_IN_RESTRICTED_MODE', TRUE);
       DBMS_SCHEDULER.ENABLE(v_job_name);
    END;

Maybe you are looking for