An RBI, or run batted in, is awarded to a player who successfully brings home a runner currently on base with a hit, walk or sacrifice. Occasionally, a batter will earn an RBI on for a play during which a fielder commits an error. The decision to award an RBI rests with the game's official scorer and depends on the situation.
If there are fewer than two outs and an error is committed on a ball that would have scored the runner even if it had been fielded cleanly, the batter is still awarded an RBI. If two runners come around to score, the batter is given two RBIs.
If there are two outs and a fielding error leads to a run when a clean play would have ended the inning, the batter is not given a hit or an RBI. The error can occur either on the catch or the throw, and is charged to the offending fielder.
It is up to the game's official scorer to determine whether a play is considered a hit or an error. The scorer must base his decision on whether or not the fielder could have made a play on the ball.