Kraft Foods has posted a rise of nearly 4% in profits for its second quarter despite rising commodity costs.