MORAL INDIGNATION is a noble passion, and

there is no country whose racial practices attract it so powerfully as South Africa's. But translating it into foreign policy legislation is full of pitfalls, and never more than when it's being done on the floor of the House of Representatives.

The House voted Thursday to prohibit any new American investment in South Africa. The author of that amendment, Rep. William H. Gray, says it means no investment by any company not already there-- but that companies now there can expand. Does Mr. Gray really mean to protect the companies now there from any further American competition? Did the House realize it was creating, at least among American companies, a kind of franchise for those now in South Africa? Evidently not.

This language was pasted into the bill to extend the Export Administration Act, which now contains several other similarly well-intentioned provisions. One would apply the Sullivan code to American companies in South Africa, and give the U.S. government the legal authority to enforce it. Legal authority is one thing; practical means are another. The Sullivan principles apply a simple and clear rule of justice to labor relations in a society that has turned racial discrimination into an obsession. Some of the American companies operating there try to follow the Sullivan code voluntarily. South Africa would be a better place if they all did.

But to enact it into a law that applies only in one not very friendly foreign country raises questions to which nobody in the House has any very plausible answers. Who's going to monitor compliance? What happens when the Sullivan code conflicts with South African law?

Congress has repeatedly tried in recent years to impose American legal standards abroad. The South Africa amendments are hardly the most important example of the extraterritorial impulse in the Export Administration Act extension. It has been bogged down all year in the aftermath of the Reagan administration's failed attempts to force the Western Europeans to back out of their gas pipeline project with the Soviet Union. Since this kind of sanction has been notably unsuccessful in the past as a means of changing other countries' policies, there is an unreal quality to the debate. But it goes on with undiminished vehemence.

As for the South Africa amendments, it's possible to argue that even if unenforceable they won't do any harm. So why not pass them? The trouble with unenforceable political gestures is that they divert effort from the kinds of slow and unspectacular work that might actually make a difference.