Scheduled & Triggered Jobs

I have a Visual Basic console application that runs other Visual Basic back-end applications on a scheduled and triggered basis. I have a list of scheduled and triggered entries in a database that this console application will read upon starting up. The application runs the VB programs at scheduled times and simultaneously runs VB programs when the correct trigger files are present.
I want to port the applications over to Java 1.3/1.4. I'm very proficient in both Visual Basic and Java. Unfortunately, the operating system I am running is Windows 2000 :(
My idea is to have a Java application (which runs 24x7) that will run programs and/or threads to handle data processing (i.e. importing a text file into a relational database). We also are running Websphere Application Server 4.0 and I haven't found anything built into Websphere that will do this.
Questions:
How would I handle the following in Java:
1) At a particular time of the day, how could I schedule a java program and/or thread from a Java application?
2) How would I periodically check for trigger files (i.e. on a network share) within a Java application?
These (batch job) programs normally perform one of these functions:
1) Read a file received and import the file into a database table.
2) Export database records into a file and ftp the file off to a remote server.
All this would need to be done simultaneously. I have several good ideas on how to create this, but I wanted to get the advice of experts to see how they would attack these issues.
Please respond.
Bill

Bill,
It is possible that I do not fully understand the problem that you are trying to solve, but from what I read I can provide some suggestions:
1) At a particular time of the day, how could I schedule a java program and/or thread from a Java application?
You could write a timer class that fires off events at certain times of the day. These events would be picked up by a listener which would in turn create a thread to execute the necessary functions. When the functions are complete, the thread dies. Since you are writing data files be sure to synchronize the writing incase multiple threads attempt to write the data simultaneously.
2) How would I periodically check for trigger files (i.e. on a network share) within a Java application?
Again, this is a threading issue. Spin up a thread to periodically check if a file has come into existence since the last check. Here is a piece of code that can do the check:
long time = rightNow.getTime(); //setting the time
try { Thread.sleep(1000); } catch(Exception e) { } //waiting a period of time
if (file.exists() && file.lastModified() > time) //checking if a file has changed
time = file.lastModified();

