Raytheon ( RTN) swung to a second-quarter loss as results were hurt by a shareholder lawsuit settlement. Excluding that cost, however, earnings beat consensus expectations.

The Waltham, Mass.-based defense and electronics company lost $108 million, or 25 cents a share, compared with a gain of $100 million, or 24 cents a share, in the same period last year.

Excluding charges of $222 million, or 51 cents a share, from the shareholder lawsuit and discontinued operations in the previous quarter, earnings fell to $152 million, or 35 cents a share, from $186 million, or 45 cents a share, in the same period last year.

Sales rose 11% to $4.9 billion from $4.4 billion in the same period last year.

Analysts had forecast earnings of 31 cents a share on revenue of $4.89 billion.

Shares of Raytheon were recently up 77 cents, or 2.35%, to $33.48.

The company said it recorded $5 billion in government and defense bookings in the second quarter, up from $3.8 billion a year earlier, which boosted its backlog to $29.5 billion.

Raytheon boosted its full-year booking expectations to $24.5 billion from $23 billion.

The company expects to earn $1.30 to $1.40 a share, excluding the impact of the settlement of 51 cents a share, in line with analysts' expectations of $1.35 a share.