Sunday, July 19, 2020

AR Invoice distribution line update API

/*AR Invoice distribution's Revenue Account Update API*/
/* Formatted on 2020/07/19 19:54 (Formatter Plus v4.8.8) */
DECLARE
   l_backout_flag               BOOLEAN;
   lout_backout_done_flag       BOOLEAN;
   p_cust_trx_line_gl_dist_id   NUMBER;
   l_customer_trx_id            NUMBER;
   l_header_gl_date             DATE;
   l_trx_date                   DATE;
   l_invoicing_rule_id          NUMBER;
   l_user_id                    NUMBER;
   l_resp_id                    NUMBER;
   l_resp_appl_id               NUMBER;
   r_rctgld                     ra_cust_trx_line_gl_dist%ROWTYPE;
l_old_ccid number;  
l_new_required_ccid number;
   CURSOR c_dist_line
   IS
      SELECT rctgd.*
        FROM ra_cust_trx_line_gl_dist_all rctgd
       WHERE rctgd.cust_trx_line_gl_dist_id = p_cust_trx_line_gl_dist_id;
BEGIN
   BEGIN
      SELECT rctgd.created_by, rcta.customer_trx_id, rcta.trx_date,
             rctgd.gl_date, rcta.invoicing_rule_id
             ,rctgd.CODE_COMBINATION_ID
        INTO l_user_id, l_customer_trx_id, l_trx_date,
             l_header_gl_date, l_invoicing_rule_id,l_old_ccid
        FROM ra_cust_trx_line_gl_dist_all rctgd, ra_customer_trx_all rcta
       WHERE 1 = 1
         AND rctgd.customer_trx_id = rcta.customer_trx_id
         AND rctgd.cust_trx_line_gl_dist_id = p_cust_trx_line_gl_dist_id
         and rctgd.ACCOUNT_CLASS='REV' ;
   END;

   BEGIN
      SELECT fnd.user_id, fresp.responsibility_id, fresp.application_id
        INTO l_user_id, l_resp_id, l_resp_appl_id
        FROM fnd_user fnd,
             fnd_responsibility_tl fresp,
             fnd_user_resp_groups_direct furg
       WHERE 1 = 1
         AND furg.user_id = fnd.user_id
         AND furg.responsibility_id = fresp.responsibility_id
         AND fnd.user_id = l_user_id
         AND UPPER (fresp.responsibility_name) LIKE '%MTC%REC%USE%'
         AND TRUNC (SYSDATE) BETWEEN furg.start_date
                                 AND NVL (furg.end_date, TRUNC (SYSDATE + 2))
         AND furg.start_date IS NOT NULL
         AND ROWNUM < 2;
--select * from fnd_user_resp_groups_direct        furg where furg.START_DATE is null

   --select * from fnd_responsibility_tl fresp where fresp.responsibility_name  like 'MTC%Rec%Use%'
   END;
  


   fnd_global.apps_initialize (user_id           => l_user_id,
                               resp_id           => l_resp_id,
                               resp_appl_id      => l_resp_appl_id
                              );

   FOR i IN c_dist_line
   LOOP
   begin
  
   select gcc_all segments as itis and seg3 is required Account into l_new_required_ccid
   from gl_code_combinations gcc
   where gcc.CODE_COMBINATION_ID=l_old_ccid;
   end;
      r_rctgld := i.*;
      r_rctgld.CODE_COMBINATION_ID:=l_new_required_ccid--
      arp_process_dist.update_dist
         (p_form_name                     => 'ARXTWMAI',
          p_form_version                  => NULL,
          p_backout_flag                  => l_backout_flag,
                       --looks have the relation with posting , have to verify
          p_cust_trx_line_gl_dist_id      => p_cust_trx_line_gl_dist_id,
          p_customer_trx_id               => l_customer_trx_id,
          p_dist_rec                      => r_rctgld,
                             --IN OUT NOCOPY ra_cust_trx_line_gl_dist%rowtype,
          p_header_gl_date                => l_header_gl_date,
          p_trx_date                      => l_trx_date,
          p_invoicing_rule_id             => l_invoicing_rule_id,
          p_backout_done_flag             => lout_backout_done_flag,
          p_exchange_rate                 => NULL,
          p_currency_code                 => NULL,
          p_precision                     => NULL,
          p_mau                           => NULL
         );
      COMMIT;
   END LOOP;
END;

No comments:

Post a Comment