Monday, 19 October 2026

Oracle EBS - Advanced Pricing - Modifier details Queries

0 comments

 

-- =====================================================================

-- Advanced Pricing - Modifier details

-- Bind: :p_modifier_name  (e.g. 'TEST-MFR-01')

-- =====================================================================


-- ---------------------------------------------------------------------

-- Query 1: Modifiers Summary + Discounts/Charges + Pricing Attributes

--          + Line Qualifiers (aggregated, so no row duplication)

--          One row per modifier line / product / pricing attribute

-- ---------------------------------------------------------------------

SELECT qlh.name                              modifier_list_name,

       qlh.list_type_code                    list_type,            -- DLT = Discount List

       qlh.active_flag                       list_active,

       qlh.automatic_flag                    list_automatic,

       qlh.start_date_active                 list_start_date,

       qlh.end_date_active                   list_end_date,

       -- Modifiers Summary tab

       qll.list_line_no                      modifier_no,

       qll.modifier_level_code               modifier_level,       -- LINE / ORDER / LINEGROUP

       qll.list_line_type_code               modifier_type,        -- DIS / SUR / PBH / FREIGHT_CHARGE ...

       qll.start_date_active                 line_start_date,

       qll.end_date_active                   line_end_date,

       qll.automatic_flag                    line_automatic,

       qll.override_flag                     line_override,

       qll.pricing_phase_id,

       qll.product_precedence                precedence,

       qll.incompatibility_grp_code,

       qll.pricing_group_sequence            bucket,

       -- Discounts/Charges tab

       qll.arithmetic_operator               application_method,   -- % / AMT / NEWPRICE / LUMPSUM

       qll.operand                           value,

       qll.price_break_type_code,                                  -- POINT / RANGE (for PBH)

       qll.accrual_flag,

       qll.charge_type_code,

       qll.include_on_returns_flag,

       -- Product (Modifiers Summary - Product Attribute)

       qpa.product_attribute_context,

       qpa.product_attribute,                                      -- PRICING_ATTRIBUTE1 = Item

       qpa.product_attr_value,

       CASE WHEN qpa.product_attribute_context = 'ITEM'

             AND qpa.product_attribute = 'PRICING_ATTRIBUTE1'

            THEN msib.segment1 END           item_number,

       qpa.product_uom_code,

       qpa.excluder_flag,                                          -- Y = Exclude button

       -- Pricing Attributes button

       qpa.pricing_attribute_context,

       qpa.pricing_attribute,

       qpa.comparison_operator_code          pricing_attr_operator,

       qpa.pricing_attr_value_from,

       qpa.pricing_attr_value_to,

       -- Line Qualifiers button (aggregated)

       (SELECT LISTAGG(qq.qualifier_grouping_no || ':' ||

                       qq.qualifier_context || '.' || qq.qualifier_attribute || ' ' ||

                       qq.comparison_operator_code || ' ' ||

                       qq.qualifier_attr_value ||

                       NVL2(qq.qualifier_attr_value_to, '-' || qq.qualifier_attr_value_to, NULL),

                       ' | ') WITHIN GROUP (ORDER BY qq.qualifier_grouping_no, qq.qualifier_id)

        FROM   qp_qualifiers qq

        WHERE  qq.list_header_id = qll.list_header_id

        AND    qq.list_line_id   = qll.list_line_id)              line_qualifiers

FROM   qp_list_headers_vl     qlh,

       qp_list_lines          qll,

       qp_pricing_attributes  qpa,

       mtl_system_items_b     msib

WHERE  qlh.list_header_id      = qll.list_header_id

AND    qll.list_line_id        = qpa.list_line_id (+)

AND    msib.inventory_item_id (+) = DECODE(qpa.product_attribute,

                                           'PRICING_ATTRIBUTE1', qpa.product_attr_value)

AND    msib.organization_id   (+) = qp_util.get_item_validation_org

AND    qlh.name                = :p_modifier_name

ORDER  BY qll.list_line_no, qpa.excluder_flag, qpa.pricing_attribute_id;



-- ---------------------------------------------------------------------

-- Query 2: Line Qualifiers (detail - one row per qualifier)

-- ---------------------------------------------------------------------

SELECT qlh.name                       modifier_list_name,

       qll.list_line_no               modifier_no,

       qq.qualifier_grouping_no       grouping_no,

       qq.qualifier_context,

       qq.qualifier_attribute,

       qq.comparison_operator_code    operator,

       qq.qualifier_attr_value        value_from,

       qq.qualifier_attr_value_to     value_to,

       qq.qualifier_precedence        precedence,

       qq.start_date_active,

       qq.end_date_active

FROM   qp_list_headers_vl qlh,

       qp_list_lines      qll,

       qp_qualifiers      qq

WHERE  qlh.list_header_id = qll.list_header_id

AND    qq.list_header_id  = qll.list_header_id

AND    qq.list_line_id    = qll.list_line_id

AND    qlh.name           = :p_modifier_name

ORDER  BY qll.list_line_no, qq.qualifier_grouping_no;



-- ---------------------------------------------------------------------

-- Query 3: List (header) Qualifiers - "List Qualifiers" button

--          Header-level qualifiers are stored with list_line_id = -1

-- ---------------------------------------------------------------------

SELECT qlh.name                       modifier_list_name,

       qq.qualifier_grouping_no       grouping_no,

       qq.qualifier_context,

       qq.qualifier_attribute,

       qq.comparison_operator_code    operator,

       qq.qualifier_attr_value        value_from,

       qq.qualifier_attr_value_to     value_to,

       qq.start_date_active,

       qq.end_date_active

FROM   qp_list_headers_vl qlh,

       qp_qualifiers      qq

WHERE  qq.list_header_id  = qlh.list_header_id

