Using a Before Commit Event, you check whether the ticket number is populated. If not, you can do a retrieve all (from database) and count. You can then populate your ticket value with the count + 1.
Note that there may be an instance where these transactions are concurrent, which may result in a duplicate ticket number. The best is actually the autonumber attribute for this reason.
You could try to create a Entity called TicketNumber with a AutoNumber Attribute.
Make a 1*1 Assocation to your current Ticket Entity and create the TicketNumber after the successfull Commit of the Ticket.
Hope this helps,