We are in the process of migrating from Native COBOL to JVM Cobol but that is a long process. We have a situation in prod where we need to signal a problem from several call levels down all the way back to the top level. In Jvm COBOL, we can use Raise (the equivalent of Throw in Java) to signal this and Catch the situation at the top level.
Is there any way to do something like this with NATIVE COBOL.
JVM Cobol Example
Top Level Program
$set ooctrl"+p-f"
$set SOURCEFORMAT"VARIABLE"
program-id. aptest01.
environment division.
configuration section.
repository.
class Ex as "java.lang.Exception"
.
data division.
working-storage section.
procedure division.
1000-main.
TRY
call 'aptest02' using 'A'
call 'aptest02' using 'B'
call 'aptest02' using 'C'
CATCH e as Ex
display 'Exception'
END-TRY.
goback.
Called Program
$set ooctrl"+p-f"
$set SOURCEFORMAT"VARIABLE"
program-id. aptest02.
environment division.
configuration section.
repository.
class Ex as "java.lang.Exception"
.
data division.
working-storage section.
77 e Ex.
linkage section.
77 prm pic x.
procedure division using prm.
display prm.
if prm = 'B'
invoke Ex "new" using "Test Exception" returning e
raise e
end-if.
goback.