AND    NVL(qq.list_line_id, -1) = -1

AND    qlh.name           = :p_modifier_name

ORDER  BY qq.qualifier_grouping_no;



-- ---------------------------------------------------------------------

-- Query 4: Price Breaks (only for modifier lines of type PBH)

-- ---------------------------------------------------------------------

SELECT qlh.name                       modifier_list_name,

       parent.list_line_no            pbh_modifier_no,

       parent.price_break_type_code,

       child.list_line_no             break_line_no,

       qpa.pricing_attribute          break_attribute,      -- e.g. PRICING_ATTRIBUTE10 = Item Quantity

       qpa.pricing_attr_value_from    break_from,

       qpa.pricing_attr_value_to      break_to,

       child.arithmetic_operator      application_method,

       child.operand                  value

FROM   qp_list_headers_vl    qlh,

       qp_list_lines         parent,

       qp_rltd_modifiers     rm,

       qp_list_lines         child,

       qp_pricing_attributes qpa

WHERE  qlh.list_header_id       = parent.list_header_id

AND    parent.list_line_type_code = 'PBH'

AND    rm.from_rltd_modifier_id = parent.list_line_id

AND    rm.rltd_modifier_grp_type = 'PRICE BREAK'

AND    child.list_line_id       = rm.to_rltd_modifier_id

AND    qpa.list_line_id         = child.list_line_id

AND    qlh.name                 = :p_modifier_name

ORDER  BY parent.list_line_no,

          TO_NUMBER(qpa.pricing_attr_value_from);


Tuesday, 14 July 2026

Oracle Apex - Script to Send the Table/Query Extract via email

1 comments

 Wrap the export/email logic into a procedure

CREATE OR REPLACE PROCEDURE xxsea_send_downtime_extract_email IS

    v_context   apex_exec.t_context;

    v_export    apex_data_export.t_export;

    v_mail_id   NUMBER;

BEGIN

    -- 1. Open a query context against your source table

    v_context := apex_exec.open_query_context (

                     p_location  => apex_exec.c_location_local_db,

                     p_sql_query => 'SELECT * FROM XXAL_DOWNTIME_FORM_HISTORY ORDER BY 1 DESC'

                 );


    -- 2. Export that context as CSV

    v_export := apex_data_export.export (

                    p_context   => v_context,

                    p_format    => apex_data_export.c_format_xlsx,

                    p_file_name => 'Downtime_Incident_Table_Extract'

                );


    apex_exec.close (v_context);


    -- 3. Send the email shell and capture the returned mail_id

    v_mail_id := apex_mail.send (

                     p_to   => 'aalam@abc.com',

                     p_from => 'apexadmin@abc.com',

                     p_body => 'Please find the attached downtime incident data extract.',

                     p_subj => 'Automated Downtime Incident Data Extract'

                 );


    -- 4. Attach the exported CSV using that mail_id

    apex_mail.add_attachment (

        p_mail_id    => v_mail_id,

        p_attachment => v_export.content_blob,

        p_filename   => v_export.file_name,

        p_mime_type  => v_export.mime_type

    );


    -- 5. Push the mail queue immediately (optional)

    apex_mail.push_queue;


EXCEPTION

    WHEN OTHERS THEN

        IF v_context IS NOT NULL THEN

            apex_exec.close(v_context);

        END IF;

        RAISE;

END xxsea_send_downtime_extract_email;

/


Important - set the APEX session context inside the job

APEX_DATA_EXPORT and APEX_MAIL need an APEX session/workspace context to resolve correctly. A DBMS_SCHEDULER job runs as a raw DB session with no APEX context by default, so you need to establish one inside the job action. Wrap the call like this:


CREATE OR REPLACE PROCEDURE xxsea_run_downtime_extract_job IS

    l_security_group_id NUMBER;

BEGIN

    -- point at the correct workspace before calling APEX APIs

    l_security_group_id := apex_util.find_security_group_id(p_workspace => 'SEAMAN');

    apex_util.set_security_group_id(p_security_group_id => l_security_group_id);


    -- APEX_EXEC / APEX_DATA_EXPORT require an actual session context, not just SG_ID

    apex_session.create_session (

        p_app_id   => 104,      -- any valid app ID in the SEAMAN workspace

        p_page_id  => 0,

        p_username => 'AALAM'         -- a valid APEX app/workspace user

    );

    xxsea_send_downtime_extract_email;

EXCEPTION WHEN OTHERS THEN 

           RAISE;

END xxsea_run_downtime_extract_job;

/


Create the scheduler job

BEGIN

    DBMS_SCHEDULER.CREATE_JOB (

        job_name        => 'JOB_DOWNTIME_EXTRACT_EMAIL',

        job_type        => 'PLSQL_BLOCK',

        job_action      => 'BEGIN xxsea_run_downtime_extract_job; END;',

        start_date      => SYSTIMESTAMP,

        repeat_interval => 'FREQ=DAILY; BYHOUR=7; BYMINUTE=0',  -- daily at 7:00 AM

        enabled         => TRUE,

        comments        => 'Sends daily downtime incident extract via email'

    );

END;

/


Verify the job is registered and check its run history

-- Confirm it's scheduled

SELECT job_name, enabled, state, next_run_date

FROM user_scheduler_jobs

WHERE job_name = 'JOB_DOWNTIME_EXTRACT_EMAIL';


-- Check whether it actually ran and if it errored

SELECT log_date, status, additional_info

FROM user_scheduler_job_run_details

WHERE job_name = 'JOB_DOWNTIME_EXTRACT_EMAIL'

ORDER BY log_date DESC;


Test it manually before waiting for the schedule

BEGIN

    DBMS_SCHEDULER.RUN_JOB('JOB_DOWNTIME_EXTRACT_EMAIL');

END;

/


To disable/drop it later

