Wednesday, 6 November 2019

Submit a Concurrent Program/Request from PL/SQL

Oracle has provided the feasibility to submit a concurrent request from backend using "fnd_request.submit_request" API.

Before submitting the API we need to set the environment and this can be done using "fnd_global.apps_initialize"

Here is a sample code to submit a concurrent program from PL/SQL

Note:- This code is to submit a Concurrent Program, not the Request Set. To Submit the Request Set from the backend, We have a different API.

/*********************************************************
*PURPOSE: To Submit a Concurrent Request from backend    *
*AUTHOR: Ragul Halan                                     *
**********************************************************/
--
DECLARE
   l_responsibility_id     NUMBER;
   l_resp_application_id   NUMBER;
   l_security_group_id     NUMBER;
   l_user_id               NUMBER;
   l_request_id            NUMBER;
BEGIN
   --
   -- Get the apps environment variables --
   --
   SELECT user_id, responsibility_id, responsibility_application_id,
          security_group_id
     INTO l_user_id, l_responsibility_id, l_resp_application_id,
          l_security_group_id
     FROM fnd_user_resp_groups
    WHERE user_id = (SELECT user_id
                       FROM fnd_user
                      WHERE user_name = '&USER_NAME')
      AND responsibility_id =
             (SELECT responsibility_id
                FROM fnd_responsibility_vl
               WHERE responsibility_name = '&RESP_NAME');


   --
   --To set environment context.
   --
   apps.fnd_global.apps_initialize (l_user_id,
                                    l_responsibility_id,
                                    l_resp_application_id
                                   );
   --
   --Submitting Concurrent Request
   --
   l_request_id :=
      fnd_request.submit_request (application      => 'XXCUST',         -- Application Short Name
                                  program          => 'XX_DEPT_DTLS',   -- Program Short Name
                                  description      => 'XX_DESCRIPTION', -- Any Meaningful Description
                                  start_time       => SYSDATE,          -- Start Time
                                  sub_request      => FALSE,            -- Subrequest Default False
                                  argument1        => 'Accounting'      -- Parameters Starting
                                 );
   --
   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: '||l_request_id);
   END IF;
   --
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (   'Error While Submitting Concurrent Request '
                            || TO_CHAR (SQLCODE)
                            || '-'
                            || SQLERRM
                           );
END;
/
For any suggestion or issues with the above code, please leave your comments. I will try to reply back as soon as possible.

Tuesday, 5 November 2019

Retrieving Script Engines in Java

A script engine registers alias names with the scripting framework.
For example, the built-in Rhino scripting registers the following names with the scripting framework:
  1. js
  2. rhino
  3. JavaScript
  4. javascript
  5. ECMAScript
  6. ecmascript
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class GetEngineByName {
  public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    /* Retrieve a ScriptEngine registered with the rhino name */
    ScriptEngine jsEngine = manager.getEngineByName("rhino");
    if (!(jsEngine == null)) {
      System.out.println(jsEngine);
    } else {
      System.out.println("\nNo supported script engine foundregistered as Rhino.");
    }
  }
}






Run JavaScript Method in Java / ADF & OAF

Run JavaScript Method in Java / ADF & OAF   

** it is not Oracle standard.
Example Code :
 try {
      ScriptEngineManager manager = new ScriptEngineManager();
      ScriptEngine engine = manager.getEngineByName("Js");
        engine.eval("function run() {alert(123);}");
        Invocable invokeEngine = (Invocable) engine;
        Runnable runner = (Runnable)invokeEngine.getInterface(Runnable.class);
        Thread t = new Thread(runner);
        t.start();
        t.join();
      }
    catch (ScriptException e)
    {
      // TODO
    }
    catch (InterruptedException e)
    {
      // TODO
    }


incase of any null pointer Exception
visit Get JavaScript Engine Name

Java Code Examples for javax.script.ScriptEngineManager.getEngineFactories()

The following are Jave code examples for showing how to use getEngineFactories() of the javax.script.ScriptEngineManager class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.



private boolean isJavaScriptAvailable() {
    if(isJSAvailableChecked) {
        return isJSAvailable;
    }
    ScriptEngineManager mgr = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = mgr.getEngineFactories();
    for (ScriptEngineFactory factory: factories) {
        List<String> engNames = factory.getNames();
        for(String name: engNames) {
            if(name.equalsIgnoreCase("js") || name.equalsIgnoreCase("javascript")) { //NOI18N
                isJSAvailableChecked = true;
                isJSAvailable = true;
                return isJSAvailable;
            }
        }
    }
    isJSAvailableChecked = true;
    isJSAvailable = false;
    return isJSAvailable;
}



OAF:
Example
try { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngineFactory[] factories = (ScriptEngineFactory[]) mgr.getEngineFactories(); for (ScriptEngineFactory factory: factories) { String[] engNames = factory.getNames(); for(String name: engNames) { System.out.println(name); } } } catch (Exception e) { }





OADBTransactionImpl in Oracle Application Framework (OAF)

OADBTransactionImpl is a class in Oracle Application Framework (OAF), which is a framework for building Oracle E-Business Suite applications...