You are correct about the flange being screwed to the slab. If it was over a wood sub floor, then it would screw to the sub floor. To fill in around the drain pipe, first use a removable wrap around the pipe. They actually make a foam wrap for this purpose, but you could improvise something else. Then use a quick set concrete to fill the void. This is really just a hard filler, it doesn't support anything. Smooth it level. Lay what ever flooring you are using then set the flange. There are a couple ways you could set anchor screws into the new concrete. My favorite way to anchor into any concrete is with lead ferrales. I drill a 5/16 hole for the ferrales then screw #12 stainless steel screws through the flance holes and into the lead. Others use Tapcon screws which do works as well. You would want to orient the flange, carefully mark the hole locations, then remove the flange while you drill the holes. I use a rotary hammer drill that must makes punching holes in concrete as easy as drilling wood. Some guy notch the tile when laying it to avoid having to drill though it.