BEGIN

    DBMS_SCHEDULER.DISABLE('JOB_DOWNTIME_EXTRACT_EMAIL');

    -- or to remove entirely:

    -- DBMS_SCHEDULER.DROP_JOB('JOB_DOWNTIME_EXTRACT_EMAIL');

END;

/

Monday, 13 July 2026

Oracle APEX - Add a user to a group (without removing existing groups)

0 comments
CREATE OR REPLACE PROCEDURE add_user_to_apex_group (
    p_workspace_name IN VARCHAR2,   -- e.g. 'MY_WORKSPACE'
    p_user_name           IN VARCHAR2,   -- e.g. 'AALAM'
    p_group_name        IN VARCHAR2    -- e.g. 'MANAGERS'
) IS
    l_security_group_id   NUMBER;
    l_existing_groups      VARCHAR2(32767);
    l_group_table             apex_t_varchar2 := apex_t_varchar2();
BEGIN
    -- 1. Point APEX at the correct workspace (needed outside an APEX session)
    l_security_group_id := apex_util.find_security_group_id(p_workspace => p_workspace_name);
    apex_util.set_security_group_id(p_security_group_id => l_security_group_id);

    -- 2. Create the group if it doesn't already exist
    BEGIN
        IF apex_util.get_group_id(p_group_name => p_group_name) IS NULL THEN
            apex_util.create_user_group(p_group_name => p_group_name);
        END IF;
    EXCEPTION
        WHEN OTHERS THEN
            IF apex_util.get_group_id(p_group_name => p_group_name) IS NULL THEN
                apex_util.create_user_group(p_group_name => p_group_name);
            END IF;
    END;

    -- 3. Get the groups this user already belongs to (comma-space separated string)
    l_existing_groups := apex_util.get_groups_user_belongs_to(p_username => p_user_name);

    -- 4. Build the combined group list (existing + new), avoiding duplicates
    IF l_existing_groups IS NOT NULL THEN
        FOR i IN 1 .. REGEXP_COUNT(l_existing_groups, ',') + 1 LOOP
            l_group_table.EXTEND;
            l_group_table(l_group_table.COUNT) := TRIM(REGEXP_SUBSTR(l_existing_groups, '[^,]+', 1, i));
        END LOOP;
    END IF;

    -- only add the new group if it isn't already in the list
    IF NOT p_group_name MEMBER OF l_group_table THEN
        l_group_table.EXTEND;
        l_group_table(l_group_table.COUNT) := p_group_name;
    END IF;

    -- 5. Apply the full group list back to the user
    apex_util.set_group_user_grants (
        p_user_name           => p_user_name,
        p_granted_group_names => l_group_table
    );

    COMMIT;
END add_user_to_apex_group;
/

DECLARE
CURSOR C1 IS
select user_name from APEX_WORKSPACE_APEX_USERS;
BEGIN
FOR i IN C1
LOOP
    add_user_to_apex_group (
        p_workspace_name => 'SEAMAN',
        p_user_name      => i.user_name,
        p_group_name     => 'PLM'
    );
END LOOP;
END;
/

Monday, 18 May 2026

Wip Completion (intellinum/Telnet) Query to Fetch Work Order, Lot and LPN Numbers Details

0 comments

 SELECT

    we.wip_entity_name,

    wlc.organization_id,

    wlc.wip_entity_id,

    wlc.inventory_item_id,

    msik.concatenated_segments item,

    mmt.transaction_id,

    mmt.transaction_quantity,

    mmt.transaction_date,

    lpn.attribute4 lot_number,

    lpn.license_plate_number

FROM

    wip_lpn_completions       wlc,

    wip_entities              we,

    mtl_material_transactions mmt,

    mtl_transaction_lot_numbers lot,

    wms_license_plate_numbers lpn,

    mtl_system_items_kfv      msik

WHERE

        we.wip_entity_id = wlc.wip_entity_id

    AND we.organization_id = wlc.organization_id

    AND mmt.completion_transaction_id = wlc.completion_transaction_id

    AND lot.transaction_id = mmt.transaction_id

    AND lpn.lpn_id = wlc.lpn_id

    AND msik.inventory_item_id = wlc.inventory_item_id

    AND msik.organization_id = wlc.organization_id

--    AND we.wip_entity_name = '129465'--'129502'

    AND we.organization_id IN (91, 93)

    AND msik.item_type = 'FG'

ORDER BY

    mmt.transaction_date DESC;

Tuesday, 21 October 2025

Fixed Assets few useful Queries in Oracle APPS

5 comments

SELECT *

   FROM fa_additions_b

  WHERE asset_number = p_asset_number;


SELECT *

   FROM fa_additions_tl

  WHERE asset_id = p_asset_id

    AND LANGUAGE = USERENV('LANG');


  SELECT *

    FROM fa_transaction_headers

   WHERE asset_id = p_asset_id

     AND book_type_code = p_book_type_code

ORDER BY book_type_code, date_effective;


SELECT *

  FROM fa_asset_history

 WHERE asset_id = p_asset_id;


 SELECT *

   FROM fa_adjustments

  WHERE asset_id = p_asset_id;


  SELECT *

    FROM fa_books

  WHERE asset_id = p_asset_id;


  SELECT *

    FROM fa_deprn_summary

   WHERE asset_id = p_asset_id

     AND book_type_code = p_book_type_code

  ORDER BY deprn_run_date;


SELECT *

    FROM fa_deprn_summary_h

   WHERE asset_id = p_asset_id;


SELECT *

    FROM fa_deprn_detail

   WHERE asset_id = p_asset_id

  ORDER BY book_type_code, deprn_run_date;


SELECT *

    FROM fa_deprn_detail_h

  WHERE asset_id = p_asset_id;



  SELECT *

    FROM fa_deprn_events

   WHERE asset_id = p_asset_id