Similar Messages

  • Schedule Background Job whenever new message WVINVE

    Hi All,
    I have following requirment:-
    Schedule Background Job with a ABAP program,
    whenever new message type WVINVE posted in SAP inbound.
    I am confused in "Event" which i select in SM36.
    Or, is there any other method to trigger a background report, whenever WVINVE03 IDOC posted in SAP system & create physical Inventory document.
    regards
    Umesh

    For triggereing a background job, when ever a message type WVINVE is posted. You need to create a
    Background Job with the the program and mark the Job Event periodic. Secondly you need to trigger that event from the Inbound processing program or Function module which processes the message type using the Function module <b>BP_EVENT_RAISE</b>. so when ever a message type is processed it will trigger the event which inturns trigger the Job.
    Hope this will Help.

  • How to schedule a job from r3 to BI daily ?

    Please let me know how to schedule a job frm bi to r3, that is i want to load data from a sd ds to a sd cube in bi. I do not want to use a PC and can i schedule a job daily without a PC, which can run daily after 10pm ,remember its not a manual schedule. Do we have any option to schedule in hourly, weekly, daily from bi to r3. If yes HOW ? i know we can do it thru infopackage group but will the infopackage group accept if its only a single load....I think it should have multiple infopackage rite to add it to a group or can it b a single job as well.
    Edited by: Manohar P on Oct 16, 2008 3:14 PM

    An infopackage group can only run infopackages, and unfortunately, you will need an ABAP program to trigger the event in R/3.  There is plenty of ABAP code in this forum to show you exactly how to do this. 
    Try this:
    Triggering a Process Chain From R/3 pgm
    R/3 Jobs Triggering  BW job
    You can also review OSS Note 135637.  This note will show from R/3 to BI (BW).  But you can reverse the logic to go from BI to R/3.
    Hope this helps.
    My suggestion would be to replace the infopackage group with a process chain, because you can call an ABAP program from a process chain.  You also have many more processes at your disposal using process chains.

  • Schedule a Job

    Hi,
    I have followed the following <a href="https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1515">blog</a> and inside the run method I have written a code which accesses user data and calls a Remote FM using JCA.
    The same code works when I execute in Abstract portal component.
    I have scheduled the job but the FM I wanted to call is not getting triggered at all.
    Can some one give me some idea of where should I look to solve this problem.
    Regards,
    Nagaraju Donikena
    Message was edited by:
            Nagaraju Donikena

    You will want to have a look at the <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/d2/5c830ca67fd842b2e87b0c341c64cd/frameset.htm">Logging and Tracing API</a>.
    To get started, you'll want to have a static variable in your scheduler task:
    static Location _loc = Location.getLocation(<classname>.class);
    and then you can make calls in individual methods like this:
    _loc.debugT("It's running!");
    In order for this method to work, you'll have to make sure that the location for the class in question is set to output for the "Debug" level.
    So if your Java class is "com.acme.example.MyClass", then you'll want to create a new location in Visual Administrator's Log Configurator with the same name (or any "parent" of this name, like "com.acme") and then make sure the severity is set to "Debug" to see the messages.
    Also, there used to be an issue with scheduler tasks where it was necessary to browse down through the entire configuration tree in the KM config iView and click on your task to get the KM runtime to load the task. This was in older versions.
    Do you see any errors in your logs?

  • Scheduling V3 Job.

    Hello experts,
    Need inputs on the below query..
    Background:
    There is V3 job scheduled for logistics application no. 11, 12, 13as follows
    LIS-BW-VB_APPLICATION_13_100---runs daily (all 7 days) at 00:00 for 6 mins
    LIS-BW-VB_APPLICATION_12_100---runs daily (all 7 days) at 19:30 for 6 mins
    LIS-BW-VB_APPLICATION_11_100----runs daily (all 7 days) at 00:00 for 16 mins
    Now there is a R/3 transport going on due to which all users on R/3 will be locked on saturday at 5am to 7am (2 hours). Please note that the R/3 transport is not related to any modifications related to above application no.s.(11,12,13)...the transports are for some other project.
    Also the corresponding process chains for logistics application no. 11, 12 and 13 do not run on saturdays and Sundays. The process chains runs daily from Monday to Friday.
    Question 1: What actions do i need to take considering the above scenario on BW side.
    Question 2: If i run the V3 job from LBWE screen (using Job Control tab) as Immediately, then after the completion of V3 job which were scheduled Immediately, will they be again scheduled as normally they use to (as mention above) OR do i need to again give the start condition (Run daily at 00:00 for appl no. 11, and so on..)
    Thanks.

    Hi,
    Question 1: What actions do i need to take considering the above scenario on BW side.
    Nothing needs to be done. You dont't even need to clear LBWQ/ RSA7 queues. They would be taken care of in the next run.
    Question 2: If i run the V3 job from LBWE screen (using Job Control tab) as Immediately, then after the completion of V3 job which were scheduled Immediately, will they be again scheduled as normally they use to (as mention above) OR do i need to again give the start condition (Run daily at 00:00 for appl no. 11, and so on..)
    If still you want to run the job as immediately, you have 2 ways,
    1. From LBWE schedule it the way you have mentioned. This way your job would be trigger only once. And the periodic job which is in place would not be impacted. It would continue to trigger on daily basis.
    2. Go to SM37. Here, you would find all your jobs in released status.(If you double click on these jobs, you would find that these jobs are scheduled to run on daily basis. Thats how this job gets triggered on daily basis)
    LIS-BW-VB_APPLICATION_13_100
    LIS-BW-VB_APPLICATION_12_100
    LIS-BW-VB_APPLICATION_11_100
    Simply, select any of these jobs. On menu bar, Job-> Repeat Scheduling-> Schedule the job immediately. This way again, your job would get scheduled and would not impact the normal frequency of the released job.

  • How to schedule a job in another system.

    Hi,
    Now i have an ABAP program, which run in system ABC, client 001. i want to schedule a job in the program, with the function modules JOB_OPEN, JOB_SUBMIT, and JOB_CLOSE. But this job should run in ABC/002.
    How to write code?
    Who can help me on the requirement, or provide me another new solution except event trigger?
    Thanks & Best Regards,
    Johnney

    Here is the code. It works fine..
    FUNCTION Z_F_TRIGGER_REPORT.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(I_PROG) TYPE  D010SINF-PROG
    *"     VALUE(I_VARIANT) TYPE  VARIS-VARIANT
    *"     VALUE(I_MODE) TYPE  CHAR01
    *"  EXPORTING
    *"     VALUE(E_SUBRC) TYPE  SYST-SUBRC
    *"     VALUE(E_MSG) TYPE  CHAR80
    Functio ID :  Z_F_TRIGGER_REPORT
    TITLE      :  Report Trigger Tool
    Create Date:  15.03.2004
    Author     :  Denis Vieira
    Ownership : For the exclusive use of the Procter & Gamble Company
    Description:
    The purpose of this function module is to trigger programs
    requested remotely.
    AUTHORIZATION CHECKS
    OBJECT               AUTHORITY FIELDS         ABAP FIELDS
                     |                       |
    CHANGE HISTORY                                                      *
      DATE      |  Name  | Description                       | Reference *
    29.Jun.2006 | BA4513 | Unicode conversion and upgrade    | SPK290606
                |        | to My SAP ERP                     |
    **eject.
    Check if selected program exists in the destination file
      SELECT SINGLE  SUBC
             FROM    D010SINF
             INTO    D010SINF-SUBC
             WHERE   PROG    EQ  I_PROG
             AND     R3STATE EQ  C_A.
      IF SY-SUBRC NE C_0.
        MOVE  C_2                                               TO E_SUBRC.
        MOVE 'Report does not exist in destination system'(M01) TO E_MSG.
        EXIT.
      ENDIF.
    Check if program request is an executable program
      IF D010SINF-SUBC NE C_1.
        MOVE  C_2                                               TO E_SUBRC.
        MOVE 'Report is not an executable program'(M02)         TO E_MSG.
        EXIT.
      ENDIF.
    Check if selected variant exists in the destination file
      SELECT COUNT( * )
           FROM  VARIS
           INTO  W_COUNT
           WHERE REPORT  EQ I_PROG
           AND   VARIANT EQ I_VARIANT
           AND   DYNNR   EQ C_1000.
      IF W_COUNT EQ C_0.
        MOVE  C_2                                                TO E_SUBRC.
        MOVE 'Variant does not exist in destination system'(M03) TO E_MSG.
        EXIT.
      ENDIF.
      IF I_MODE EQ C_B.
        PERFORM 0100_BACKGROUND USING     I_PROG I_VARIANT
                                CHANGING  E_MSG  E_SUBRC.
      ELSE.
        PERFORM 0200_FOREGROUND USING     I_PROG I_VARIANT
                                CHANGING  E_MSG  E_SUBRC.
      ENDIF.
    ENDFUNCTION.
    *eject
    *&      Form  0100_background
    Executes Selected program in BackGround Mode VIA JOB
    *Block commented from here SPK290606
    *FORM 0100_BACKGROUND USING     L_PROG L_VARIANT
                        CHANGING  L_MSG  L_SUBRC.
    *Block commented till here SPK290606
    *Block added from here SPK290606
    FORM 0100_BACKGROUND USING    L_PROG    LIKE D010SINF-PROG
                                  L_VARIANT LIKE VARIS-VARIANT
                         CHANGING L_MSG     TYPE  CHAR80
                                  L_SUBRC   TYPE  SYST-SUBRC.
    *Block added till here SPK290606
      CONCATENATE C_AREA
                  C_UND
                  L_PROG
                  C_UND
                  SY-DATUM
                  C_UND
                  SY-UZEIT
                  INTO W_JOBNAME.
    Create a JOB and Get the Number for further execution
      CALL FUNCTION 'JOB_OPEN'
           EXPORTING
                JOBNAME  = W_JOBNAME
           IMPORTING
                JOBCOUNT = W_JOBCOUNT.
      IF SY-SUBRC NE C_0.
        MOVE  C_2                       TO L_SUBRC.
        MOVE 'Error opening job'(M07)   TO L_MSG.
        EXIT.
      ENDIF.
    Submit program
      SUBMIT (L_PROG)
        USING SELECTION-SET L_VARIANT
        VIA JOB W_JOBNAME NUMBER W_JOBCOUNT
        AND RETURN.
      IF SY-SUBRC NE C_0.
        MOVE  C_2                        TO L_SUBRC.
        MOVE 'Error Submitting Job'(M06) TO L_MSG.
        EXIT.
      ENDIF.
    Closes job to start its processing
      CALL FUNCTION 'JOB_CLOSE'
           EXPORTING
                JOBCOUNT  = W_JOBCOUNT
                JOBNAME   = W_JOBNAME
                STRTIMMED = 'X'.
      IF SY-SUBRC NE C_0.
        MOVE  C_2                       TO L_SUBRC.
        MOVE 'Error closing job'(M08)   TO L_MSG.
        EXIT.
      ENDIF.
      MOVE  C_0                                          TO L_SUBRC.
      MOVE 'Program Submitted in Background Mode'(M09)   TO L_MSG.
    ENDFORM.
    *eject
    *&      Form  0200_foreground
    Executes Selected program in ForeGround Mode VIA Submit
    *Block commented from here SPK290606
    *FORM 0200_FOREGROUND USING     L_PROG L_VARIANT
                        CHANGING  L_MSG  L_SUBRC.
    *Block commented till here SPK290606
    *Block added from here SPK290606
    FORM 0200_FOREGROUND USING    L_PROG    LIKE D010SINF-PROG
                                  L_VARIANT LIKE VARIS-VARIANT
                         CHANGING L_MSG     TYPE  CHAR80
                                  L_SUBRC   TYPE  SYST-SUBRC.
    *Block added till here SPK290606
      SUBMIT (L_PROG) USING SELECTION-SET L_VARIANT
             EXPORTING LIST TO MEMORY AND RETURN.
      IF SY-SUBRC EQ C_0.
        MOVE  C_0                                 TO L_SUBRC.
        MOVE 'Report submitted successfully'(M04) TO L_MSG.
      ELSE.
        MOVE  C_2                                 TO L_SUBRC.
        MOVE 'Error submitting report'(M05)       TO L_MSG.
      ENDIF.
    ENDFORM.

  • Schedule Background Job :  Remove delivery Block in Sales order

    Hi Gurus,
    I have a requirement to select all sales orders as per a condition and remove delivery block at
    VA02-> Go to -> Header -> Status
    For that I have to write a program which will be run only in background and i have to schedule background job for the same.
    I have a parameter at selection - No of records
    If no of records = 500 , I have to submit 500 jobs ie one job each for each sales order for removing delivery block.
    I need to know
    1) Which function module/bapi I can use to remove delivery block at sales order header level.
        For blocked delivery the status is 'BSTK" . to remove block i need to change status to "RSTK".
    2) How to schedule a background job for my program and how to submit one job each for each sales   order.
    Regards
    Avi.

    Hi Avi,
    Would like to seek for your advice. I am facing the same scenario too which is to delete the delivery block but is deletion of the delivery block is done in the user exit MV45AFZZ. The subroutine which needs to have the extra logic of deleting the delivery block is USEREXIT_SAVE_DOCUMENT_PREPARE.
    Need your advice on how do you solve this scenario? Thanks in advance.

  • Error in Schedule Background Job for Deadline Monitoring of swu3

    While Auto Customization swu3 i am getting error message 'Output device "" not known' in 'Schedule Background Job for Deadline Monitoring'
    Please advice what could be cause of it

    the earlier problem of background job was solved by changing the  output device assigned to user wf-batch .
    regarding the transport request :
    when i was trying to execute the step : "Schedule bakgrd for missed deadlines " MANUEL it was giving me an option of SAVE AND SCHEDULE . which was creating the transport request . but when i executed it automatically it worked fine without asking a request to me ... i don't know why )-: ... probablly we can specify a different interval then the standard of three minutes and which will be transported (it's just a guess) . i have  executed it  automatically ...
    well thanks all for u r help

  • How to schedule the job to run evry Sunday at 12 P.M IST.

    Hi Experts,
    I want to schedule a job which will run evry Sunday at 12 P.M IST.
    I have written the below script.
    [code]BEGIN
      SYS.DBMS_SCHEDULER.CREATE_JOB
           job_name        => 'SERVICE_SAL_FS.SAL_MESSAGE_BUFFER_PURGE_JOB'
          ,start_date      =>  SYSTIMESTAMP
          ,repeat_interval => 'FREQ=WEEKLY; BYDAY=SUN; BYHOUR=12;BYMINUTE=0; BYSECOND=0;'
          ,end_date        =>  NULL
          ,job_class       => 'DEFAULT_JOB_CLASS'
          ,job_type        => 'STORED_PROCEDURE'
          ,job_action      => 'SERVICE_SAL_FS.SAL_MESSAGE_BUFFER_PURGE_PROC'
          ,comments        => 'Run at 12 P.M.IST every Sunday'
          ,enabled            => TRUE
    END;[/code]
    But the server in US.
    [code]SELECT sysdate from Dual;
    6/11/2013 3:58:58 AM
    --But the time in India is 02:28 PM [/code]
    How to convert the timezone to IST.
    Please help me how to schedule the job to run evry Sunday at 12 P.M IST.
    Thanks.

    Did you read DBMS_SCHEDULER docs:
      The calendaring syntax does not allow you to specify a time zone. Instead the Scheduler retrieves the time zone from the start_date argument. If jobs must follow daylight savings adjustments you must make sure that you specify a region name for the time zone of the start_date. For example specifying the start_date time zone as 'US/Eastern' in New York will make sure that daylight saving adjustments are automatically applied. If instead the time zone of the start_date is set to an absolute offset, such as '-5:00', daylight savings adjustments are not followed and your job execution will be off by an hour half of the year.
      When start_date is NULL, the Scheduler will determine the time zone for the repeat interval as follows: 
    It will check whether the session time zone is a region name. The session time zone can be set by either:
    Issuing an ALTER SESSION statement, for example:
    SQL> ALTER SESSION SET time_zone = 'Asia/Shanghai'; 
      Setting the ORA_SDTZ environment variable.
      If the session time zone is an absolute offset instead of a region name, the Scheduler will use the value of the DEFAULT_TIMEZONE Scheduler attribute. For more information, see the SET_SCHEDULER_ATTRIBUTE Procedure.
      If the DEFAULT_TIMEZONE attribute is NULL, the Scheduler will use the time zone of systimestamp when the job or window is enabled.
    SY.

  • Creating a job and scheduling a job error in OEM

    Hi, Everyone,
    I am trying to create and schedule a job thru OEM. In the the pl/sql block provide i have given my code like this
    begin
    SET SERVEROUTPUT ON;
    SPOOL C:\RFV_PROFILE_REPORT.LOG APPEND;
    SELECT TO_CHAR(SYSDATE, 'DD/MM/YY HH24:MI:SS') FROM DUAL;
    EXEC PAC_RFV_PROFILE_REPORT.CALL_ALL (200910);
    SELECT TO_CHAR(SYSDATE, 'DD/MM/YY HH24:MI:SS') FROM DUAL;
    SPOOL OFF;
    end;
    i have created the job and scheduled it but i am getting this error:
    Error # 6550
    Details ORA-06550: line 2, column 5: PL/SQL: ORA-00922: missing or invalid option ORA-06550: line 2, column 1: PL/SQL: SQL Statement ignored ORA-06550: line 3, column 7: PLS-00103: Encountered the symbol "C" when expecting one of the following: := . ( @ % ;
    could anyone pls help as this is very urgent.
    Thanks in advance

    Ah, the problem is you are confusing SQLPlus commands with PL/SQL.
    SET SERVEROUTPUT ON; -- This is a SQLPlus command, not necessary here.
    SPOOL C:\RFV_PROFILE_REPORT.LOG APPEND; -- This is a SQLPlus command, in PL/SQL to write out to a file you will need to call the UTL_FILE package to open a file for writing to. Except that the file you write to will appear on the database server, not your workstation, when the scheduled job runs.
    SELECT TO_CHAR(SYSDATE, 'DD/MM/YY HH24:MI:SS') FROM DUAL; -- In PL/SQL you need to SELECT columns INTO variables FROM tables. But in fact I guess you want to write the time to file using UTL_FILE again. However, you don't really need to do this, since scheduler will log the start time and run duration itself.
    EXEC PAC_RFV_PROFILE_REPORT.CALL_ALL (200910); -- This is the SQLPlus equivalent of the PL/SQL command:
    BEGIN
    PAC_RFV_PROFILE_REPORT.CALL_ALL (200910);
    END;
    SPOOL OFF; -- This is a SQLPlus command, not necessary here.
    So to summarise, all you really need is:
    BEGIN
    PAC_RFV_PROFILE_REPORT.CALL_ALL (200910);
    END;
    And the scheduled job will log the start time and duration in the database, which you can find here:
    SELECT * FROM USER_SCHEDULER_JOB_RUN_DETAILS

  • Scheduling background job on Logon group

    Hi All,
    We have 4  logon groups configured in SMLG, while scheduling the job  in SM36 ->Target server field i am able to see only one group and other indivdual servers not  all the Groups configured in SMLG.
    Is there any option i have to check to let all the groups configured in SLMG to diaply in  SM36 for scheduling so that i can select the Logon group. I tried giving the logon group names manually which are not listed in Target server field it's giving the error group not exist..
    Please suggest..how to make all the Groups configured in SMLG to get displayed in SM36  for scheduling jobs...
    Thanks,
    Subhash.G

    Target server field is Name of an SAP instance at which a background job should be run.  The name has the following format:  <host name>_<SAP System name>_<SAP System number>, where host name is the name of the server computer on which the instance is running, as specified in the system profile parameter SAPLOCALHOST.
    The name of each instance is specified in the system profile parameter rdisp/myname.
    Example:  hs0123_C11_55
    In programming:  As the table field EXECSERVER, shows the target instance selected by the user for running a job.  As the table field REAXSERVER, shows the SAP instance at which a job was actually run.
    Hope this is clear.
    Thank you,
    Shyam

  • Schedule background jobs which run only on Thursdays.

    Dear Friends,
    We are using ECC6.00. I have a requirement whereby a specific job (background) should be executed only on Thursdays. I searched in this forum but couldn't get anything related to my question. I tried the options present in the SM36 transactions (scheduling options).
    Is there any way of achieving my requirement.? Experts help required.
    Regards,
    M.M

    Hi Magesh,
    I am not sure if this would be the right approach. But if you are really sure that there is no way to do this using SM36 settings,
    you can schedule a job to execute daily, which would be a custom abap program.
    This program would check the day and if it is a thursday ,will schedule another job for the day(programatically).
    This can be a way around to solve this problem.
    Regards,
    Sagar

  • Schedule background job using system variant

    Dear gurus,
    We're planning to schedule background job using system variant, for example, current fiscal year and current posting period (transaction AFAB). Is it possible? So for example, for this month, "Posting Period" value will be 6, and then next month will be 7.
    Can you tell me how to do this, if I want to set up the schedule only once?
    Thanks for your help.
    Best Regards,

    done using abap

  • Schedule background job programatically

    Hi,
    I want to schedule background job programatically  .
    Also, I want to specify the scheduled start time & start date .
    Please suggest .
    Moderator message - This question has been asked and answered many times before. Please search before posting.
    Edited by: Rob Burbank on Apr 16, 2009 12:27 PM

    Hi
    Please check this link
    [http://help.sap.com/saphelp_46c/helpdata/en/fa/096ee5543b11d1898e0000e8322d00/frameset.htm]
    Thanks,
    Hari

  • Schedule background jobs at OS level.....

    Hi All,
    Scheduling Background Jobs at SAP Level is a very simple task. Is there any way to schedule background jobs at OS level? Please lemme ASAP....
    Thanks
    Rhishabh

    Hi Rhishabh,
    Actually we can not completely schedule background at OSLevel but we can trigger a background job which has alreadyscheduled by using sapevt tool syntax as follows.
    sapevt <event name> nr=<instance name> name=<host name>
    or we have tool like
    In unix you use crontab.
    We can use different job scheduling softwares like IBM TIVOLI software MAESTRO JOB SCHEDULING CONSOLE, Control M
    Regards,
    Kiran M

Maybe you are looking for