The M99 goes at the end of the subprogram.

I think the following is correct; I am working from memory here not having opened the engraving subprogram for many years.

However, getting into the the subprogram that is referenced by G47 is not straightforward. G47 is an alias for a subprogram number beginning with the number 9; i.e. O9nnnn. If you look in List Program you will not see any programs starting with 9 because Setting 23, 9xxxx PROGS EDIT LOCK is ON. You have to turn this Setting OFF and then you can see and select the programs starting with 9. Now you can have a look at the actual code for the engraving subprogram. To see if there are any M99 commands in the program select EDIT, type M99 and press the down cursor. If the M99 is there this will jump the display down to it, or it will display NOT FOUND if there is no M99. If it is not found you can press END to go to the end of the program and you could type M99 and enter it as the last line. Now bring the program you were using in Graphics and see if it runs okay. You may find the engraving subprogram still does not run correctly. What I think it is very likely to have happened is that whatever glitch occured when you went into background edit erased many lines of code from the G47 subprogram. But you may be lucky and it may work.

If things do not work you might find a copy of the G47 subprogram to reload on the usb drive that comes with the machine when it is purchased. When you are done remember to change Setting 23 back to ON.