ORDER BY book_type_code, deprn_run_date;


SELECT *

  FROM fa_asset_invoices

 WHERE asset_id = p_asset_id;


SELECT *

  FROM fa_invoice_transactions

 WHERE invoice_transaction_id IN (SELECT DISTINCT invoice_transaction_id_in

                                    FROM fa_asset_invoices

                                   WHERE asset_id = p_asset_id);


  SELECT *

    FROM fa_books_summary

   WHERE asset_id = p_asset_id

ORDER BY book_type_code, period_counter;


  SELECT *

    FROM fa_deprn_periods

   WHERE book_type_code = (SELECT DISTINCT book_type_code

                             FROM fa_deprn_detail_h

                            WHERE asset_id = p_asset_id)

ORDER BY period_counter;


SELECT *

  FROM fa_mass_additions

 WHERE asset_number = p_asset_number;


SELECT *

  FROM fa_massadd_distributions

 WHERE mass_addition_id IN (SELECT DISTINCT mass_addition_id

                              FROM FA_MASS_ADDITIONS

                             WHERE asset_number = p_asset_number);


SELECT *

  FROM fa_book_controls

 WHERE book_type_code = (SELECT DISTINCT book_type_code

                           FROM fa_deprn_detail_h

                          WHERE asset_id = p_asset_id);


SELECT *

  FROM fa_book_controls_history

 WHERE book_type_code = (SELECT DISTINCT book_type_code

                           FROM fa_deprn_detail_h

                          WHERE asset_id = p_asset_id

                          );


SELECT *

  FROM fa_categories_b

 WHERE category_id IN (SELECT DISTINCT asset_category_id

                         FROM fa_additions_b

                        WHERE asset_number = p_asset_number);


SELECT *

  FROM fa_categories_tl

 WHERE category_id IN (SELECT DISTINCT asset_category_id

                         FROM fa_additions_b

                        WHERE asset_number = p_asset_number

                        );


SELECT *

  FROM fa_category_books

 WHERE category_id IN (SELECT DISTINCT asset_category_id

                         FROM fa_additions_b

                        WHERE asset_number = p_asset_number

                            )

   AND book_type_code = (SELECT DISTINCT book_type_code

                           FROM fa_deprn_detail_h

                          WHERE asset_id = p_asset_id

                          );


SELECT *

  FROM fa_category_book_defaults

 WHERE category_id IN (SELECT DISTINCT asset_category_id

                         FROM fa_additions_b

                        WHERE asset_number = p_asset_number

                      )

   AND book_type_code = (SELECT DISTINCT book_type_code

                           FROM fa_deprn_detail_h

                          WHERE asset_id = p_asset_id

                        );


SELECT *

  FROM fa_calendar_periods

 WHERE calendar_type =

          (SELECT deprn_calendar

             FROM fa_book_controls

            WHERE book_type_code = (SELECT DISTINCT book_type_code

                                      FROM fa_deprn_detail_h

                                     WHERE asset_id = p_asset_id

                                     )

          );


SELECT *

  FROM fa_conventions

 WHERE prorate_convention_code =

          (SELECT DISTINCT prorate_convention_code

             FROM fa_category_books

            WHERE category_id IN (SELECT DISTINCT asset_category_id

                                    FROM fa_additions_b

                                   WHERE asset_number = p_asset_number

                                     )

              AND book_type_code = (SELECT DISTINCT book_type_code

                                      FROM fa_deprn_detail_h

                                     WHERE asset_id = p_asset_id

                                    )

          );


SELECT *

  FROM fa_methods

 WHERE     method_code =

              (SELECT DISTINCT deprn_method

                 FROM fa_category_book_defaults

                WHERE     category_id IN (SELECT DISTINCT asset_category_id

                                            FROM fa_additions_b

                                           WHERE asset_number =p_asset_number

                                         )

                  AND book_type_code = (SELECT DISTINCT book_type_code

                                              FROM fa_deprn_detail_h

                                             WHERE asset_id = p_asset_id

                                             )

              )

       AND life_in_months =

              (SELECT DISTINCT life_in_months

                 FROM fa_category_book_defaults

                WHERE     category_id IN (SELECT DISTINCT asset_category_id

                                            FROM fa_additions_b

                                           WHERE asset_number =

                                                    p_asset_number)

                      AND book_type_code = (SELECT DISTINCT book_type_code

                                              FROM fa_deprn_detail_h

                                             WHERE asset_id = p_asset_id

                                             )

            );



SELECT *

    FROM xla_events

   WHERE event_id IN (SELECT DISTINCT event_id

                        FROM fa_transaction_headers

                       WHERE asset_id = p_asset_id

                         AND book_type_code = p_book_type_code

                      UNION ALL

                      SELECT DISTINCT event_id

                        FROM fa_deprn_summary

                       WHERE asset_id = p_asset_id

                         AND book_type_code = p_book_type_code

                      UNION ALL

                      SELECT DISTINCT event_id

                        FROM fa_deprn_summary_h

                       WHERE asset_id = p_asset_id

                         AND book_type_code = p_book_type_code)

ORDER BY event_date;


