Yes you can do this, it is no problem. You do not need to pass through immigration. You can treat it as though it is a connecting flight on the same ticket.
If possible, check in online for the second flight, and obtain the onward boarding pass on your phone or by print out in advance. If the two airlines are in the same alliance, or cooperate closely, the first airline may be able to do a remote check in for you and obtain your boarding pass at the first airport. (There are actually several ways to do this, so it is worth asking a second person if the check in person is unable to do it. It's best to ask the more "experienced" staff at the customer help desk, because many of the newer staff do not tend to be trained in these kind of technically advanced procedures.)
Alternatively there are check in desks in the international-international connections route to facilitate this. You may have to wait while a representative of your onward airline is contacted, if the desk is not yet manned. You should bring a book, because you could be waiting for over an hour. (This is very unlikely in Bangkok, but it is possible if the second airline doesn't have many flights out of BKK, and therefore the staff haven't arrived at work yet.)
You may find this official link useful: http://www.suvarnabhumiairport.com/en/969-international-to-international-no-boarding-pass