Category: Scripts

  • Oracle Apps Custom Table with ORG Access Control policy

    Oracle RLS Policy to enable Multi org security for custom objects / tables

  • XLA: Delete event XLA_EVENTS

    — Creted by Prudhvi </code> DECLARE p_event_source_info xla_events_pub_pkg.t_event_source_info; BEGIN p_event_source_info.source_application_id := NULL; –101 GL — 602 XLE p_event_source_info.application_id := 222; — AR p_event_source_info.legal_entity_id := 1234; p_event_source_info.ledger_id := 1; p_event_source_info.entity_type_code := ‘TRANSACTIONS’; p_event_source_info.transaction_number := NULL; p_event_source_info.source_id_int_1 := 1234; — Customer Transaction ID; p_event_source_info.source_id_int_2 := NULL; p_event_source_info.source_id_int_3 := NULL; p_event_source_info.source_id_int_4 := NULL; p_event_source_info.source_id_char_1 := NULL; p_event_source_info.source_id_char_2 :=…

  • API: Update event status code in XLA_EVENTS

    — Created by Prudhvi DECLARE p_event_source_info xla_events_pub_pkg.t_event_source_info; BEGIN p_event_source_info.source_application_id := NULL; p_event_source_info.application_id := 222; — AR p_event_source_info.legal_entity_id := 12340; — change it p_event_source_info.ledger_id := 1; — change it p_event_source_info.entity_type_code := ‘TRANSACTIONS’; p_event_source_info.transaction_number := ‘1234’; — change it p_event_source_info.source_id_int_1 := 1234; –Transaction ID; p_event_source_info.source_id_int_2 := NULL; p_event_source_info.source_id_int_3 := NULL; p_event_source_info.source_id_int_4 := NULL; p_event_source_info.source_id_char_1 := NULL; p_event_source_info.source_id_char_2…

  • Respond to workflow notification from a DB procedure

    The  below script can be used to auto approve notifications through database procedure. Write your business logic with in the below procedure ,register it as a concurrent program and schedule it as needed to run periodically. The same script can also be used in custom forms, custom or third party applications to respond to notifications…

  • GL Account Balance

    GL Account Balance: The below SQL gets the beginning balance and ending balance of the specified GL Account for a giver ledger and period. SELECT gcc.concatenated_segments Code_combination, SUM(NVL(gb.begin_balance_dr,0)-NVL(gb.begin_balance_cr,0)) beginning_bal, SUM(NVL(gb.begin_balance_dr,0)-NVL(gb.begin_balance_cr,0) + (NVL(gb.period_net_Dr,0) – NVL(gb.period_net_cr,0))) end_bal FROM gl_balances gb, gl_code_combinations_kfv gcc WHERE gb.code_combination_id = gcc.code_combination_id AND gcc.CONCATENATED_SEGMENTS = ’01-000-1110-0000-000′ — Enter GL Account AND gb.ledger_id =…

  • Get Version number for Oracle apps, Database, Workflow, XML, OS

    — Oracle Database version along with hostname and instance name SELECT instance_name, host_name, version, status, database_status FROM v$instance; — Database version along with operating system platform SELECT name, DB_UNIQUE_NAME, platform_name FROM v$database; — Oracle Apps version SELECT release_name, applications_system_name, aru_release_name FROM FND_PRODUCT_GROUPS; — Database Version, PLSQL Version, TNS Version SELECT * FROM v$version; — Oracle…

  • 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…

  • 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…

  • 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.…

  • Trace details for a concurrent request along with the log and output file location details

    Script to get Trace details for a concurrent request along with the log file and output file location details SELECT ‘Request id: ‘ || request_id, ‘Trace id: ‘ || oracle_process_id, ‘Trace Flag: ‘ || req.enable_trace, ‘Trace Name: ‘ || dest.VALUE || ‘/’ || LOWER (dbnm.VALUE) || ‘_ora_’ || oracle_process_id || ‘.trc’, ‘Prog. Name: ‘ ||…

  • Concurrent Program session details along with SQL Query

    Concurrent Program session details along with SQL Query SELECT sqlt.sql_text, sess.sid, sess.serial#, fcr.requested_start_date FROM fnd_concurrent_requests fcr , V$SQLTEXT sqlt , v$session sess WHERE fcr.request_id = :pRequestID AND fcr.phase_code = ‘R’ AND fcr.status_code = ‘R’ AND fcr.oracle_session_id = sess.audsid (+) AND sqlt.address = sess.sql_address ORDER BY sqlt.piece;

  • List Concurrent Programs using a specific valueset in its parameter list

    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…

  • List of users having access to specific responsibility

    Get the list of users who have access to a specific given responsibility SELECT fu.user_name, frt.responsibility_name, TO_CHAR(furg.start_date,’DD-MON-YYYY’) start_date, furg.end_date FROM fnd_user fu , fnd_user_resp_groups_direct furg , fnd_responsibility_vl frt WHERE fu.user_id = furg.user_id AND frt.responsibility_id = furg.responsibility_id AND frt.application_id = furg.responsibility_application_id AND NVL(furg.end_date,sysdate+1) > sysdate AND NVL(frt.end_date,sysdate +1) > sysdate AND NVL(fu.end_date,sysdate +1) > sysdate AND…

  • Get List of responsibilities assigned to a user

    Get List of responsibilities assigned to a user select fu.user_name, frt.responsibility_name, furg.start_date, furg.end_date from fnd_user fu , fnd_user_resp_groups_direct furg , fnd_responsibility_vl frt where fu.user_id = furg.user_id and frt.responsibility_id = furg.responsibility_id and frt.application_id = furg.responsibility_application_id and nvl(furg.end_date,sysdate+1) > sysdate and nvl(frt.end_date,sysdate +1) > sysdate and fu.user_name = :p_user_name –and fu.user_name = :p_userid; ;

  • Concurrent requests / programs executed by a specific user

    Get details of concurrent requests / programs that are executed by a specific user from a specific responsibility between certain dates. SELECT fcp.user_concurrent_program_name, fcr.request_id, fcr.request_date, fu.user_name Requested_By , fr.responsibility_name FROM fnd_concurrent_requests fcr , fnd_concurrent_programs_tl fcp , fnd_user fu , fnd_responsibility_tl fr WHERE 1 =1 AND fcr.concurrent_program_id = fcp.concurrent_program_id AND fcr.requested_by = fu.user_id AND fcr.responsibility_id =…

  • Currently running concurrent program details along with user and responsibility

    Get details of concurrent requests which are running currently and also the script will provide details of who is running the request and from which responsibility SELECT fcp.user_concurrent_program_name, fcr.request_id, fcr.request_date, fu.user_name Requested_By , fr.responsibility_name, TO_CHAR(fcr.actual_start_date,’DD-MON-YYYY HH24:MI:SS’) actual_start_date FROM fnd_concurrent_requests fcr , fnd_concurrent_programs_tl fcp , fnd_user fu , fnd_responsibility_tl fr WHERE 1 =1 AND fcr.phase_code =’R’…

  • Concurrent Program Details: Name, Short name, Executable, Execution method, Trace

    Script to fetch the following details 1. Concurrent Program Name 2. Concurrent Program Short Name 3. Concurrent Program Application Name 4. Executable Name 5. Executable Short Name 6. Executable Application Name 7. Execution Method 8. Execution file Name 9. Enable Trace flag SELECT fcpt.user_concurrent_program_name , fcp.concurrent_program_name short_name , fat.application_name program_application_name , fet.executable_name , fat1.application_name executable_application_name…

  • Internal Requsition and Internal Sales Order Link

    Use this query / script to find the link between a internal requisition and internal sales order. Please note that a internal sales order which is created from internal requisition may not always have sales order type as “INTERNAL” or “INTERCOMPANY”. Sales order type can also me “MIXED” or any other custom type so do…

  • Invoice List for a Customer query

    Query to retrieve Invoice List for a specific Customer SELECT hp.party_name customer ,hca.account_number ,rcta.trx_date ,rcta.trx_number Invoice_number ,rcta.status_trx ,rcta.invoice_currency_code Invoice_currency ,rctla.line_number ,msi.segment1 Item_number ,rctla.description ,rctla.extended_amount line_amt ,rcta.org_id ,rctt.cust_trx_type_id FROM RA_CUSTOMER_TRX_ALL RCTA, RA_CUSTOMER_TRX_LINES_ALL RCTLA, RA_CUST_TRX_TYPES_ALL rctt, HZ_CUST_ACCOUNTS_ALL HCA, HZ_PARTIES HP, MTL_SYSTEM_ITEMS_B msi WHERE rcta.customer_trx_id = rctla.customer_trx_id AND msi.inventory_item_id = rctla.inventory_item_id AND msi.organization_id = 116 AND rcta.cust_trx_type_id =…

  • Order to Cash query

    Order to Cash query / script SELECT hp.party_name customer ,hca.account_number ,hp.party_number ,ooh.order_number ,ooh.flow_status_code Order_status ,rcta.trx_date Invoice_date ,rcta.trx_number Invoice_number ,rcta.status_trx Invoice_Status ,rcta.invoice_currency_code Invoice_currency ,rctla.line_number ,msi.segment1 Item_number ,rctla.description ,rctla.extended_amount line_amt ,arp.amount_due_original ,arp.amount_due_remaining ,rcta.org_id ,rcta.customer_trx_id FROM RA_CUSTOMER_TRX_ALL RCTA, RA_CUSTOMER_TRX_LINES_ALL RCTLA, RA_CUST_TRX_TYPES_ALL rctt, AR_PAYMENT_SCHEDULES_ALL arp, HZ_CUST_ACCOUNTS_ALL HCA, HZ_PARTIES HP, MTL_SYSTEM_ITEMS_B msi, OE_ORDER_LINES_ALL ool, OE_ORDER_HEADERS_ALL ooh WHERE rcta.customer_trx_id = rctla.customer_trx_id…

  • Launch Workflow from PL/SQL

    The below script will lanch or kickoff the desired workflow from PL/SQL code: 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…

  • OAF Personlization related Script

    The below script will list all the OAF Personlizations in Oracle Applications: SELECT PATH.PATH_DOCID PERZ_DOC_ID, jdr_mds_internal.getdocumentname(PATH.PATH_DOCID) PERZ_DOC_PATH FROM JDR_PATHS PATH WHERE PATH.PATH_DOCID IN (SELECT DISTINCT COMP_DOCID FROM JDR_COMPONENTS WHERE COMP_SEQ = 0 AND COMP_ELEMENT = ‘customization’ AND COMP_ID IS NULL) ORDER BY PERZ_DOC_PATH;

  • Forms Personalization query

    The below Forms Personalization query will list all the forms in Oracle Applications that have been customized using Forms Personlization: select distinct ffcr.form_name , ffcr.enabled, fft.USER_FORM_NAME, fat.APPLICATION_NAME , ffcr.description, ffcr.id RULE_ID from FND_FORM_CUSTOM_RULES ffcr, FND_FORM ff, FND_FORM_TL fft, fnd_application_tl fat where enabled = ‘Y’ and ffcr.form_name = ff.form_name and ff.form_id = fft.form_id and ff.application_id =…

  • Concurrent Requests and Programs Related Scripts

    This page will include the scripts 1. Find the responsibility name from which a concurrent program can be run 2. Find the responsibility name from which user has ran the concurrent program Find the Responsibility name from which a concurrent program can be run select distinct a.application_id, a.concurrent_program_id, a.user_concurrent_program_name, a.description, b.request_group_id, request_group_name, e.responsibility_name from fnd_concurrent_programs_tl…

  • Menu and Functions Related Scripts

    This script will accept the menu name as parameter and will list all functions that can be accessed under that menu. SELECT DISTINCT fmep.menu_id, DECODE(fmep.function_id,NULL, DECODE(fmec.function_id, NULL, DECODE(fmec1.function_id,NULL,’No Func’,fmec1.function_id ),fmec.function_id), fmep.function_id) funcID, fff.user_function_name, fff.description FROM fnd_form_functions_tl fff, fnd_menu_entries fmec1, fnd_menu_entries fmec, fnd_menu_entries fmep WHERE fmep.menu_id = (SELECT menu_id FROM fnd_menus WHERE menu_name=’INV_NAVIGATE’Â –Change the menu…

  • Send e mail through PL SQL code (UTL_SMTP, UTL_MAIL)

    utl_smtp example: CREATE OR REPLACE PROCEDURE erpschools_send_email IS mailhost varchar2 (30) := ‘smtp.erpschools.com’; crlf varchar2(2)Â := CHR (13) || CHR (10); v_email varchar2(16000); message_1 LONG; mail_conn utl_smtp.connection; BEGIN mail_conn := utl_smtp.open_connection (mailhost, 25); utl_smtp.helo (mail_conn, mailhost); utl_smtp.mail (mail_conn, ‘[email protected]’); utl_smtp.rcpt (mail_conn, ‘[email protected]’); message_1 := ‘From: Mr Sender < [email protected] >‘ || crlf || ‘Subject: Testing…

  • UTL_FILE Read Example

    This script can be used to read data from a flat file and insert into a table. UTL_FILE Read CREATE OR REPLACE PROCEDURE load_data(errbuff varchar2,errcode number) AS v_line VARCHAR2(2000); — Data line read from input file v_file UTL_FILE.FILE_TYPE; — Data file handle v_dir VARCHAR2(250); — Directory containing the data file v_filename VARCHAR2(50); — Data filename…

  • Get On Hand Quantities through API

    This script can be used to get the below quantities. 1. On-hand Quantity 2. Available to Reserve 3. Quantity Reserved 4. Quantity Suggested 5. Available to Transact 6. Available to Reserve You can also get the On-hand quantities from the table mtl_onhand_quantities GET ON-HAND QUANTITIES API DECLARE x_return_status VARCHAR2 (50); x_msg_count VARCHAR2 (50); x_msg_data VARCHAR2…

  • Concurrent Program Registration Scripts

    The scripts in this article can be used to: 1) Register the executable and Program 2) Attach Concurrent program to a Request Group 3) Submit Concurrent program 1) Registering the Executable from back end Usually we create executable in the front-end, but this can be done from the database tier i.e. back-end too. Below is…

  • Procure to Pay Cycle Query

    Includes two scripts to fetch all the transactions information related with in a procure to pay cycle. Two scripts are provided to use one with receipts and other when receipts are not created. Few important fields that were included in the script are Requisition Number, Purchase Order Number, Invoice Number, Customer Number, Invoice Amount, GL…

  • Revenue Adjustment Script

    This script can be used to adjust the Revenue for a particular transaction. The amount can be adjusted from one transaction line to another line by specifying the actual amount to adjust or percentage. Run this procedure in loop to adjust many transactions. CREATE OR REPLACE PROCEDURE adjustment_api IS p_revenue_adj_rec ar_revenue_adjustment_pvt.rev_adj_rec_type; x_return_status VARCHAR2 (2000); x_msg_count…

  • Add Older revision numbers to an item

    The below script can be used to add Older revision numbers to an item. Why we need to use this script: In Oracle standard functionality revisions need to be added in sequence like A, B, C….. It doesn’t allow us to add B after adding A and C. In that case this script can be…

  • Order Header Details Script

    This script can be used to extract order header details from backend. SELECT ra.customer_number, hl.address1, hl.address2, hl.city, hl.state, hl.postal_code, hl.country, hl.province, hl.county FROM oe_order_headers_all ooh, hz_cust_site_uses_all hcsu, hz_cust_acct_sites_all hcas, hz_party_sites hps, hz_locations hl, ra_customers ra WHERE 1 = 1 AND ooh.invoice_to_org_id = hcsu.site_use_id AND hcsu.cust_acct_site_id = hcas.cust_acct_site_id AND hcas.party_site_id = hps.party_site_id AND hps.location_id = hl.location_id…

  • Scripts to get the statistics based on order type

    Scripts to get the statistics based on order type: — Number of orders taken in each order type per month select b.name,b.description,to_char(ordered_date,’Mon’) Month, count(0) NoOfOrders from oe_order_headers_all a, oe_transaction_types_tl b where 1=1 and a.order_type_id = b.transaction_type_id and ordered_Date between ’01-SEP-2009′ and ’01-OCT-2009′ and org_id = 1 group by b.name, b.description,to_char(ordered_date,’Mon’) order by to_char(ordered_date,’Mon’) –Number of…

  • Script to get responsibilities for a user

    This script will display all the responsibilities for a given Username. SELECT fu.user_name, frt.responsibility_name, furgd.start_date, furgd.end_date FROM fnd_user fu, fnd_user_resp_groups_direct furgd, fnd_responsibility_tl frt WHERE fu.user_id = furgd.user_id AND furgd.responsibility_id = frt.responsibility_id AND UPPER (fu.user_name) = UPPER (‘ERPSCHOOLS’)

  • List of Approvers for a Purchase Order in Position Hierarchy

    This script gets all the approvers and their details like approver name, position, approval group, amount limit, approval hierarchy path for a given position hierarchy. Inputs for this script are: business_group_id for the desired POSITION HIERARCHY pos_structure_version_id for the desired POSITION HIERARCHY Top position in the desired POSITION HIERARCHY SCRIPT TO GET POSITION_STRUCTURE_ID AND BUSINESS_GROUP_ID…

  • Script to End Date Responsibility for a User

    This script below will get the list of all inactive users and end date all the responsibilities assigned to them. Declare –cursor to get all inactive users CURSOR cur_inactive_user IS select fu.user_id, fd.responsibility_id, fd.responsibility_application_id, fd.security_group_id, fd.start_date, fd.end_date from fnd_user fu, fnd_user_resp_groups_direct fd where fu.user_id = fd.user_id and (fu.end_date <= sysdate or fu.end_date is NOT NULL)…

  • Get SQL for a concurrent request id

    1. Use this Script to get current sql statement that is running in the background for a given concurrent request. 2. Get all the sql statements that are being executed by a user. 3. Get all the blocking sessions — GET THE CURRENT SQL STATEMENT RUNNING FOR A CONCURRENT REQUEST SELECT A.REQUEST_ID, D.SID, D.SERIAL#, D.OSUSER,…