How to run long background jobs in ADF applications

Hi,
I'm looking for some guidance on how to run an asynchronous job within an ADF application with proper progress notification in the current page.
Let's assume we have some long running task (e.g. generating notification emails from a bunch of rows in my view object and send them) with the corresponding classes implemented in the DataModel as part of the business logic (e.g. a class that sends a mail to a given recipient).
Let's assume all the relevant methods can be exposed in the appmodule's client interface so they can be invoked from the ViewController if needed.
In my jspx page I have implemented the standard af:poll+af:progressIndicator mechanism to give feedback about the running task, backed by a custom BoundedRangeModel
with methods getValue() and getMaximum(). This works.
However, all the examples I've found on the net are very very simplistic and only deal with simple counters or countdowns.
But how to actually implement the whole mechanism in a real life scenario? How do I run the job itself and make it give feedback to my BoundedRangeModel class
(which in turn is used by the progressIndicator on the page)?
Is there a recommended way to do this within ADF apps? I've tried to search something about asynchronous method execution in ADF but there seems to be nothing out there.
Do I need to use standard Java techniques such as a separate Thread running a Runnable worker? Should I use an observer/observable pattern to notify BoundedRangeModel
and update its internal variables (current value and maximum)? Would this work across a Datacontrol interface?
Is anything of this allowed within the ADF framework or I'm just gonna break the whole framework model because do-it-yourself concurrent programming isn't allowed in a multithreaded pooled environment?
Some explanation about the current recommended best practices and/or some practical examples or articles about that would be great.
(BTW: I'm using version 11.1.1.2.0 and yes, I've checked the contextual events thing too, but that's just an inter-page communication mechanism so it has has nothing to do with what I need to do.)

Hi
I have implement a "Runner" class to generate a pdf to every customer of a mailmerge file, which was uploaded. Its simply easy to do something like this. Just add a button, bound the button with a methode out of you applicationModule and start your implementing Thread in this methode.
public class Runner implements Runnable {
    private String docFileName;
    private String csvFileName;
    private byte[] csvData;
    private byte[] docData;
    private FtpClient client;
    private String category;
    public Runner(String category, String docFileName, byte[] docData,
                  String csvFileName, byte[] csvData, FtpClient client) {
        this.category = category;
        this.docFileName = docFileName;
        this.docData = docData;
        this.csvFileName = csvFileName;
        this.csvData = csvData;
        this.client = client;
    public void run() {
}In your applicationModule, you can start your Runner like this:
        Runner runner =
            new Runner(category, docFileName, docData, csvFileName, csvData, client);
        new Thread(runner).start();And to the problem with your progressBar. I would create a managedBean with a HashMap<String, HashMap<String, String>>. Every thread you start, add a HashMap<String, String> to this hashmap with the id of the username/session/whatever (must be bound to the user, which starts the thread). This added HashMap<String, String> should be used by your thread to put some status-information into. Now you can try to bind this info to your progressBar.
I dont know if this will work, it is just an idea ;-)
Regards
Majo

Similar Messages

  • How to run a background job with the cloud_scheduler package

    Hi,
    Is the cloud_scheduler package able to run background jobs as documented? When you try to run a job in another session using:
    cloud_scheduler.run_job(job_name=>'MYJOB', use_current_session=>false);
    The call fails with:
    ORA-20002: Cannot run job MYJOB. Adhoc background execution is disallowed. Please enable the job instead.
    If you try to use cloud_scheduler.enable to run the job then the job does not run when scheduled.
    Rod West

    Hi Rod,
    Yes, I believe so. Here's a test case that I just ran successfully from SQL Workshop in my database trial service:
    create table myjob_test (aa timestamp with time zone);
    begin
        cloud_scheduler.create_job (
            job_name        => 'MYJOB',
            job_type        => 'PLSQL_BLOCK',
            job_action      => 'begin insert into myjob_test values (systimestamp); commit; end;',
            repeat_interval => 'freq=minutely; interval=3' );
    end;
    begin
        cloud_scheduler.enable ( name => 'MYJOB' );
    end;
    select job_name, state, run_count, failure_count, last_start_date, next_run_date, systimestamp from sys.user_scheduler_jobs;
    select * from myjob_test order by aa;Is the next_run_date in the past for your job? If it is, try disabling/enabling the job to "reinitialize" the job's schedule.
    -- Vlad

  • Office intergration - run as background job

    Hi,
      I have a word template merged with data using "Desktop Office Integration".
      Currently word template will be opened before data merging is done.
      Is it possible to run as background job, which word template can merge with data in backend? If possible, how should i work on it?
    Kindly advise.
    Thanks,
    Ginnie

    Hi,
      Thanks for your prompt reply.
      Is there any other methods which i can pull my data from table and merge to a word document?
      Or is it possible to generate PDF in this case?
      I need it to be a backend job.
      Any suggestion? Kindly advise.
    thanks,
    ginnie

  • How to schedule a background Job based on events

    Hi,
    We are on 4.6 C.
    We have a background job that has two ABAP programs.
    We need to start the 2nd ABAP program only after the first one has run successfully.
    If the second ABAP program does not run, the the job should have a status "FINISHED".
    Help appreciated.
    Thanks
    Mala

    Hi,
    How to schedule a background Job based on events,please refer to the follow SAP help:
    You can use events that have already been defined, or you can create new events for scheduling background jobs.
    If you wish to use new events, do the following to implement the event scheduling:
    Define and transport the event as a user event with transaction SM62.
    You must define only event IDs; event arguments are not defined in the R/3 System. Instead, you specify event arguments when you schedule a job to wait for an event and when you trigger the event.
    If you define a new event, you must also transport it to your production systems. The event transaction does not have a connection to the transport system. Instead, you must create a transport request for the event yourself.
    Do this to transport an event:
    Create a transport request.
    Start the editor in the transport request and enter the following:
    R3TR TABU <table name> where table name is BTCSEV for a system event ID, BTCUEV for a user event ID.
    Press F2 with the cursor on the table name to call up the screen for specifying the table entries to transport. In this screen, enter the event ID’s that you have created.
    Save and release the transport request. Ensure that it is imported into your production system(s).
    To trigger an event, add:
    – the function module BP_EVENT_RAISE to your ABAP program, or
    – the program SAPEVT to your external script, batch file, or program.
    When your programs execute these keywords, an event will be triggered in the R/3 background processing system. The event-based scheduler is started immediately. It in turn starts all jobs that were waiting upon the event, subject to normal background processing restrictions, such as the requirement that the job has been released to start.
    Schedule the jobs that are to run when your events are triggered.
    You can schedule jobs for one-time start or to be started whenever an event is triggered.
    Regards,
    collysun

  • How to Schedule SAP background job at OS Level

    Hi All,
    Can Anyone tell me how to Schedule SAP background job at OS Level (unix).
    Regards,
    Anil

    Hi Anil,
    I donu2019t know your requirements, anyway itu2019s possible to setup your SAP job in order to start after an event, and after that you can get the event triggered from the Operating System in the following way:
    - 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.
    You can periodically execute this job with crontab.
    Thanks,
    Federico Biavati

  • How to schedule the background job daily twice?

    Hi,
    How to schedule the background job daily twice? any conditions?
    Regards,
    Srihitha

    see the step by step procedure.
    Scheduling Background Jobs:
    1. Background jobs are scheduled by Basis administrators using transaction SM36.
    2. To run a report in a background, a job needs to be created with a step using the report name
    and a variant for selection parameters. It is recommended to create a separate variant for each
    scheduled job to produce results for specific dates (e.g. previous month) or organizational units (e.g.
    company codes).
    3. While defining the step, the spool parameters needs to be specified
    (Step-> Print Specifications->Properties) to secure the output of the report and help authorized users
    to find the spool request. The following parameters needs to be maintained:
    a. Time of printing: set to “Send to SAP spooler Only for now”
    b. Name – abbreviated name to identify the job output
    c. Title – free form description for the report output
    d. Authorization – a value defined by Security in user profiles to allow those users to access
    this spool request (authorization object S_SPO_ACT, value SPOAUTH). Only users with matching
    authorization value in their profiles will be able to see the output.
    e. Department – set to appropriate department/functional area name. This field can be used in
    a search later.
    f. Retention period – set to “Do not delete” if the report output needs to be retained for more
    than 8 days. Once the archiving/document repository solution is in place the spool requests could
    be automatically moved to the archive/repository. Storage Mode parameter on the same screen
    could be used to immediately send the output to archive instead of creating a spool request.
    Configuring user access:
    1. To access a report output created by a background job, a user must have at
    least access to SP01 (Spool requests) transaction without restriction on the user
    name (however by itself it will not let the user to see all spool requests). To have
    that access the user must have S_ADMI_FCD authorization object in the profile with
    SPOR (or SP01) value of S_ADMI_FCD parameter (maintained by Security).
    2. To access a particular job’s output in the spool, the user must have
    S_SPO_ACT object in the profile with SPOAUTH parameter matching the value used
    in the Print Specifications of the job (see p. 3.d above).
    3. Levels of access to the spool (display, print once, reprint, download, etc) are
    controlled by SPOACTION parameter of S_SPO_ACT. The user must have at least
    BASE access (display).
    On-line reports:
    1. Exactly the same configuration can be maintained for any output produced
    from R/3. If a user clicks “Parameters” button on a SAP Printer selection dialog, it
    allows to specify all the parameters as described in p. 3 of
    “Scheduling background jobs” section. Thus any output created by an online report
    can be saved and accessed by any user authorized to access that spool request
    (access restriction provided by the Authorization field of the spool request
    attributes, see p. 3.d of “Scheduling background jobs” section).
    Access to report’s output:
    1. A user that had proper access (see Configuring user access above) can
    retrieve a job/report output through transaction SP01.
    2. The selection screen can be configured by clicking “Further selection
    criteria…” button (e.g. to bring “Spool request name (suffix 2)” field or hide other
    fields).
    3. The following fields can be used to search for a specific output (Note that
    Created By must be blank when searching for scheduled job’s outputs)
    a. Spool request name (suffix 2) – corresponds to a spool name in p. 3.b in
    “Scheduling background jobs” section above).
    b. Date created – to find an output of a job that ran within a certain date range.
    c. Title – corresponds to spool Title in p. 3.c in “Scheduling background jobs”
    section above).
    d. Department - corresponds to spool Department in p. 3.e in “Scheduling
    background jobs” section above).
    4. Upon entering selection criteria, the user clicks the Execute button to
    retrieve the list of matching spool requests.
    5. From the spool list the user can use several function such as view the
    content of a spool request, print the spool request, view attributed of the spool
    request, etc. (some functions may need special authorization, see p.3 in
    Configuring user access)
    a. Click the Print button to print the spool request with the default attributes
    (usually defined with the job definition). It will print it on a printer that was
    specified when a job was created.
    b. Click the “Print with changed attributed” button to print the spool request
    with the different attributes (e.g. changing the printer name).
    c. Click the “Display contents” button to preview the spool request contents. A
    Print and Download functions are available from the preview mode.

  • How to stop the background job "Sap_collector_for_job_statistic"

    Dear All,
    Kindly let me know how to stop the Background job "Sap_collector_for_job_statistic" which is running everyday.
    We want to stop this background job.
    Kindly suggest.
    Regards,
    Mullairaja

    Select the Job using SM37 transaction. In the Menu Choose
    Job ---> Cancel Active Job.
    Before you do this it may be good idea to check the pid using SM50.
    It will be using a Background work process. Check the pid and the status.
    Select the same and in the Menu Choose Process --> Cancel with Core.
    Refresh and check in SM37 for the Active and Cancelled Jobs.

  • How to debug the background job in ABAP

    Hi Guys,
    Can anyone let me know how to debug the background job in ABAP.
    Thanks in advance
    peter

    Hi,
    Goto SM37 and see the log if any is there and based on that you can check the code.
    you can't debug background job.
    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
    Check this
    http://jplamontre.free.fr/SAP/Debug%20background%20process.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/abap/abap+debugger&
    Regards,
    Padmam.

  • How to kill a background job

    Hi Experts,
    I would like to ask on how to kill a background job in SAP? I have tried to cancel it via sm50, sm37, dpmon, and even the kill -9 command but none of those commands can solve the issue still the job is running.
    Can you guide me on how to deal to such issue and if you know a command on how to kill that particular job.
    Hoping for your immediate response.

    Hi,
    I think you may not have proper authorization to kill the job.
    You can kill the job through SM50 as follows.
    SM50 -> Choose the background job -> click Process -> and then click Cancel without core.
    If the job is still not getting killed you can ask your basis person to kill it.
    Regards
    Vimal

  • How to cancel scheduled background job?

    Hi,
    I have used FM 'HR_START_BATCHJOB_IN_OTHER_SYS' to schedule background job.
    Some mistake has happend and this FM calling has gone to infinite loop. So, now the system is keep on generating background job. I tried looking into SM36 to stop this background job but i failed.
    Can anybody help me how to stop scheduled background job please.
    Regards,
    Mukund.

    Hi,
    Check which background process your job is  running from the Job details and inform your Basis consultant to Kill the process. If you have sm50 acess or sm66 access you can do the same.
    Regards,
    Vijay v

  • Read Error logs after running the background jobs

    Hi,
    How to read the error logs after running the background jobs. In our scenarion we are running the COHV transaction to release the production orders in background. But we are not finding the error logs after background job. We would like to read the error logs and correct for further processing.
    Kindly suggest.
    Thanks & Regards,
    N. Laxman

    Hi
    you can check the  back ground jobs defined by any user in SM37 and where you can see the spool and job logs as well.
    plz check in your case and revert back
    Regards
    Anupam Sharma

  • How to schedule a background job in realtime

    Hi,
    Can you tell me how to schedule a background job in realtime.
    give some example scenerios in scheduling the background jobs in realtime.
    Thanks.
    sam.

    And also.....
    There are two ways for you to handle,
    one manually setting up the job through SM36 which is better and convinient,
    secondly through program using FM's JOB_OPEN, SUBMIT, JOB_CLOSE.
    Find below steps in doing both:
    Procedure 1:
    1. Goto Trans -> SM36
    2. Define a job with the program and variant if any
    3. Click on start condition in application tool bar
    4. In the pop-up window, click on Date/Time
    5. Below you can see a check box "Periodic Job"
    6. Next click on Period Values
    7. Select "Other Period"
    8. Now give '15' for Minutes
    9. Save the job
    Procedure 2 via Program:
    Below is a sample code for the same. Note the ZTEMP2 is the program i am scheduling with 15mins frequency.
    DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
    L_RELEASE(1) TYPE c.
    CALL FUNCTION 'JOB_OPEN'
    EXPORTING
    JOBNAME = 'ZTEMP2'
    IMPORTING
    JOBCOUNT = P_JOBCNT
    EXCEPTIONS
    CANT_CREATE_JOB = 1
    INVALID_JOB_DATA = 2
    JOBNAME_MISSING = 3
    OTHERS = 4.
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    SUBMIT ZTEMP2 VIA JOB 'ZTEMP2' NUMBER P_JOBCNT
    TO SAP-SPOOL WITHOUT SPOOL DYNPRO
    WITH DESTINATION = 'HPMISPRT'
    WITH IMMEDIATELY = SPACE
    WITH KEEP_IN_SPOOL = 'X' AND RETURN.
    CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
    JOBCOUNT = P_JOBCNT
    JOBNAME = 'ZTEMP2'
    STRTIMMED = 'X'
    PRDMINS = 15
    IMPORTING
    JOB_WAS_RELEASED = L_RELEASE
    EXCEPTIONS
    CANT_START_IMMEDIATE = 1
    INVALID_STARTDATE = 2
    JOBNAME_MISSING = 3
    JOB_CLOSE_FAILED = 4
    JOB_NOSTEPS = 5
    JOB_NOTEX = 6
    LOCK_FAILED = 7
    INVALID_TARGET = 8
    OTHERS = 9.
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Hope the above helps you.
    ***********reward points,if found useful

  • How to schedule the background job using current selection screen field val

    Hello Friends,
    How to schedule the background job using current selection screen field values.
    after completion of the job the spool should be sent as a mail to SAP Inbox.
    Is there any way to create the variant dynamically by reading the current selection screen values.
    Thanks,
    Ravi

    Hi,
    To get the variant details you can use teh following FM.
    'RS_VARIANT_CONTENTS'.
    Regards,
    Ankur Parab

  • ABAP program to run in Background job

    Hi,
    We have a custumized program (SO Creation) calling some functions (like: WS_QUERY, WS_UPLOAD, WS_DOWNLOAD, CREATE_TEXT and CALL TRANSACTION VA01) and can only run thru dialog process (foreground).  Is it possible to convert it to something that can run thru background job?
    Please help.
    Thanks.

    Hi Deo ,
    Unfortunately cl_gui_frontend_services will not work in background.
    Please have a look at following information about cl_gui_frontend_services :
    The class CL_GUI_FRONTEND_SERVICES contains static methods for the following areas:
    File functions
    Directory functions
    Registry
    Environment
    Write to / read from clipboard
    Upload / download files
    Execute programs / open documents
    Query functions, such as Windows directory, Windows version, and so on
    Standard dialogs (open, save, directory selection)
    To Use this, you should be bit familier with OO ABAP Concepts. So I will suggest you to go through with OO concepts of ABAP. It will be of great help to you.
    Regards,
    Nikhil

  • Regarding email attachement while running a background job

    Dear Experts,
    When i am running a background job for any ALV report (standard or custom report) <b>automatically</b> the output is going to an e-mail address as a HTML file attachment. I want to change it to EXCEL file attachment.
    Please help me on this issue..
    Kind Regards,
    Tom

    Hi Prasanna,
    Thank you for your reply.  I am not using any code for sending the mail to the recipient E-mail address, system is taking care automatically.
    Few settings were done in SCOT transaction from basis, but no where they mentioned file type is .HTM.
    From my end i have done the following steps.
    1. go to SM36, give a job name.
    2. press on step push button , give the ABAP program name ( any ALV program, i mean standard report or Z report), give the variant and save.
    3. Come back . press on Spool list recipient push button give the e-mail address, press copy button on the  pop up window.
    4. press on start condition button , press on Immediate option and save.
    5. again press on Save button in the screen.
    now here job will be scheduled immediately, go to SM37 check your job status, if it is completed, automatically system is sending an e-mail with the ".HTM" attachment file output to the recipient e-mail address.
    i am not doing any coding part here.
    my concern is system should send the e-mail with ".XLS" file output attachment.
    please advise on this.
    Regards,
    Tom.

