Thursday 7 June 2018

Query to get Concurrent Program and Related Resposnibility, Request Group in which its assigned.

--Query to get Standalone Request/Concurrent Program Info
SELECT distinct frv.responsibility_name,
       frg.request_group_name,
       frgu.request_unit_type,
       frgu.request_unit_id,
       fcpt.user_concurrent_program_name,
       null request_set_name
  FROM fnd_responsibility_vl frv
      ,fnd_request_groups frg
      ,FND_REQUEST_GROUP_UNITS frgu
      ,fnd_concurrent_programs fcp
      ,fnd_concurrent_programs_tl fcpt
WHERE  1=1
   AND frv.request_group_id= frg.request_group_id
   AND frgu.request_group_id= frg.request_group_id
   AND fcpt.application_id= frgu.unit_application_id
   AND fcp.concurrent_program_id= frgu.request_unit_id
   AND fcpt.concurrent_program_id=fcp.concurrent_program_id
   AND fcpt.user_concurrent_program_name like '%Concurrent Program Name%'

Query to Delete XML Publisher Data Definition and Template from Backend

----Script/Query to Delete XML Publisher Data Definition and Template from Backend--
DECLARE
   -- Change the following two parameters
   var_templateCode    VARCHAR2 (100) := 'XXXXXXXXX';     -- Template Code
   boo_deleteDataDef   BOOLEAN := TRUE;     -- delete the associated Data Def. then TRUE unless make it as FALSE.
BEGIN
   FOR RS
      IN (SELECT T1.APPLICATION_SHORT_NAME TEMPLATE_APP_NAME,
                 T1.DATA_SOURCE_CODE,
                 T2.APPLICATION_SHORT_NAME DEF_APP_NAME
            FROM XDO_TEMPLATES_B T1, XDO_DS_DEFINITIONS_B T2
           WHERE T1.TEMPLATE_CODE = var_templateCode
                 AND T1.DATA_SOURCE_CODE = T2.DATA_SOURCE_CODE)
   LOOP
      XDO_TEMPLATES_PKG.DELETE_ROW (RS.TEMPLATE_APP_NAME, var_templateCode);

      DELETE FROM XDO_LOBS
            WHERE     LOB_CODE = var_templateCode
                  AND APPLICATION_SHORT_NAME = RS.TEMPLATE_APP_NAME
                  AND LOB_TYPE IN ('TEMPLATE_SOURCE', 'TEMPLATE');

      DELETE FROM XDO_CONFIG_VALUES
            WHERE     APPLICATION_SHORT_NAME = RS.TEMPLATE_APP_NAME
                  AND TEMPLATE_CODE = var_templateCode
                  AND DATA_SOURCE_CODE = RS.DATA_SOURCE_CODE
                  AND CONFIG_LEVEL = 50;

      DBMS_OUTPUT.PUT_LINE ('Selected template has been ' || var_templateCode || ' deleted.');

      IF boo_deleteDataDef
      THEN
         XDO_DS_DEFINITIONS_PKG.DELETE_ROW (RS.DEF_APP_NAME,
                                            RS.DATA_SOURCE_CODE);

         DELETE FROM XDO_LOBS
               WHERE LOB_CODE = RS.DATA_SOURCE_CODE
                     AND APPLICATION_SHORT_NAME = RS.DEF_APP_NAME
                     AND LOB_TYPE IN
                            ('XML_SCHEMA',
                             'DATA_TEMPLATE',
                             'XML_SAMPLE',
                             'BURSTING_FILE');

         DELETE FROM XDO_CONFIG_VALUES
               WHERE     APPLICATION_SHORT_NAME = RS.DEF_APP_NAME
                     AND DATA_SOURCE_CODE = RS.DATA_SOURCE_CODE
                     AND CONFIG_LEVEL = 30;

         DBMS_OUTPUT.PUT_LINE (
            'Selected Data Definition has been ' || RS.DATA_SOURCE_CODE || ' deleted.');
      END IF;
   END LOOP;
  COMMIT;
