The Senate finished a sixth day of debate yesterday on a landmark immigration bill but bogged down over an unrelated amendment dealing with the Social Security system.

The amendment offered by Sen. John Heinz (R-Pa.) is a nonbinding sense-of-the-Senate resolution proposing that the Social Security system not be included in the unified federal budget.

Senate Majority Leader Robert J. Dole (R-Kan.) and Sen. Alan K. Simpson (R-Wyo.), sponsor of the immigration legislation, had asked Heinz to attach the amendment to a more relevant bill. He refused.

Senate aides said the Heinz amendment may endanger the future of the immigration bill since other senators were considering offering amendments on other unrelated issues -- including economic sanctions against South Africa.

On the immigration issue, the Senate approved an amendment by Sen. Paul Simon (D-Ill.) to put a three-year cap on a controversial plan approved Tuesday by the Senate to allow an additional 350,000 foreign workers into the country to harvest perishable crops.

Simon's provision -- approved by voice vote after a procedural vote of 56 to 38 in its favor -- would end the program after three years unless Congress votes to continue it.

Meanwhile, Rep. Peter W. Rodino Jr. (D-N.J.), chairman of the House Judiciary Committee and sponsor of the House immigration bill, said he was "deeply disappointed" by the Senate vote for the agricultural "guest worker" program.

"I continue to be adamantly opposed to any massive importation of foreign agricultural labor which can seriously jeopardize the job opportunities as well as the wages and working conditions of American farm workers," he said.