Terminate statement in Natural

Hi All,

This is my first topic in forum…

As we can code TERMINATE to terminate a program conditionally (usually) is there any statements that can be used to restart a natural program after termination by a TERMINATE statement?

E.g.

At Line No 2000:
IF #REC-TYPE NE ‘D’
TERMINATE 99
ELSE

END-IF

Can we restart the same program after the conditional statement when executing for 2nd time (not from the top).

Thanks,

Rohan Joseph.

No, but you can code this:

If not restart
<lines before line 2000
end-if
At Line No 2000:
IF #REC-TYPE NE ‘D’
TERMINATE 99
ELSE

END-IF

The TERMINATE statement exits from Natural. If you simply want to restart this program from the top, you might use the FETCH command (which can transfer control to any program, including itself).

A common approach to restart is to use ET data (see the END TRANSACTION / GET TRANSACTION DATA statements). At the start of the program, you would use the GET TRANSACTION DATA statement to retrieve the last full state of the program, which would include some information about where the program should restart - where in the data processing the program successfully reached before it was terminated (for any reason - TERMINATE, abend, etc)

Thanks Kelly…

But as per my little knowledge, After the termination of the Natural session, the program whose name is specified with the profile parameter PROGRAM will receive control. So how is this Get Transaction come in to the picture here?

Thanks,
Rohan.

Please note - what you can specify in PROGRAM is not a Natural program. It can be e.g. a cobol pgm. Or it can be another Natural session and to this Natural session you can STACK a Natural program.

The previous Natural session does an END TRANSACTION stmt with some restart data of your choice:
END TRANSACTION

Thanks a lot Mogens for your precious time…