EXCEPTION
   WHEN OTHERS
   THEN
      ROLLBACK;
      DBMS_OUTPUT.PUT_LINE (
         'Unable to delete XML Publisher Template ' || var_templateCode);
      DBMS_OUTPUT.PUT_LINE (SUBSTR (SQLERRM, 1, 200));
END;
/

Script/Query to Delete Concurrent Program and Executable from Backend

--**1. Script to Delete Data Definition**--
BEGIN
XDO_DS_DEFINITIONS_PKG.DELETE_ROW('APPL NAME','DATA DEFINITION CODE');

--
COMMIT;
--
END;

--**Script to Delete Data Template**--
BEGIN
XDO_TEMPLATES_PKG.DELETE_ROW('APPL NAME','DATA TEMPLATE CODE');

--
COMMIT;
--
END;


--2. Script/Query to delete Concurrent Program and Executable from Backend
DECLARE
  prog_short_name    VARCHAR2(240);
  appl_short_name    VARCHAR2(240);
BEGIN
   prog_short_name := 'XXXXXXXX';    --Concurrent Program Short name
   appl_short_name := 'XXXX';     --Application Short name
   --Checking for program and executable is exist or not
   IF fnd_program.program_exists    (prog_short_name, appl_short_name) OR
     fnd_program.executable_exists (prog_short_name, appl_short_name)   
   THEN
   --deleting the program
      fnd_program.delete_program(prog_short_name, appl_short_name);
   --deleting the executable
      fnd_program.delete_executable(prog_short_name, appl_short_name);
      COMMIT;
DBMS_OUTPUT.PUT_LINE (prog_short_name || ' deleted successfully');
   ELSE
      DBMS_OUTPUT.PUT_LINE (prog_short_name || ' not found');
   END IF;
EXCEPTION
   WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE ('Error: ' || SQLERRM);
END;

Query to get Account Payables Invoice Payment Details

--Query to get PAYMENT_REFERENCE_NUMBER and other Info
SELECT xx.*
FROM IBY_PAYMENTS_ALL xx
WHERE payment_id IN
  (SELECT idp.payment_id
    FROM IBY_DOCS_PAYABLE_ALL idp
    WHERE idp.calling_app_id = 200 --SQLAP Application ID
    AND
      (calling_app_doc_unique_ref1
      ,calling_app_doc_unique_ref2)
      IN
      (SELECT TO_CHAR(aps.checkrun_id) checkrun_id
             ,TO_CHAR(aps.invoice_id)
         FROM ap_payment_schedules_all aps
        WHERE aps.invoice_id = 61332--:P_INV_ID
        UNION
       SELECT TO_CHAR(NVL(ac.checkrun_id, ac.check_id)) checkrun_id
             ,TO_CHAR(aip.invoice_id)
        FROM ap_invoice_payments_all aip
            ,ap_checks_all ac
       WHERE aip.invoice_id = 61332--:P_INV_ID
         AND aip.check_id = ac.check_id
      )
  );
 
--Query to get payment document info
SELECT xx.*
  FROM IBY_PAY_INSTRUCTIONS_ALL xx
 WHERE payment_instruction_id
    IN
  (SELECT ipa.payment_instruction_id
     FROM IBY_DOCS_PAYABLE_ALL idp
         ,IBY_PAYMENTS_ALL ipa
    WHERE idp.calling_app_id = 200 --SQLAP Application ID
      AND ipa.payment_id = idp.payment_id
      AND (calling_app_doc_unique_ref1
          ,calling_app_doc_unique_ref2
          )
       IN(SELECT TO_CHAR(aps.checkrun_id) checkrun_id
                ,TO_CHAR(aps.invoice_id)
            FROM ap_payment_schedules_all aps
           WHERE aps.invoice_id = 61332--:P_INV_ID
        UNION
          SELECT TO_CHAR(NVL(ac.checkrun_id, ac.check_id)) checkrun_id
                ,TO_CHAR(aip.invoice_id)
            FROM ap_invoice_payments_all aip
                ,ap_checks_all ac
           WHERE aip.invoice_id = 61332--:P_INV_ID
             AND aip.check_id = ac.check_id
          )
     ); 

