There
is an API used in Receivables form to delete AR invoice considering all
validations, take care that if the AR invoice has any transaction it will not
be able to be deleted
BEGIN
FOR AR_INV_DATA in (select cux.customer_trx_id , cux.trx_number
from ra_customer_trx_all cux
where cux.batch_source_id = ‘REEM’ And cux.trx_date <= to_date(‘01/05/2007’,’dd/mm/yyyy’)
)
loop
-- Set a proper where condition as your
case
AR_TRANSACTION_PUB.DELETE_TRANSACTION
(p_api_name => 'Maintain_Transaction',
p_api_version => 1.0 ,
p_init_msg_list => Fnd_Api.G_TRUE ,
p_commit => Fnd_Api.G_FALSE,
p_validation_level
=> FND_API.G_VALID_LEVEL_NONE ,
p_customer_trx_id => AR_inv_data.Customer_Trx_Id ,
p_return_status => return_v ,
p_msg_count => msg_count_v ,
p_msg_data => msg_data_v ,
p_errors => l_errors
);
Fnd_File.put_line(Fnd_File.OUTPUT,'Trying to Delete Receivables
Invoice Number : '||AR_INV_DATA.TRX_NUMBER );
IF RETURN_V LIKE 'E%'
THEN
FND_MESSAGE.Set_Name('Receivables', l_errors(1).message_name );
Fnd_File.put_line(Fnd_File.OUTPUT,FND_message.GET);
Fnd_File.put_line(Fnd_File.OUTPUT,'Unable to delete Receivables
Invoice Number : '||AR_INV_DATA.TRX_NUMBER);
APP_EXCEPTION.Raise_Exception;
END IF;
l_match_count
:= l_match_count + 1;
Fnd_File.put_line(Fnd_File.OUTPUT,'Receivables Invoice Number : '||AR_INV_DATA.TRX_NUMBER || ' is deleted ' );
END LOOP;
EXCEPTION
WHEN OTHERS THEN
Fnd_File.put_line(Fnd_File.OUTPUT,'Unable to Delete AR Invoices
due to Internal Error: '||sqlcode||'-'||sqlerrm);
APP_EXCEPTION.Raise_Exception;
END;
No comments:
Post a Comment