FANUC codes
FANUCProgram/G-codeIntermediate15-30 minutes

124

Fanuc Alarm 124 - GOTO Nesting Exceeded

Too Many GOTO Levels

Fanuc program alarm 124: Too Many GOTO Levels. The part program contains an error or illegal condition that the Fanuc control cannot execute. Correct the program to clear this alarm.

Root Cause Summary

Fanuc Alarm 124 MISSING END STATEMENT occurs when a custom macro program contains a DO loop structure that lacks its corresponding END statement. This is a syntax error in macro programming where the DO-END pairing is incomplete, preventing proper program compilation and execution. The alarm is triggered during program execution or background edit/search operations when the control detects unbalanced loop structures.

Safety

  • Macro stopped

Causes and Fixes

  1. 1

    Press EDIT mode, search for the program number that was active when alarm occurred. Check alarm history at ALARM > HISTORY screen to identify exact program number.

  2. 2

    Search the macro program for all DO statements (DO1, DO2, DO3, etc.). Count each DO instruction and verify each has a corresponding END1, END2, END3 statement matching the DO level number.

  3. 3

    Check nested DO loops carefully. Each DO level must have proper END pairing: DO1...END1, DO2...END2, DO3...END3. Maximum nesting is typically DO1 through DO3 depending on control series.

    Incorrect nesting order (e.g., DO1-DO2-END1-END2 instead of DO1-DO2-END2-END1) will also trigger this alarm.

  4. 4

    Add the missing END statement at the appropriate location in the macro program. Reset alarm with RESET key, verify program syntax by running background edit check (Parameter 3107#3=1 enables background edit), then test macro execution.

DIY Feasiblehigh confidence

Call a technician if:

  • ·Memory diagnostic tests fail
  • ·Parameter corruption suspected
  • ·Alarm persists after program correction

Prevention

  • Limit GOTO nesting to maximum 5 levels
  • Use subroutines instead of complex branching
  • Implement loop counters with maximum iteration limits
  • Regular backup of macro programs

Common Mistakes

  • Not checking for infinite loops in macro logic
  • Exceeding system GOTO nesting limits
  • Forgetting to initialize loop counter variables
  • Not testing macros in single block mode first

Related Alarms

Seeing Multiple Alarms?

Seeing another alarm with this one? Enter the code.

Get machine-aware diagnosis

AxisMD logs alarms against your actual machines, tracks patterns, and gives AI context your manual doesn't have.

Start free

Was this guide helpful?

Always verify with your machine manual or a certified technician before performing service procedures.