Select distinct ct.customer_trx_id customer_trx_id, ct.trx_number trx_number From ra_customer_trx_all ct, ra_cust_trx_line_gl_dist_all gl Where gl.customer_trx_id = ct.customer_trx_id And ct.complete_flag = 'Y' And gl.account_set_flag = 'N' And gl.gl_date between l_start_gl_date AND l_end_gl_date And ct.customer_trx_id = decode(l_cust_trx_id, 0, ct.customer_trx_id, l_cust_trx_id) And gl.posting_control_id = - 3 And gl.event_id IS NOT NULL And NOT EXISTS ( Select * From xla_events xe Where xe.application_id = 222 And xe.event_id = gl.event_id ) Order By customer_trx_id; BEGIN set_org(l_org_id); debug(' '); debug('Read_Only_Mode: '||l_read_only_mode); debug(' '); debug('Cust Trx Id '||' '||'Trx Number '); debug('================='||' '||'================'); IF nvl(upper(l_read_only_mode),'Y') = 'Y' THEN debug('Script is being run in Read Only Mode ...'); ELSE Debug('Creating back up tables'); backup_table_gldist; END IF; For gld_inv IN gld_missing_event_rows LOOP debug( gld_inv.customer_trx_id|| print_spaces(18-length(gld_inv.customer_trx_id))|| gld_inv.trx_number|| print_spaces(17-length(gld_inv.trx_number)) ); If nvl(upper(l_read_only_mode),'Y') = 'N' Then insert_into_backup_gldist(gld_inv.customer_trx_id); ---- NULL Out the event_id in GLD Table --Debug('Updating the GLD Table for customer_trx_id '||gld_inv.customer_trx_id); Update ra_cust_trx_line_gl_dist Set event_id = null, last_update_date = sysdate Where customer_trx_id = gld_inv.customer_trx_id And posting_control_id = -3 And account_set_flag = 'N' And event_id is not null; -- Calling Event Creation Routines IF gld_inv.customer_trx_id IS NOT NULL THEN --Debug('Recreating the event details for the customer_trx_id '||gld_inv.customer_trx_id); l_xla_ev_rec.xla_from_doc_id := gld_inv.customer_trx_id; l_xla_ev_rec.xla_to_doc_id := gld_inv.customer_trx_id; l_xla_ev_rec.xla_mode := 'O'; l_xla_ev_rec.xla_call := 'B'; l_xla_ev_rec.xla_doc_table := 'CT'; ARP_XLA_EVENTS.create_events(p_xla_ev_rec => l_xla_ev_rec); END IF; End If; -- End If for read_only_mode END LOOP; -- End Loop for the Main For Exception When others then Debug('Error During the Script Execution' ); Raise; Debug('Rollback the fix .. Upload the output file for dev analysis' ); Rollback; END;