Prior to devolution, the Lord Advocate and Solicitor General for Scotland were Ministers in the UK Government. Apart from his Law Officer function of advising the Government on matters of Scots law and representing it in civil proceedings, the prime responsibility of the Lord Advocate was for the prosecution of crimes and for the investigation of deaths in Scotland. As a Departmental Minister in charge of part of the Scottish Courts Administration, he was also responsible for the policy on certain matters concerned with the administration of justice, such as civil jurisdiction and procedure, evidence, diligence etc. The Solicitor General acted as his deputy under section 2(1) of the Law Officers Act 1944.
As none of these matters are reserved, the White Paper on Scotland’s Parliament stated that it was “appropriate that the Law Officers of the Scottish Executive should be the Lord Advocate and the Solicitor General for Scotland” (para. 4.8). It was therefore necessary to provide for their transfer into the Scottish Executive. This is effected by section 44 providing that the Lord Advocate and the Solicitor General are members of the Scottish Executive and that they, together with the First Minister and the Ministers appointed under section 47, are to be known collectively as the Scottish Ministers. It is also effected by this section making provision as to how they are to be appointed within the Scottish Executive and by ensuring that amendments are made consequential upon them ceasing to be Ministers of the Crown in the UK Government.
The Scottish Law Officers ceased to be members of the UK Government and became members of the Scottish Executive on 20 May 1999 by virtue of Article 2(2) of and Schedule 4 to the Scotland Act 1998 (Commencement) Order 1998 (S.I. 1998/3216).  Although there was no change in the persons who were Lord Advocate and the Solicitor General, it was still necessary for them to be appointed in terms of section 48.
When he became a member of the Scottish Executive on 20 May 1999, the Lord Advocate carried with him his existing functions as head of the systems of prosecution and investigation of deaths in Scotland.  These are part of his “retained functions” under section 52(6).
Amendments were also made to the Crown Suits (Scotland) Act 1856 by Schedule 8 paragraph 2 to enable civil proceedings, which are being brought by or against any part of the Scottish Administration (e.g. the Scottish Ministers), to be brought by or against the Lord Advocate on its behalf.
However the functions of the Lord Advocate connected with the administration of justice were transferred to the Secretary of State just before the Lord Advocate ceased to be a member of the UK Government - see the Transfer of Functions (Lord Advocate and Secretary of State) Order 1999 (S.I. 1999/678) and a written answer to a Parliamentary Question given by the Prime Minister on 22 March 1999 (H.C. Deb vol. 328 col. 9w).  These functions were then transferred on 1 July 1999 to the Scottish Ministers either under section 53 or in the Scotland Act 1998 (Transfer of Functions to the Scottish Ministers etc.) Order 1999 (S.I. 1999/1750) made under section 63 of the Act.
Certain of the functions of the Lord Advocate in relation to reserved matters were transferred to the Advocate General for Scotland, who was appointed under section 87 to provide legal advice to the UK Government on matters of Scots law under the Transfer of Functions (Lord Advocate and Advocate General for Scotland) Order 1999 (S.I. 1999/679).
Subsection (5) of the present section is one of a number of provisions which safeguard the independence of the Lord Advocate and the Solicitor General in exercising their prosecution functions. Section 29 provides that it would be outside the competence of the Parliament to legislate to remove the Lord Advocate from his position as head of the systems of criminal prosecution and investigation of deaths in Scotland. Section 27 deals with the participation of the Law Officers in the proceedings of the Parliament and includes provision for either of them to decline to provide documents or to answer questions about particular criminal cases if he considers that doing so might prejudice the proceedings in that case or would otherwise be contrary to the public interest.
Commentary Part II: the Scottish Administration General