How to abort a transaction?

How to abort a transaction?

  
I uploaded a data file and use a foreach loop to cycle through each record. In each cycle I forward the record to an action for processing.  In this action, the record's validity is checked and if it's valid, the record is created. But if it's not valid,  I like to abort the entire process and send back an error message.  I sent an error feedback message and ended the action, but the for each loop continues to the next record.  So only the offending records were not created. What I want is to rollback the transaction as soon as an invalid record is encountered.

Thanks for any info.
Hi,
Use the built-in action AbortTransaction and end the loop.
Hello,
 
Other option is to, as soon as the error is detected, use Raise Error.
Then have an error handler on your page with the option set to Abort Transaction = YES. 
Thank you all for your help.  I've resolved the issue based on the info.