Monday 2 July 2018

Script to delete AR transaction (Invoice/CM)

declare
l_org_id   NUMBER := &org_id;
l_trx_id          NUMBER := &customer_trx_id;

begin

mo_global.init('AR');
mo_global.set_policy_context('S',l_org_id);
arp_global.g_allow_datafix := TRUE ; 

delete from xla_distribution_links
where event_id in (select event_id
                     from   xla_events
                     where  entity_id in (select entity_id from xla_transaction_entities
                                          where source_id_int_1 = l_trx_id
                                          and   application_id = 222)
                     and    application_id = 222)
and application_id = 222;

delete from xla_ae_lines
where ae_header_id in (select ae_header_id
                         from xla_ae_headers
                         where entity_id in (select entity_id
                                             from xla_transaction_entities
                                             where source_id_int_1 = l_trx_id
                                             and   application_id = 222)
                         and application_id = 222)
and   application_id = 222;


delete from xla_ae_headers
where entity_id in (select entity_id
                      from xla_transaction_entities
                      where source_id_int_1 = l_trx_id
                      and   application_id = 222)
and application_id = 222;


delete from xla_events
where  entity_id in (select entity_id
                      from xla_transaction_entities
                      where source_id_int_1 = l_trx_id
                      and   application_id = 222)
and application_id = 222;


delete from xla_transaction_entities
where   source_id_int_1 = l_trx_id
and   application_id = 222;


delete from ar_payment_schedules_all
where customer_trx_id in (l_trx_id);


delete from ar_distributions_all
where source_id in (select receivable_application_id
                    from   ar_receivable_applications_all
                    where  customer_trx_id = l_trx_id
                    and    application_type = 'CM');


delete from ar_receivable_applications_all
where customer_trx_id in (l_trx_id);

delete from zx_lines_det_factors
where  trx_id in (l_trx_id);

delete from zx_lines
where  trx_id in (l_trx_id);

delete from ra_cust_trx_line_salesreps_all
where customer_trx_id in (l_trx_id);

delete from ra_cust_trx_line_gl_dist_all
where customer_trx_id in (l_trx_id);

delete from ra_customer_trx_lines_all
where customer_trx_id in (l_trx_id);

delete from ra_customer_trx_all
where customer_trx_id in (l_trx_id);

arp_global.g_allow_datafix := FALSE; 

end;

/

No comments:

Post a Comment

How to resolve issue for BIP RTF template XML tags showing value as <?ref: 0000xx?>

 How to resolve issue for BIP RTF template XML tags showing value as <?ref: 0000xx?>  Sometime these xml data tags automatically chang...