You can use the FAIL function to abort a map based on map or application specific logic.

FAIL (single-text-expression)
FAIL (message_to_return)

The FAIL function returns "none" to the output to which the function is assigned, aborts the map, and returns message_to_return as the map completion error message included in the execution audit. The map return code will be "30", indicating that the map failed through the FAIL function.


  • AcctID = EITHER (LOOKUP (CustomerID:.:Xref , MyKey:.:Xref = ID:.:Input ) , FAIL ( "Unknown Customer (" + ID:.:Input + "). Processing Terminated." ) )

    In this example, the FAIL function is being used in conjunction with the EITHER function to conditionally fail the map if a record in the customer cross-reference file does not exist for a given CustomerID.

    For example, the ID in Input is ABC123. If the LOOKUP succeeds, the CustomerID result is assigned to AcctID and the map continues.

    If the LOOKUP fails, AcctID is assigned a value of "none", the map aborts, and the message Unknown Customer (ABC123). Processing written to the execution audit log.

  • Message = VALID (RUN ("Map1Msg.mmc", "-AE -OMMSMQ1B `-QN .\aqueue -CID 2001'" ), FAIL ("Failure on RUN (" + TEXT (LASTERRORCODE ( ) ) + "):" + LASTERRORMSG ( ) ) )

    In this example, the FAIL function is being used in conjunction with the VALID, LASTERRORCODE, and LASTERRORMSG functions to fail (abort) the map if the map executed by the RUN function (Map1Msg.mmc) fails. In this example, the map fails and returns the error code and error message reported by the RUN function using the LASTERRORCODE and LASTERRORMSG functions.

    If Map1Msg fails because one or more of its inputs was invalid, Message is assigned a value of "none". The map aborts and the following message is reported in the execution audit log:

    "Failure on RUN (8): One or more inputs was invalid."

Related functions

  • QUIT