diff --git a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt index 334a9ce63..3d314b972 100644 --- a/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt +++ b/rpgJavaInterpreter-core/src/main/kotlin/com/smeup/rpgparser/parsing/ast/statements.kt @@ -606,7 +606,20 @@ data class CallStmt( val callStatement = this val programToCall = interpreter.eval(expression).asString().value.trim() MainExecutionContext.setExecutionProgramName(programToCall) - val program = interpreter.getSystemInterface().findProgram(programToCall) + val program: Program? + try { + program = interpreter.getSystemInterface().findProgram(programToCall) + if (errorIndicator != null) { + interpreter.getIndicators()[errorIndicator] = BooleanValue.FALSE + } + } catch (e: Exception) { + if (errorIndicator == null) { + throw e + } + interpreter.getIndicators()[errorIndicator] = BooleanValue.TRUE + return + } + require(program != null) { "Line: ${this.position.line()} - Program '$programToCall' cannot be found" } @@ -659,6 +672,9 @@ data class CallStmt( System.currentTimeMillis() - startTime ) } + if (errorIndicator != null) { + interpreter.getIndicators()[errorIndicator] = BooleanValue.FALSE + } } } catch (e: Exception) { // TODO Catch a more specific exception? interpreter.log { diff --git a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt index 474bda400..000811a4c 100644 --- a/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt +++ b/rpgJavaInterpreter-core/src/test/kotlin/com/smeup/rpgparser/evaluation/SmeupInterpreterTest.kt @@ -178,6 +178,15 @@ open class SmeupInterpreterTest : AbstractTest() { assertEquals(expected, "smeup/T40_A10_P07".outputOf()) } + @Test + fun executeT20_A10_P05() { + val expected = listOf( + "1", + "0" + ) + assertEquals(expected, "smeup/T20_A10_P05".outputOf()) + } + @Test fun executeT02_S10_P01() { val expected = listOf( diff --git a/rpgJavaInterpreter-core/src/test/resources/smeup/T20_A10_P05.rpgle b/rpgJavaInterpreter-core/src/test/resources/smeup/T20_A10_P05.rpgle new file mode 100644 index 000000000..42beb7b62 --- /dev/null +++ b/rpgJavaInterpreter-core/src/test/resources/smeup/T20_A10_P05.rpgle @@ -0,0 +1,15 @@ + D £DBG_Str S 2560 Stringa + D TXT S 10 + * Test indicator 35 activation when CALL non existent pgm + C CALL 'XXXXXX_YY' 35 + C EVAL £DBG_Str=%CHAR(*IN35) + C £DBG_Str DSPLY + * + C EVAL TXT='PING' + C CALL 'ECHO_PGM' 35 + C PARM TXT + C + C EVAL £DBG_Str=%CHAR(*IN35) + C £DBG_Str DSPLY + * + C SETON LR