The problem has been solved.
The corrected Hal code looks as follows:-
// VER: 5.4 080912
// UST: 23.09.2008 (update)
// VER: 5.3 071214
// UST: 10.01.2008
global
procedure DoRunCMForm(record RcVc Dummyr,record RcVc RepSpec)
begin
string 30 formcode;
boolean testf;
formcode = "INVOICE";
LogText(0,"Before OpenForm 0");
// FormLabelGrid(1,1,1,1);
LogText(0,"Before OpenForm 1");
testf = (OpenForm(formcode)==true);
CloseForm;
LogText(0,"After OpenForm: " & testf);
return;
end;
global
procedure RunCMForm(record RcVc RepSpec)
BEGIN
boolean tmpf;
tmpf = PrintDocument(RepSpec,"RunCMForm",false);
LBH_StockMovLabelForm:;
RETURN;
END;
So the procedure with openform() in it has to be called via PrintDocument()
tmpf = PrintDocument(RepSpec,"RunCMForm",false);