SAN FRANCISCO (AP) _ ''The A-Team'' fought its last battle on television years ago but won another one in court in a copyright suit by the writer of an unsuccessful TV pilot about another crew of Vietnam vets.

The 9th U.S. Circuit Court of Appeals on Thursday upheld a judge's ruling that NBC had not copied the action-adventure series from a screenplay called ''Cargo'' by Ernest Olson.

Olson's script involved three Vietnam veterans who had conducted scams during the war and were looking to continue them in civilian life over the opposition of their former superior officers, who had become corrupt drug agents.

''The A-Team'' involved the adventures of four Vietnam vets, three of whom were unjustly court-martialed in Vietnam, escaped from prison and were on the run. Its stars included Mr. T and George Peppard.

A federal jury in Los Angeles found that the series was substantially similar to ''Cargo'' and that NBC had access to Olson's work before putting on ''The A-Team.'' But the judge overruled the jury, finding no substantial similarity.

In a 3-0 decision, the appeals court said the two works were action- adventure series designed to show Vietnam veterans in a favorable light, and there was some resemblance between the leading characters. But the court said the similarities fell far short of the evidence needed for copyright infringement.

The court noted also that Olson had defined the characters in ''Cargo'' with descriptions of only a few lines each.