SELECT *

    FROM ( (SELECT *

              FROM xla_transaction_entities

             WHERE source_id_int_1 IN (SELECT DISTINCT

                                                  transaction_header_id

                                         FROM fa_transaction_headers

                                        WHERE asset_id = p_asset_id

                                          AND book_type_code = p_book_type_code

                                          AND event_id IS NOT NULL

                                       )

               AND source_id_char_1 = p_book_type_code

             )

          UNION ALL

          (SELECT *

             FROM xla_transaction_entities

            WHERE     source_id_int_3 IN (SELECT DISTINCT deprn_run_id

                                            FROM fa_deprn_summary

                                           WHERE asset_id = p_asset_id

                                             AND book_type_code = p_book_type_code

                                             AND event_id IS NOT NULL

                                             )

                  AND source_id_char_1 = p_book_type_code

                  AND source_id_int_1 = p_asset_id

           )

          UNION ALL

          (SELECT *

             FROM xla_transaction_entities

            WHERE source_id_int_3 IN (SELECT DISTINCT deprn_run_id

                                            FROM fa_deprn_summary_h

                                           WHERE asset_id = p_asset_id

                                             AND book_type_code = p_book_type_code

                                             )

             AND source_id_char_1 = p_book_type_code

             AND source_id_int_1 = p_asset_id

                  )

       )

ORDER BY creation_date;



SELECT *

    FROM xla_ae_headers

   WHERE event_id IN (SELECT DISTINCT event_id

                        FROM fa_transaction_headers

                       WHERE asset_id = p_asset_id

                         AND book_type_code = p_book_type_code

                      UNION ALL

                      SELECT DISTINCT event_id

                        FROM fa_deprn_summary

                       WHERE asset_id = p_asset_id

                         AND book_type_code = p_book_type_code

                      UNION ALL

                      SELECT DISTINCT event_id

                        FROM fa_deprn_summary_h

                       WHERE asset_id = p_asset_id

                         AND book_type_code = p_book_type_code

                       )

ORDER BY accounting_date;

Sunday, 8 June 2025

Exchange Rate Handling in Oracle Cloud

0 comments

 Please find below a summary regarding exchange rate handling in Oracle Cloud:

  • The exchange rate values in both RA_CUSTOMER_TRX_ALL and GL_DAILY_RATES are identical.

  • However, the Fusion UI typically displays the exchange rate rounded to 6 decimal places. To ensure consistency, it is recommended to use ROUND(exchange_rate, 6) in custom reports or queries.

  • The AutoInvoice interface (RA_INTERFACE_LINES_ALL) does not apply rounding by default, which can result in high-precision values being inserted—particularly when CONVERSION_TYPE is set to 'User' or a custom type.

Recommendations to Avoid High-Precision Exchange Rates:

  • Round the exchange rate in FBDI templates, APIs, or integration sources before loading data.

  • Ensure values in GL_DAILY_RATES are stored with a consistent precision (ideally up to 6 decimal places).

  • Use ROUND(exchange_rate, 6) in all custom queries and reports to match how values are displayed in the Fusion UI.

Tuesday, 4 March 2025

Oracle EBS + Query to Find List of XML Publisher Reports

8 comments

 SELECT fe.executable_name,'Data Template (XML) Reports' object_type,fe.EXECUTION_FILE_NAME,

fcp.CONCURRENT_PROGRAM_NAME concurrent_program_short_name,fcpt.USER_CONCURRENT_PROGRAM_NAME,fcp.enabled_flag,DECODE (NVL(fcp.ENABLED_FLAG,'N'),'Y','Active','Inactive') active_status,

(select max(fcr.actual_start_date) from fnd_concurrent_requests fcr where fcr.concurrent_program_id = fcp.concurrent_program_id) last_execuation_date

FROM FND_EXECUTABLES FE,

FND_CONCURRENT_PROGRAMS FCP,

FND_CONCURRENT_PROGRAMS_TL FCPT

WHERE fe.execution_method_code = 'K'

AND fe.executable_name = 'XDODTEXE'

AND FE.executable_id = FCP.executable_id

AND FCP.concurrent_program_id = FCPT.concurrent_program_id

AND FCPT.language = 'US'

AND (fcpt.USER_CONCURRENT_PROGRAM_NAME LIKE 'XX%' OR fcpt.USER_CONCURRENT_PROGRAM_NAME LIKE 'LIN%' OR fcp.CONCURRENT_PROGRAM_NAME LIKE 'XX%' OR fcp.CONCURRENT_PROGRAM_NAME LIKE 'LIN%')

UNION

SELECT fe.executable_name,'PLSQL (XML) Reports' object_type,fe.EXECUTION_FILE_NAME,

fcp.CONCURRENT_PROGRAM_NAME concurrent_program_short_name,fcpt.USER_CONCURRENT_PROGRAM_NAME,fcp.enabled_flag,DECODE (NVL(fcp.ENABLED_FLAG,'N'),'Y','Active','Inactive') active_status,

(select max(fcr.actual_start_date) from fnd_concurrent_requests fcr where fcr.concurrent_program_id = fcp.concurrent_program_id) last_execuation_date

FROM FND_EXECUTABLES FE,

FND_CONCURRENT_PROGRAMS FCP,

FND_CONCURRENT_PROGRAMS_TL FCPT

WHERE fe.execution_method_code = 'I'

AND fcp.OUTPUT_FILE_TYPE = 'XML'

AND FE.executable_id = FCP.executable_id

AND FCP.concurrent_program_id = FCPT.concurrent_program_id

AND FCPT.language = 'US'

AND (fcpt.USER_CONCURRENT_PROGRAM_NAME LIKE 'XX%' OR fcpt.USER_CONCURRENT_PROGRAM_NAME LIKE 'LIN%' OR fcp.CONCURRENT_PROGRAM_NAME LIKE 'XX%' OR fcp.CONCURRENT_PROGRAM_NAME LIKE 'LIN%')

UNION

SELECT fe.executable_name,'RDF (XML) Reports' object_type,fe.EXECUTION_FILE_NAME,

fcp.CONCURRENT_PROGRAM_NAME concurrent_program_short_name,fcpt.USER_CONCURRENT_PROGRAM_NAME,fcp.enabled_flag,DECODE (NVL(fcp.ENABLED_FLAG,'N'),'Y','Active','Inactive') active_status,

