All outstanding issues holding up a Namibian settlement--except for South Africa's U.S.-backed demand that Cuban troops first leave neighboring Angola--have been resolved in talks between U.N. Secretary General Javier Perez de Cuellar and the South African government, both sides announced today.

The issue of the Cubans--long the major obstacle to an agreement--was not discussed, Perez de Cuellar said, because it fell outside his Security Council mandate to try to break the deadlock in the drawn-out negotiations being conducted by a U.S.-led "contact group" of western nations.

Perez de Cuellar said he thus still could not give a date when an agreement on independence for the South African-administered territory of Namibia would be implemented. But he added that "substantial progress" had been made in the two days of talks, which he said had been more cordial than previous negotiations between South Africa and the United Nations.

After the two days of talks in Cape Town, Perez de Cuellar flew here for visits to the war zone and border settlements in northern Namibia.

South African Foreign Minister Pik Botha said there had been "complete agreement" on all issues other than the Cuban troops--including the composition of a U.N. transition group, a Namibian electoral system and the impartiality of the United Nations to supervise the transition, which South Africa earlier had questioned.

But Botha emphasized that his country was still "irrevocably committed" to removal of the Cubans from Angola before Namibian independence.

Despite the studied avoidance of the main obstructive issue, western observers said they felt encouraged.

They said that since Perez de Cuellar's mission had removed all current secondary obstructions, it should be possible for a settlement to proceed if U.S. efforts to resolve the Cuban issue in negotiations with Angola succeed.

This mood of hopefulness was boosted later in the day when Prime Minister Pieter W. Botha set Nov. 2 as the date for a referendum on proposed reforms to South Africa's constitution.

It is widely believed in South Africa that Pieter Botha has been reluctant to commit himself to a Namibian settlement before completing these changes to the segregationist system called apartheid. Although the proposed changes are small, they have caused a backlash among Botha's white Afrikaner supporters.

The prompt agreement reached in the talks enabled Perez de Cuellar and his seven-man delegation to leave for Namibia a day ahead of schedule.

This is the first visit by a U.N. secretary general to the territory that has occupied its attention for 35 years and that South Africa continues to administer despite U.N. declarations that it does so illegally.

Perez de Cuellar is risking controversy by using his extra time to fly with his South African hosts to the war zone in northern Namibia, where South African troops are fighting guerrillas of the black nationalist Southwest Africa Peoples Organization (SWAPO).

He flew tonight to Etosha Pan, a game reserve on the edge of the war zone. Thursday he is scheduled to visit Ruacana on the Angolan border, where there have been a number of skirmishes. He then will return to Windhoek for meetings with leaders of internally based Namibian political parties.

He is to fly to Luanda, Angola, on Friday for meetings with the Angolan government and the SWAPO president, Sam Nujoma.

In an interview on the flight from Cape Town today, Perez de Cuellar said that the talks had been cordial and that he had found the South Africans "less reserved" than previously.

"I did not expect a breakthrough," he said, "but I think we made meaningful progress, and I say that as someone with a reputation for making sober assessments.

"They did not raise any new objections. There were no surprises. I really don't think there are any problems left as far as the settlement agreement itself is concerned."

He and other members of his party, however, retain an underlying skepticism. Often over the years of negotiations, hopes have risen only to be dashed.

Adding to the underlying skepticism is the fact that the rebel National Union for the Total Independence of Angola (UNITA), generally said to be supported by South Africa, is waging a major offensive in southern Angola.

This threat to the government in Luanda is seen as making it unlikely that Angola would agree to dispense with the estimated 30,000 Cuban troops bolstering its hard-pressed Army.

But Pik Botha heatedly denied a suggestion made at a press conference today that his country has instigated the rebel offensive to ensure that the Cubans stayed and a Namibian settlement remained blocked.

Botha said he accepted that the Cuban issue fell outside Perez de Cuellar's mandate, but he said he had explained South Africa's insistence on it to him "in great detail."

Describing the talks as "useful and positive," Botha said: "We have today resolved all the outstanding issues within the framework of the understanding with the United States and the western contact group."

He explained that this included agreement by South Africa on the "vexed question" of the composition of a U.N. military force to keep the peace in Namibia during the transition to independence.

South Africa had objected to the inclusion of a Finnish contingent. This was because Finnish missionaries have a long historical association with Namibia, and South Africa contends their church is identified with SWAPO. But today Botha said South Africa now agreed to a Finnish contingent being included.

On the issue of Namibian voting, Botha said an electoral system would be chosen by the South African administrator general in Namibia and communicated to the United Nations as soon as a date for implementation was set.

South Africa's general complaint that the United Nations is too partial to play a key role in overseeing the transition of Namibian independence was based on General Assembly resolutions recognizing SWAPO as the "sole authentic voice of the people of Namibia."

Asked about this today, Botha replied: "It is no longer an issue."

Perez de Cuellar said he accepted that the Cuban issue was "a reality politically," but he could not accept it as a condition for implementing the settlement agreement.