We read the correspondence between you and the local distributor and they have given you some advice which will also illustrate again below:
It could be a Watch Dog Timer reset if your program ends up in an endless goto loop and could not leave the custom function. That is a software related issue.
To verify if it is your software giving problem, transfer a different program, or a blank program and set a few outputs, then wait and if the PLC does not reset, then it is confirmed to be your programming issue. If it does reset itself even with a blank program, then there are a few possibilities:
1) bad power supply
2) severe electrical noise interfering with the CPU.
3) faulty PLC hardware.
You can remove the PLC from the control panel and put it on the bench power supply to test the behavior in order to isolate the cause.