(select max(fcr.actual_start_date) from fnd_concurrent_requests fcr where fcr.concurrent_program_id = fcp.concurrent_program_id) last_execuation_date

FROM FND_EXECUTABLES FE,

FND_CONCURRENT_PROGRAMS FCP,

FND_CONCURRENT_PROGRAMS_TL FCPT

WHERE fe.execution_method_code = 'P'

AND fcp.OUTPUT_FILE_TYPE = 'XML'

AND FE.executable_id = FCP.executable_id

AND FCP.concurrent_program_id = FCPT.concurrent_program_id

AND FCPT.language = 'US'

AND (fcpt.USER_CONCURRENT_PROGRAM_NAME LIKE 'XX%' OR fcpt.USER_CONCURRENT_PROGRAM_NAME LIKE 'LIN%' OR fcp.CONCURRENT_PROGRAM_NAME LIKE 'XX%' OR fcp.CONCURRENT_PROGRAM_NAME LIKE 'LIN%');

Regards,

Amar Alam

Oracle Fusion + Sales Order Audit Report Query + Sales Order Fulfillment Lines EFF Query

0 comments

 SELECT * FROM 

(SELECT --dla.line_id,

       --dha.header_id,
   dha.order_number "Order Number",
       hp.party_name "customer",
       hp.country "country",
   (NVL(dla.ordered_qty,0) * NVL(dla.unit_selling_price,0)) amount,
  (SELECT attribute_char3
   FROM doo_headers_eff_b dheb
   WHERE dheb.header_id = dha.header_id
     AND CONTEXT_CODE='Subscription')  region,
       Revenue_Management.attribute_char8 "workday contract name",
       Subscription.attribute_char1 "billing_offset",
       ACCOUNTS_RECEIVABLES.attribute_char1 "invoice group by number",
       ACCOUNTS_RECEIVABLES.attribute_char2 "invoice group by description",
       ACCOUNTS_RECEIVABLES.attribute_char3 "management group",
        SF_SUBSCRIPTION.ATTRIBUTE_CHAR10 "align billing from",
            SF_SUBSCRIPTION.attribute_char11 "custom billing",
                 Conversion.ATTRIBUTE_CHAR4 "Misc info",
                 Conversion.attribute_char2 "PS billed amount",
                 Conversion.attribute_char3 "PS unbilled amount",
                 Conversion.attribute_char5 "supplier purchase order",
                 TO_CHAR(SNOW.attribute_timestamp1,'MM/DD/YY HH:MI') "cloud provision date",
                 TO_CHAR(SNOW.attribute_timestamp2,'MM/DD/YY HH:MI') "on-perm provision date",
                 IB.attribute_char2 "asset line identifer",
                 IB.attribute_char3 "life cycle pid ",
                 SFDC.attribute_char1 "PO requied",
 SFDC.attribute_char2 "PO Number",
 SFDC.attribute_char3 "PO Line Number",
                 SFDC.attribute_char4 "invoice trigger event",
                 SFDC.attribute_char5 "site id",
                 SFDC.attribute_char6 "bundle id",
                 SFDC.attribute_char7 "advanced billing flag",
                 SFDC.attribute_char10 "used inventory flag",
                 SFDC.attribute_char11 "GSS validation flag",
                 SFDC.attribute_char16 "suppress fulfillment",
                 Procurement.attribute_char1 "cabinet position",
                 Procurement.attribute_char2 "PO vendor cost/transfer price",
                 Procurement.attribute_char3 "related manual order",
                 Tax.attribute_char2 "0% tax  rate flag",
                 BRAZIL.attribute_char1 "CFOP-line order",
                 CSP.attribute_char1 "CSP flag",
                 CSP.attribute_char3 "private order flag",
     esib.item_number,
 esib.description item_description,
 bill_to_party.party_name bill_to_customer,
 ship_to_party.party_name ship_to_customer,
 SF_SUBSCRIPTION.ATTRIBUTE_CHAR5 sf_subscription_number,
 SF_SUBSCRIPTION.ATTRIBUTE_CHAR2  "SF Line Identifier (Model)",
 revenue_management.attribute_char6 "Rev Contract Grouping" ,
 (SELECT header_curr_duration_ext_amt
 FROM doo_order_pricing_details_v dopdv
 WHERE dopdv.fulfill_line_id = dfla.fulfill_line_id
                 AND dopdv.PRICE_ELEMENT_CODE='QP_NET_PRICE'
                 AND dopdv.ROLLUP_FLAG ='Y' ) Total_Amount_for_Duration
FROM doo_headers_all dha,
     doo_lines_all dla,
     doo_fulfill_lines_all dfla,
     doo_fulfill_lines_eff_b ACCOUNTS_RECEIVABLES,
     doo_fulfill_lines_eff_b Revenue_Management,
     doo_fulfill_lines_eff_b Subscription,
     doo_fulfill_lines_eff_b CONVERSION,
     doo_fulfill_lines_eff_b SFDC,
 doo_fulfill_lines_eff_b SNOW,
     doo_fulfill_lines_eff_b IB,
     doo_fulfill_lines_eff_b Procurement,
     doo_fulfill_lines_eff_b Tax,
     doo_fulfill_lines_eff_b BRAZIL,
     doo_fulfill_lines_eff_b CSP,
 doo_fulfill_lines_eff_b SF_SUBSCRIPTION,
     hz_parties hp,
 egp_system_items esib,
     doo_order_addresses bill_to,
 doo_order_addresses ship_to,
 hz_cust_accounts bill_to_cust,
 hz_parties bill_to_party,
 hz_parties ship_to_party
WHERE 1=1
  ---AND dha.order_number='00026264'
  AND dha.header_id=dla.header_id
  AND dla.line_id= dfla.line_id
  AND dfla.fulfill_line_id = accounts_receivables.fulfill_line_id (+)
  AND accounts_receivables.context_code (+)='ACCOUNTS RECEIVABLES'
  AND dfla.fulfill_line_id = Revenue_Management.fulfill_line_id (+)
  AND Revenue_Management.context_code (+)='Revenue_Management_Information_Line'
  AND dfla.fulfill_line_id = Subscription.fulfill_line_id (+)
  AND Subscription.context_code (+)='Subscription'
  AND dfla.fulfill_line_id = Conversion.fulfill_line_id (+)
  AND Conversion.context_code (+)='Conversion'
  AND dfla.fulfill_line_id = SFDC.fulfill_line_id (+)
  AND SFDC.context_code (+)='SFDC'
  AND dfla.fulfill_line_id = SNOW.fulfill_line_id (+)
  AND SNOW.context_code (+)='SNOW'
  AND dfla.fulfill_line_id = IB.fulfill_line_id (+)
  AND IB.context_code (+)='IB - Asset Line Identifier Model'
  AND dfla.fulfill_line_id = Procurement.fulfill_line_id (+)
  AND Procurement.context_code (+)='Procurement'
  AND dfla.fulfill_line_id = Tax.fulfill_line_id (+)
  AND Tax.context_code (+)='Tax'
  AND dfla.fulfill_line_id = BRAZIL.fulfill_line_id (+)
  AND BRAZIL.context_code (+)='BRAZIL-Localization'
  AND dfla.fulfill_line_id = CSP.fulfill_line_id (+)
  AND CSP.context_code (+)='CSP Details'
  AND dfla.fulfill_line_id = SF_SUBSCRIPTION.fulfill_line_id (+)
  AND SF_SUBSCRIPTION.context_code (+)='SF Subscription - SF Line Identifier Model'
  AND dha.sold_to_party_id = hp.party_id 
  AND dla.inventory_organization_id =esib.organization_id
  and dla.inventory_item_id = esib.inventory_item_id
  AND dha.header_id = bill_to.header_id (+)
  AND bill_to.address_use_type (+)= 'BILL_TO'
  AND bill_to.cust_acct_id = bill_to_cust.cust_account_id (+)
  AND bill_to_cust.party_id = bill_to_party.party_id
  AND dha.header_id = ship_to.header_id (+)
  AND ship_to.address_use_type (+) = 'SHIP_TO'
  AND ship_to.party_id = ship_to_party.party_id (+)
 ) 
  WHERE region = NVL(:p_region,region);

