Friday, 4 July 2014

How to find invalid invoice distributions for a ‘DIST ACCT INVALID’ hold

/* Formatted on 7/4/2014 10:47:39 AM (QP5 v5.115.810.9015) */
SELECT invoice_distribution_id, distribution_line_number, d.*
FROM apps.ap_invoice_distributions_all d
WHERE d.invoice_id = 174783 AND d.posted_flag IN ('N', 'P')
      AND ( (EXISTS
                (SELECT 'x'
                 FROM gl_code_combinations c
                 WHERE d.dist_code_combination_id = c.code_combination_id(+)
                       AND (   c.code_combination_id IS NULL
                            OR c.detail_posting_allowed_flag = 'N'
                            OR c.start_date_active > d.accounting_date
                            OR c.end_date_active < d.accounting_date
                            OR c.template_id IS NOT NULL
                            OR c.enabled_flag <> 'Y'
                            OR c.summary_flag <> 'N')))
           OR (d.dist_code_combination_id = -1));


/* Formatted on 7/4/2014 10:48:28 AM (QP5 v5.115.810.9015) */
SELECT *
FROM gl_code_combinations_kfv
WHERE 1 = 1
      AND code_combination_id IN (SELECT DISTINCT dist_code_combination_id
                                  FROM apps.ap_invoice_distributions_all d
                                  WHERE d.invoice_id = 261319)


/* Formatted on 7/4/2014 10:48:33 AM (QP5 v5.115.810.9015) */
SELECT start_date_active, concatenated_segments, code_combination_id
FROM gl_code_combinations_kfv
WHERE 1 = 1
      AND code_combination_id IN (SELECT DISTINCT dist_code_combination_id
                                  FROM apps.ap_invoice_distributions_all d
                                  WHERE d.invoice_id = 261319)

No comments:

Post a Comment