Wednesday, October 31, 2018

Run / start workflow from Workflow Administrator Responsibility

Run / start workflow from Workflow Administrator Responsibility

First of all why do we need to run a workflow from workflow administrator responsibility?
Second, Who will run it?
Third, When can we run it?
Fourth, How can we run it?
Finally, Is it recommended approach?
1) Normally we don’t run or kickoff workflow’s from workflow administrator responsibility. All seeded workflow’s are tied to some kind of transactions and they are kicked-off automatically when you create the transaction, for example PO workflow will be executed when we create a new PO.
We use workflow administrator responsibility to run a workflow only during development phase of a custom workflow or to debug a custom / standard workflow.
2) You need to be a “Workflow System Administrator”.
No, It is not just enough if you have “Workflow Administrator..” responsibility assigned to your user. You also need to be workflow system administrator.
A single user can be made as workflow system administrator or a Role can be assigned (Group of users).
Navigation: Login to Workflow Administrator Responsibility > Administer Workflow > “Administration” tab
Run oracle workflow from workflow administrator
3) Anytime you wish to test a workflow, Debug workflow or for some reason you want to start workflow manually.
4) Navigation: Workflow Administrator Responsibility > Administer Workflow > “Developer Studio”
Select your workflow Item Type > Go > Run
Run oracle workflow from workflow administrator
Provide Item Key, User Key, Select Process if you have multiple process in workflow item type
Run oracle workflow from workflow administrator
Submit.
Oracle workflow run confirmation
5) This approach should be used only for testing / debugging workflow’s but not as a usual approach to run workflow on regular basis.
You can check the status of the workflow by navigating to “Status Monitor” tab.

Workflow migration: WFLOAD | Workflow Definitions Loader

Workflow migration: WFLOAD | Workflow Definitions Loader

Oracle workflow objects can be saved into database or into a file. So We can treat Oracle workflow objects as both file system objects and database objects. We save workflow object into file when working on local system either for development / enhancement or debugging. When you execute the workflow from server it will always look at the database object.
Notes:
1. Workflow objects need to be deployed into database for execution. 
2. Workflow engine will not refer to any .wft files during execution.
We have three approaches to download, upload, upgrade workflow objects.
1) WFLOAD Utility from UNIX command prompt, This approach is usually preferred by DBA’s.
2) Workflow Builder client tool, Preferred by Technical Developers
3) Use “Workflow Definitions Loader” concurrent program. Not many people are aware of this approach and used very less.
The above mentioned approaches can be used to migrate workflow object from one instance to other instance. ex: From Development (DEV) instance to Quality testing instance (QA)
WFLOAD:
Download a workflow definition from Database into a file:
1
WFLOAD apps/pwd 0 Y DOWNLOAD file_name.wft ITEM_TYPE_NAME
Download multiple workflow definition’s from Database into one file:
1
WFLOAD apps/pwd 0 Y DOWNLOAD file_name.wft ITEM_TYPE_NAME1 ITEM_TYPE_NAME2
ITEM_TYPE_NAME3
Download all workflow definitions from Database into one file:
1
WFLOAD apps/pwd 0 Y DOWNLOAD file_name.wft '*'
Upload a workflow definition from file into Database:
1
WFLOAD apps/pwd 0 Y UPLOAD file_name.wft
Upload a workflow definition in database from file (File has the latest changes):
1
WFLOAD apps/pwd 0 Y UPGRADE file_name.wft
Force a workflow definition from file into Database ignoring the protection level:
1
WFLOAD apps/pwd 0 Y FORCE file_name.wft

Workflow Builder Client Tool:
To save a workflow into database from file which is on your local machine you need to open the workflow (.wft) in your workflow builder client tool.
1. Open .wft file in workflow builder client tool using File > Open
2. Choose File option and select your file from local machine
3. Go to File > “Save as”
4. Choose Database option now and provide your database login credentials
5. Save
workflow save from file to database

To open a workflow object from database and save it as a file (.wft) on your local machine
1. Open workflow builder client tool and go to File > Open
2. Choose Database and provide login credentials
3. Select the workflow on the right side panel and use arrows button to move it left side
4. Click Ok to open
5. Go to File > “Save as” and now choose File Option and save it.
workflow save from database to file

Workflow Definitions Loader Concurrent Program:
Make sure the mentioned concurrent program is added to the corresponding request group of the responsibility from which you wish to run.
Workflow Definitions submit
Submit the concurrent program with your preferred options.
Workflow Definitions submit

Launch Workflow from PL/SQL

Launch Workflow from PL/SQL

The below script will lanch or kickoff the desired workflow from PL/SQL code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
declare
   v_itemtype   VARCHAR2(50);
   v_itemkey    VARCHAR2(50);
   v_process    VARCHAR2(50);
   v_userkey    VARCHAR2(50);