Maybe you are looking for

  • Windows 7 x64 ***** on a macbook

    PLEASE HELP.... i'm in south america and a friend of mine bought a macbook (she actually returned one for a pc, then exchanged it back for a macbook again). this is a late 2009 white macbook (6.1) she's an architect and needs autocad, which is pc onl

  • Iphone 4; connected to wifi but in cannot connect safari and appstore

    Hi, any one knows how to fix my problem? my iphone 4 is connected to my wifi home network. When I use the appstore it says "cannot connect to itunes store". when I use safari "safari cannot open page because it is not connected to the internet". HELP

  • ITunes will not sync music to new iPhone.

    I used to have an iPhone 5S 16GB, and I just got an iPhone 5S 32GB. I went to backup my new phone from iTunes, and it worked fine. Yesterday, I put a new CD on my iTunes and thought I had downloaded it onto my iPhone. I went to listen to the new CD t

  • Help with Airprint on HP Envy 111 / D411d

    Frustrated: Bought the Envy yesterday Hooked it up, got it working... was able to print documents from iPad 2 / 3G (AT&T) There is no network in this building There is no DSL, and there is no wireless router. Today I printed a couple more docs. Then

  • Tape Drive and Library Compatibility Matrix - Oracle Secure Backup Express

    Does Oracle Secure Backup Express support IBM System Storage TS3200 Tape Library with two Tape Drives? Regards Rado