--Query to get Payment Doc Info
SELECT xx.*
FROM AP_DOCUMENTS_PAYABLE xx
WHERE calling_app_id = 200
AND calling_app_doc_unique_ref2 = 61332--:P_INV_ID;

--Query to get Accounts Pay Amount
SELECT DISTINCT fnd_flex_ext.get_segs('SQLGL','GL#', '101',
  aip.accts_pay_code_combination_id) "Accts Pay Account"
  ,aip.*
FROM AP_INVOICE_PAYMENTS_ALL aip,
     AP_INVOICE_PAYMENTS_ALL aip2
WHERE aip2.check_id = aip.check_id
  AND aip2.invoice_id = 61332--:P_INV_ID
ORDER BY aip.check_id ASC,
  aip.invoice_payment_id ASC;
 
--Query to get Payment & Bank Information
SELECT *
FROM AP_CHECKS_ALL
WHERE check_id IN
  (SELECT check_id
    FROM  AP_INVOICE_PAYMENTS_ALL
    WHERE invoice_id = 61332--:P_INV_ID
  );
 
--Query to get Pay Dist Info
SELECT tab.*
FROM AP_INVOICE_PAYMENTS_ALL aip,
  AP_PAYMENT_DISTRIBUTIONS_ALL tab
WHERE aip.invoice_payment_id = tab.invoice_payment_id
AND aip.invoice_id = 61332--:P_INV_ID;

--Query to get PAy History
SELECT *
FROM AP_PAYMENT_HISTORY_ALL
WHERE check_id IN
  (SELECT DISTINCT check_id
    FROM AP_INVOICE_PAYMENTS_ALL
    WHERE invoice_id = 61332--:P_INV_ID
  )
ORDER BY accounting_event_id ASC;
 
--Query to get Payment History and Dist Info
SELECT DISTINCT aphd.*
FROM ap_payment_hist_dists aphd,
  AP_PAYMENT_HISTORY_ALL aph
WHERE aph.payment_history_id = aphd.payment_history_id
AND aph.check_id IN
  (SELECT DISTINCT check_id
    FROM AP_INVOICE_PAYMENTS_ALL
    WHERE invoice_id = 61332--:P_INV_ID
  )
ORDER BY
  aphd.payment_history_id ASC;
 
--Query to get Invoie selection info in Batch Payment
SELECT *
FROM AP_INV_SELECTION_CRITERIA_ALL

WHERE checkrun_name IN
  (SELECT checkrun_name
    FROM AP_CHECKS_ALL
    WHERE check_id IN
      (SELECT check_id
        FROM AP_INVOICE_PAYMENTS_ALL
        WHERE invoice_id = 61332--:P_INV_ID
      )
  );
 
--Query to getSelected  Invoie info in Batch Payment
SELECT *
FROM AP_SELECTED_INVOICES_ALL
WHERE invoice_id = 61332--:P_INV_ID;

-- 
SELECT *
  FROM AP_RECON_DISTRIBUTIONS_ALL
 WHERE check_id
    IN (SELECT check_id
          FROM AP_INVOICE_PAYMENTS_ALL
         WHERE invoice_id = :P_INVOICE_ID
       );
 
--Query to get selected inv and pay info
SELECT asic.*
FROM AP_SELECTED_INVOICE_CHECKS_ALL asic,
  AP_SELECTED_INVOICES_ALL asi
WHERE asi.invoice_id = 61332--:P_INV_ID
AND
  (asic.selected_check_id  = asi.pay_selected_check_id
  OR asic.selected_check_id = print_selected_check_id
  );