We want to define a trigger program "FUNIB" associated to a PF "FILE1". This "FUNIB" is defined to be called BEFORE an INSERT operation.
In that program they will make validations before the record is inserted in "FILE1".
One of the validations can have as a result the NOT creation (inhibition) of the intended record insertion defined by the trigger.
So the question is : Is it possible to inhibit the triggered INSERT operation in the BEFORE program defined at the PF level? If yes how?
CA 2E 8.7.x
In order to accomplish this, we need to populate the P0RTN variable of the Trigger function and send it to the caller. To do that first, we need to populate the "PGM.*Return code" with an error and then we need to call the "*EXIT PROGRAM" 2E built-in function in the "*Built in functions" file and populate the "*Return code" of "*EXIT PROGRAM" with the "PGM.*Return code".
It will populate the P0RTN value and send it to the caller and then the system will NOT create (inhibition) of the intended record insertion defined by the trigger.
The sample action diagram for this is:
> TRGFUN
.--
. PGM.*Return code = CND.*User QUIT requested
. Exit program - return code PGM.*Return code
'--
Generated Source:
*
* TRGFUN
C MOVEL 'Y2U9999' W0RTN
C MOVEL W0RTN P0RTN /* Which will populate the P0RTN value */
C EXSR ZYEXPG /* this will make the current program exit and send the P0RTN error return code to the caller */