How to Schedule a concurrent program from Backend

We can use the same fnd_request.submit_request API which we use to submit a program for scheduling a program too. The only difference is the value passed to the parameter “start_time“.

Usually while submitting a concurrent program form backend we pass ‘sysdate’ as value to the parameter “start_time” but to schedule a program we just need to pass a future date and time to this parameter.

For example:- If you would like to schedule a program to run after 30 minutes from now, you need to pass “to_char(sysdate + 30/1440,’DD-MON-YYYY HH24:MI:SS’)” as a value to parameter “start_time“.

Note: 1440 is the number of minutes in a day.

Below is the example to schedule a concurrent program to run after 30 minutes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*********************************************************
*PURPOSE: To Submit a Concurrent Request from backend    *
*AUTHOR: Shailender Thallam                              *
**********************************************************/
--
DECLARE
l_responsibility_id 	NUMBER;
l_application_id    	NUMBER;
l_user_id           	NUMBER;
l_request_id            NUMBER;
BEGIN
  --
  SELECT DISTINCT fr.responsibility_id,
    frx.application_id
     INTO l_responsibility_id,
    l_application_id
     FROM apps.fnd_responsibility frx,
    apps.fnd_responsibility_tl fr
    WHERE fr.responsibility_id = frx.responsibility_id
  AND LOWER (fr.responsibility_name) LIKE LOWER('XXTest Resp');
  --
   SELECT user_id INTO l_user_id FROM fnd_user WHERE user_name = 'STHALLAM';
  --
  --To set environment context.
  --
  apps.fnd_global.apps_initialize (l_user_id,l_responsibility_id,l_application_id);
  --
  --Submitting Concurrent Request
  --
  l_request_id := fnd_request.submit_request ( 
                            application   => 'XXCUST', 
                            program       => 'XXEMP', 
                            description   => 'XXTest Employee Details', 
                            start_time    => to_char(sysdate + 30/1440,'DD-MON-YYYY HH24:MI:SS'), 
                            sub_request   => FALSE,
			    argument1     => 'Smith'
  );
  --
  COMMIT;
  --
  IF l_request_id = 0
  THEN
     dbms_output.put_line ('Concurrent request failed to submit');
  ELSE
     dbms_output.put_line('Successfully Submitted the Concurrent Request');
  END IF;
  --
EXCEPTION
WHEN OTHERS THEN
  dbms_output.put_line('Error While Submitting Concurrent Request '||TO_CHAR(SQLCODE)||'-'||sqlerrm);
END;
/