ebs ar_receipt_api_pub.REVERSE api返回错误

时间:2016-02-28 05:40:07

标签: oracle-ebs

我在程序包中有一个xxtkg_rcpt_reverse_data过程。此过程确定哪个收据将从自定义表中反转。然后,它为反向ar_receipt_api_pub.REVERSE API调用另一个过程xxtkg_rcpt_reverse。

问题是,当多个组织接收反向数据传递给ar_receipt_api_pub.REVERSE API时,它会在包ar_receipt_api_pub过程create_cash中返回错误ORA-28115:带有检查选项违规的策略。

我的两个程序:

PROCEDURE xxtkg_rcpt_reverse_data (p_ou_id           NUMBER,
                                      p_header_id       NUMBER,
                                      p_line_id         NUMBER,
                                      v_out_msg     OUT VARCHAR2)
   IS
      CURSOR dist_data
      IS
           SELECT DISTINCT dist_data.ou_id,
                           dist_data.header_id,
                           dist_data.line_id,
                           --                       dist_data.Amount,
                           --                       dist_data.ref_type,
                           dist_data.ref_number,
                           --                       dist_data.status dist_status,
                           dist_data.CUST_ACCT_ID,
                           line_data.rcv_date,
                           line_data.cash_receipt_id
             FROM (SELECT NVL (TARGET_OU_ID, ou_id) ou_id,
                          NVL (TARGET_header_id, header_id) header_id,
                          NVL (TARGET_line_id, line_id) line_id,
                          Amount,
                          ref_type,
                          ref_number,
                          status,
                          CUST_ACCT_ID
                     FROM xxtkg_chq_distribution
                    WHERE     header_id = p_header_id
                          AND line_id = p_line_id
                          AND ou_id = p_ou_id) dist_data,
                  (SELECT online_data.ou_id,
                          online_data.header_id,
                          online_data.cust_account_id,
                          online_data.line_id,
                          online_data.ref_number,
                          online_data.status,
                          rcv_date,
                          rct.cash_receipt_id
                     FROM (SELECT header.ou_id,
                                  header.header_id,
                                  header.cust_account_id,
                                  line.line_id,
                                  line.ref_number,
                                  line.status,
                                  line.DEPOSIT_DATE rcv_date
                             FROM xxtkg.xxtkg_online_trns_lines line,
                                  xxtkg.xxtkg_online_trns_header header
                            WHERE header.ou_id = line.ou_id
                                  AND header.header_id = line.header_id)
                          online_data,
                          ar_cash_receipts_all rct
                    WHERE online_data.ou_id = rct.org_id(+)
                          AND online_data.cust_account_id =
                                rct.PAY_FROM_CUSTOMER(+)
                          AND online_data.ref_number = rct.RECEIPT_NUMBER(+))
                  line_data
            WHERE     dist_data.header_id = line_data.header_id(+)
                  AND dist_data.line_id = line_data.line_id(+)
                  AND dist_data.ou_id = line_data.ou_id(+)
         ORDER BY line_data.cash_receipt_id DESC;

      l_exist             VARCHAR2 (1);
      l_ou_id             NUMBER;
      l_rct_date          DATE;
      l_cash_receipt_id   NUMBER;
      l_out               VARCHAR2 (2000);
      v_user_id           NUMBER;
      v_resp_id           NUMBER;
      v_resp_appl_id      NUMBER;
      l_error_number      NUMBER;
   --    RECORD_NOT_SAVED    VARCHAR2 (50);
   BEGIN
      l_error_number := 0;
      error_msg := NULL;
      l_exist := NULL;

      MO_GLOBAL.INIT ('AR');
      mo_global.set_policy_context ('S', p_ou_id);
      fnd_global.apps_initialize (user_id        => v_user_id,
                                  resp_id        => v_resp_id,
                                  resp_appl_id   => v_resp_appl_id);

      BEGIN
         SELECT DISTINCT 'Y'
           INTO l_exist
           FROM xxtkg.xxtkg_chq_distribution
          WHERE     ou_id = p_ou_id
                AND header_id = p_header_id
                AND line_id = p_line_id;
      EXCEPTION
         WHEN NO_DATA_FOUND
         THEN
            l_exist := 'N';
      END;

      IF l_exist = 'Y'
      THEN

         FOR dist_curs IN dist_data
         LOOP
            --call API procedure
            IF NOT (dist_curs.cash_receipt_id IS NULL)
            THEN
               xxtkg_rcpt_reverse (dist_curs.ou_id,
                                   dist_curs.cash_receipt_id,
                                   dist_curs.rcv_date);
            END IF;

            IF error_msg LIKE 'E%'
            THEN
               l_error_number := 1 + l_error_number;
            END IF;

            v_out_msg :=
               error_msg || '   ' || dist_curs.ou_id || '   ' || v_out_msg;

            IF NOT (error_msg LIKE 'E%')
            THEN
               UPDATE xxtkg.xxtkg_chq_distribution
                  SET status = 'R'
                WHERE     OU_ID = dist_curs.ou_id
                      AND header_id = dist_curs.header_id
                      AND line_id = dist_curs.line_id;

               UPDATE xxtkg.xxtkg_online_trns_lines
                  SET status = 'R'
                WHERE     OU_ID = dist_curs.ou_id
                      AND header_id = dist_curs.header_id
                      AND line_id = dist_curs.line_id;
            END IF;
         END LOOP;

         v_out_msg := v_out_msg || ' L' || error_msg;
      ELSE
         SELECT online_data.ou_id,
                online_data.deposit_date,
                rct.cash_receipt_id
           INTO l_ou_id, l_rct_date, l_cash_receipt_id
           FROM (SELECT header.ou_id,
                        header.header_id,
                        header.cust_account_id,
                        line.line_id,
                        line.ref_number,
                        line.status,
                        line.deposit_date
                   FROM xxtkg.xxtkg_online_trns_lines line,
                        xxtkg.xxtkg_online_trns_header header
                  WHERE     header.ou_id = line.ou_id
                        AND header.header_id = line.header_id
                        AND status = 'Y') online_data,
                ar_cash_receipts_all rct
          WHERE     online_data.ou_id = rct.org_id(+)
                AND online_data.cust_account_id = rct.PAY_FROM_CUSTOMER(+)
                AND online_data.ref_number = rct.RECEIPT_NUMBER(+)
                AND online_data.ou_id = p_ou_id
                AND online_data.header_id = p_header_id
                AND online_data.line_id = p_line_id;


         IF     NOT (l_ou_id IS NULL)
            AND NOT (l_rct_date IS NULL)
            AND NOT (l_cash_receipt_id IS NULL)
         THEN