begin
 
v_itemtype := 'DEMOIT';
v_itemkey := '1233';
v_userkey := '1233';
v_process := 'DEMOPROCESS';
WF_ENGINE.Threshold := -1;
WF_ENGINE.CREATEPROCESS(v_itemtype, v_itemkey, v_process);
wf_engine.setitemuserkey(v_itemtype, v_itemkey, v_userkey );
wf_engine.setitemowner (v_itemtype, v_itemkey,'SYSADMIN');
WF_ENGINE.STARTPROCESS(v_itemtype, v_itemkey);
commit;
exception when others
then
  dbms_output.put_line(SQLERRM);
end;  

UTL_FILE Write Example

UTL_FILE Write Example

The below example illustrates how to write a line to a file using UTL_FILE.
1. Create Directory on your server (ex: Linux, Unix)
2. Give writable permissions to the directory created. If you register this code as a concurrent program then you need to make sure your applmgr user has write permissions to this directory.
3. Create DIRECTORY object in database using below command. This is different from the physical directory you created in step1.
1
CREATE OR REPLACE DIRECTORY ERPS_OUT_DIR AS '/home/haritha'
You can see the existing directory objects using below query
1
select * from dba_directories;
UTL_FILE Write Example:
1
2
3
4
5
DECLARE
l_file_handler UTL_FILE.FILE_TYPE;
l_txt VARCHAR2(1000) := 'Demo to write to a file using UTL_FILE';
l_file_name VARCHAR2(50) := 'ERPSFILE.txt';
BEGIN
–Open the file in Write mode
l_file_handler := UTL_FILE.FOPEN(‘ERPS_OUT_DIR’,l_file_name,’W’);
–Write to the file
UTL_FILE.Put_LINE(l_file_handler,l_txt);
–Once the writing is done, close the file
IF UTL_FILE.IS_OPEN(l_file_handler) THEN
UTL_FILE.FCLOSE(l_file_handler);
END IF;
EXCEPTION
WHEN UTL_FILE.invalid_mode THEN
raise_application_error (-20051, ‘Invalid Mode Parameter’);
WHEN UTL_FILE.invalid_path THEN
raise_application_error (-20052, ‘Invalid File Location’);
WHEN UTL_FILE.invalid_filehandle THEN
raise_application_error (-20053, ‘Invalid Filehandle’);
WHEN UTL_FILE.invalid_operation THEN
raise_application_error (-20054, ‘Invalid Operation’);
WHEN UTL_FILE.write_error THEN
raise_application_error (-20055, ‘Write Error’);
WHEN UTL_FILE.internal_error THEN
raise_application_error (-20057, ‘Internal Error’);
WHEN UTL_FILE.charsetmismatch THEN
raise_application_error (-20058, ‘Opened With FOPEN_NCHAR But Later I/O Inconsistent’);
WHEN UTL_FILE.file_open THEN
raise_application_error (-20059, ‘File Already Opened’);
WHEN UTL_FILE.invalid_maxlinesize THEN
raise_application_error (-20060, ‘Line Size Exceeds 32K’);
WHEN UTL_FILE.invalid_filename THEN
raise_application_error (-20061, ‘Invalid File Name’);
WHEN UTL_FILE.access_denied THEN
raise_application_error (-20062, ‘File Access Denied By’);
WHEN UTL_FILE.invalid_offset THEN
raise_application_error (-20063, ‘FSEEK Param Less Than 0’);
WHEN OTHERS THEN
raise_application_error (-20099, ‘Unknown UTL_FILE Error’||sqlerrm);
END;

List Concurrent Programs using a specific valueset in its parameter list

List Concurrent Programs using a specific valueset in its parameter list

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SELECT fcp.user_concurrent_program_name,
fat.application_name,
fdfc.column_seq_num Seq,
fdfc.form_left_prompt "Parameter Name",
fdfc.enabled_flag Active
FROM FND_DESCR_FLEX_COL_USAGE_VL fdfc ,
fnd_flex_value_sets ffvs ,
fnd_concurrent_programs_vl fcp ,
fnd_application_tl fat
WHERE 1 =1
AND ffvs.flex_value_set_id = fdfc.flex_value_set_id
and fdfc.descriptive_flexfield_name = '$SRS$.'||fcp.concurrent_program_name
and fcp.application_id = fat.application_id
and ffvs.flex_value_set_name = :p_valuesetname -- Enter value set name
--and fcp.user_concurrent_program_name = :p_conc_program_name -- use this
condition to find out for a specific conc program
;

SQL Important Queries

  How to delete rows with no where clause The following example deletes  all rows  from the  Person.Person  the table in the AdventureWork...