Hi, the correct statement should be IF udiCmpId = 0 THEN so that it will called once at the beginning