---call api procedure
            xxtkg_rcpt_reverse (l_ou_id, l_cash_receipt_id, l_rct_date);

            IF error_msg LIKE 'E%'
            THEN
               l_error_number := 1 + l_error_number;
            END IF;

            IF NOT (error_msg LIKE 'E%')
            THEN
               l_out :=
                     'UPDATE xxtkg.xxtkg_online_trns_lines
                  SET STATUS = ''R''
                WHERE     OU_ID = '
                  || p_ou_id
                  || ' AND header_id ='
                  || p_header_id
                  || ' AND line_id ='
                  || p_line_id;
               BEGIN
                  EXECUTE IMMEDIATE (l_out);

                  IF (SQL%ROWCOUNT = 0)
                  THEN
                     ROLLBACK;
                     v_out_msg := 'Error In Receipt Reversal  ' || v_out_msg;
                  END IF;
               END;
            END IF;


            v_out_msg := error_msg || '   ' || v_out_msg;
         ELSE
            v_out_msg := 'Error In Receipt Reversal' || ' LL' || v_out_msg;
         END IF;
      END IF;

      IF l_error_number > 0
      THEN
         ROLLBACK;
      ELSE
         COMMIT;
      END IF;
   END;
PROCEDURE xxtkg_rcpt_reverse (p_ou_id              NUMBER,
                                 v_cash_receipt_id    NUMBER,
                                 v_recpt_date         DATE)
   IS
      v_user_id         NUMBER;
      v_resp_id         NUMBER;
      v_resp_appl_id    NUMBER;
      v_return_status   VARCHAR2 (1);
      p_count           NUMBER;
      v_msg_count       NUMBER;
      v_msg_data        VARCHAR2 (2000);
   BEGIN
      v_user_id := fnd_global.USER_ID;
      v_resp_id := fnd_global.RESP_ID;
      v_resp_appl_id := fnd_global.RESP_APPL_ID;

      MO_GLOBAL.INIT ('AR');
      mo_global.set_policy_context ('S', p_ou_id);
      fnd_global.apps_initialize (user_id        => v_user_id,
                                  resp_id        => v_resp_id,
                                  resp_appl_id   => v_resp_appl_id);

      ar_receipt_api_pub.REVERSE (
         p_api_version              => 1.0,
         p_init_msg_list            => FND_API.G_TRUE,
         p_commit                   => FND_API.G_TRUE,
         p_validation_level         => FND_API.G_VALID_LEVEL_FULL,
         x_return_status            => v_return_status,
         x_msg_count                => v_msg_count,
         x_msg_data                 => v_msg_data,
         p_cash_receipt_id          => v_cash_receipt_id,
         p_receipt_number           => NULL,
         p_reversal_category_code   => 'REV',
         p_reversal_category_name   => NULL,
         p_reversal_gl_date         => v_recpt_date,
         p_reversal_date            => v_recpt_date,
         p_reversal_reason_code     => 'WRONG INVOICE',
         p_reversal_reason_name     => NULL,
         p_reversal_comments        => NULL,
         p_called_from              => NULL,
         p_cancel_claims_flag       => 'Y',
         p_org_id                   => p_ou_id);

      IF v_return_status = 'S'
      THEN
         error_msg := 'Receipt Reversal is Sucessful';
         DBMS_OUTPUT.put_line ('Receipt Reversal is Sucessful');
      ELSE
         DBMS_OUTPUT.put_line ('Message count ' || v_msg_count);
         error_msg := 'Error In Receipt Reversal ';

         IF v_msg_count = 1
         THEN
            DBMS_OUTPUT.put_line ('l_msg_data ' || v_msg_data);
         ELSIF v_msg_count > 1
         THEN
            LOOP
               p_count := p_count + 1;
               v_msg_data :=
                  FND_MSG_PUB.Get (FND_MSG_PUB.G_NEXT, FND_API.G_FALSE);

               IF v_msg_data IS NULL
               THEN
                  EXIT;
               END IF;

               DBMS_OUTPUT.put_line (
                  'Message' || p_count || ' ---' || v_msg_data);
               error_msg :=
                  error_msg || '  --- ' || p_count || ' ---' || v_msg_data;
            END LOOP;
         END IF;
      END IF;
   END;

请帮忙。

0 个答案:

没有答案