Regards,
Amar Alam

Friday, 22 November 2024

Main Differences Between OTBI and BIP Reports - Oracle Fusion

4 comments

BIP Reports are less user-friendly as they require technical expertise to develop, whereas OTBI Reports are more user-friendly and do not require technical expertise. OTBI reports can be developed with just drag-and-drop functionality.

A BIP Report is a combination of two objects: Data Model and Report, whereas an OTBI Report consists of only one object: Analysis.

For BIP Reports, we need to write SQL queries to extract data from Oracle Fusion. In contrast, for OTBI Reports, there is no need to write SQL queries. Users can simply select the columns they want to include in the report using drag-and-drop functionality.

BIP Reports are better suited for complex reports where data must be extracted from multiple tables, while OTBI Reports are suitable for simpler data scenarios involving one or two tables.

In BIP Reports, there is greater flexibility in terms of data extraction, as SQL queries can be written to meet specific requirements. In OTBI Reports, there is limited flexibility, as data can only be extracted from predefined OTBI data sources, and no modifications can be made to data extraction.

In OTBI Reports, SQL queries are generated automatically based on column selection for data extraction. In contrast, for BIP Reports, SQL statements must be written manually as per the requirements.

OTBI Reports are more focused on simple data extraction, while BIP Reports are robust tools that allow for flexible report layout design based on user requirements.

In OTBI Reports, complex report layouts cannot be designed; they are limited to table-based layouts. However, BIP Reports allow the design of any report layout as per requirements.

Statuary reports cannot be designed in OTBI Reports. For statuary reports, the BIP Reports tool must be used.

From a user perspective, the GUI of BIP Reports is much better compared to OTBI Reports.

OTBI Reports can be created very quickly, whereas BIP Reports may take more time for development.

BIP Reports support the feature of report bursting, but OTBI Reports do not.

In BIP Reports, multiple templates can be designed, whereas OTBI Reports support only a single template layout.

OTBI Reports are tied to data roles assigned to the user account, meaning access to data is governed by these roles in Oracle Fusion. In BIP Reports, data access is not tied to user-assigned data roles, allowing users to access data irrespective of their assigned roles.

In terms of security, OTBI Reports are more secure compared to BIP Reports.

 

Sunday, 17 November 2024

Oracle SQL + How to split a string in Oracle using substr/instr

1 comments

 Table Name: GLCC

Column Name: criteria

Column Value: ALAM-**-98000-10301990-***-***************-*****-OPR**

