If your cabinets are painted, screw a 2x4 to one side of the cabinet to cover the gap, add a little caulk if needed to make the transition between cabinet and 2x4 nice and flat, and then paint the 2x4 to match.
If your cabinets are stained, you'll probably want to find something nicer than a standard 2x4, with a grain that matches the cabinets, and skip the caulk.
if you are removing a portion of the cabinet fronts, take and cut a 4" piece to use as a fill. Get a 1/4" dowling and carefully drill a 1/4" hole in the side of the existing cabinet and the trim piece that you have made put drops of glue into holes that you drilled and then put the pieces together with dowling. you might want to be sure the holes line up good first. then clamp untill dry and then inswtall your d/w.