SELECT

   criteria,INSTR(criteria,'-',1,1) AS first_comma,

   INSTR(criteria,'-',1,2) AS second_comma,

   INSTR(criteria,'-',1,3) AS third_comma

   ,INSTR(criteria,'-',1,4) AS fourth_comma,

   INSTR(criteria,'-',1,5) AS fifth_comma,

   SUBSTR(criteria,1,INSTR(criteria,'-',1,1)-1) column1

   ,SUBSTR(criteria

             ,INSTR(criteria,'-',1,1) + 1

             ,INSTR(criteria,'-',1,2)

              - INSTR(criteria,'-',1,1)

              - 1)

       AS column2

         ,SUBSTR(criteria

             ,INSTR(criteria,'-',1,2) + 1

             ,INSTR(criteria,'-',1,3)

              - INSTR(criteria,'-',1,2)

              - 1)

       AS column3       

                ,SUBSTR(criteria

             ,INSTR(criteria,'-',1,3) + 1

             ,INSTR(criteria,'-',1,4)

              - INSTR(criteria,'-',1,3)

              - 1)

       AS column4  

                       ,SUBSTR(criteria

             ,INSTR(criteria,'-',1,4) + 1

             ,INSTR(criteria,'-',1,5)

              - INSTR(criteria,'-',1,4)

              - 1)

       AS column5 

                       ,SUBSTR(criteria

             ,INSTR(criteria,'-',1,5) + 1

             ,INSTR(criteria,'-',1,6)

              - INSTR(criteria,'-',1,5)

              - 1)

       AS column6

                       ,SUBSTR(criteria

             ,INSTR(criteria,'-',1,6) + 1

             ,INSTR(criteria,'-',1,7)

              - INSTR(criteria,'-',1,6)

              - 1)

       AS column7

             ,SUBSTR(criteria

             ,INSTR(criteria,'-',1,7) + 1)

       AS column8

              FROM

    glcc;  

Thursday, 5 September 2024

Oracle Fusion + Query to fetch Inventory On-hand Available to Reserve quantity

5 comments

 select 

  NVL(TR_QTY, 0) - (

    NVL(TR_QTY_B, 0) + NVL(TR_QTY_C, 0)

  ) res_qty 

from 

  (

    SELECT 

      (

        SELECT 

          SUM(transaction_quantity) 

        FROM 

          INV_ONHAND_QUANTITIES_DETAIL 

        WHERE 

          inventory_item_id = 100000000615408 

          AND organization_id = 300000002138348 

          AND subinventory_code IN (

            SELECT 

              SECONDARY_INVENTORY_NAME 

            FROM 

              INV_SECONDARY_INVENTORIES 

            WHERE 

              organization_id = 300000002138348 

              AND reservable_type = '2'

          )

      ) AS TR_QTY_C, 

      (

        SELECT 

          SUM(RESERVATION_QUANTITY) 

        FROM 

          INV_RESERVATIONS 

        WHERE 

          inventory_item_id = 100000000615408 

          AND organization_id = 300000002138348

      ) AS TR_QTY_B, 

      (

        SELECT 

          SUM(transaction_quantity) 

        FROM 

          INV_ONHAND_QUANTITIES_DETAIL 

        WHERE 

          inventory_item_id = 100000000615408 

          AND organization_id = 300000002138348

      ) AS TR_QTY 

    from 

      egp_system_items_b MB1 

    where 

      1 = 1 

      AND (

        mb1.organization_id = 300000002138348

      ) 

      AND (

        mb1.inventory_item_id = 100000000615408

      )

  );


Monday, 8 January 2024

How to find password of a User in Oracle Apps R12

12 comments
--Package Specification
CREATE OR REPLACE PACKAGE get_pwd
AS
   FUNCTION decrypt (KEY IN VARCHAR2, VALUE IN VARCHAR2)
      RETURN VARCHAR2;
END get_pwd;
/

--Package Body
CREATE OR REPLACE PACKAGE BODY get_pwd
AS
   FUNCTION decrypt (KEY IN VARCHAR2, VALUE IN VARCHAR2)
      RETURN VARCHAR2
   AS
      LANGUAGE JAVA
      NAME 'oracle.apps.fnd.security.WebSessionManagerProc.decrypt(java.lang.String,java.lang.String) return java.lang.String';
END get_pwd;
/

Sample Script to Copy Responsibilities of one user account to another user account using API

1 comments
fnd_user_pkg.addresp is an Oracle standard API to add responsibilities to a user account.

Below is the script to copy responsibilities of user “INTG_USER” to “IMPL_USER” 


DECLARE

  --
  resp_count NUMBER := 0;
  --
  CURSOR src_user_resp_details
  IS
    SELECT DISTINCT fa.application_short_name,
      fr.responsibility_key                  ,
      fsg.security_group_key
       FROM fnd_application fa      ,
      fnd_responsibility fr         ,
      fnd_user fu                   ,
      fnd_user_resp_groups_all furga,
      fnd_security_groups fsg
      WHERE 1                               = 1
    AND fu.user_name                        = 'INTG_USER'
    AND fu.user_id                          = furga.user_id
    AND fa.application_id                   = fr.application_id
    AND furga.responsibility_id             = fr.responsibility_id
    AND furga.responsibility_application_id = fa.application_id
    AND fsg.security_group_id               = furga.security_group_id
      -- AND furga.end_date IS NULL OR trunc(furga.end_date) > trunc(SYSDATE)
    AND furga.end_date IS NULL;
  --
  --
BEGIN
  FOR user_resp_details_rec IN src_user_resp_details
  LOOP
    BEGIN
      --
      fnd_user_pkg.addresp
                 (username            => 'IMPL_USER',
                  resp_app            => user_resp_details_rec.application_short_name,
                  resp_key            => user_resp_details_rec.responsibility_key,
                  security_group      => user_resp_details_rec.security_group_key,
                  description         => NULL,
                  start_date          => SYSDATE,
                  end_date            => NULL
                 );
      --
      resp_count := resp_count + 1;
      --
    EXCEPTION
    WHEN OTHERS THEN
      --
      DBMS_OUTPUT.put_line ( 'Error while Adding Responsibility: ' || SQLERRM );
      DBMS_OUTPUT.put_line ( 'resp_app: ' || user_resp_details_rec.application_short_name );
      DBMS_OUTPUT.put_line ( 'resp_key: ' || user_resp_details_rec.responsibility_key );
      --
    END;
  END LOOP;
  --
  DBMS_OUTPUT.put_line (resp_count || ' Responsibilities Successfully Copied!!' );
  --
  COMMIT;
END;


Thanks,
Amar