Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 11: CICS Error Handling and Debugging


HANDLE AID

Terminals talk to CICS programs with attention keys: ENTER, CLEAR, the PF keys, and the PA keys. HANDLE AID tells CICS which paragraph should run when the user presses each key. It is how a conversational or pseudo-conversational program reacts to PF3 = exit, PF12 = cancel, PA1 = refresh, and so on.

What is HANDLE AID

  • AID stands for Attention Identifier. Every attention key has one: ENTER, CLEAR, PA1, PA2, PA3, PF1 through PF24.
  • Syntax: EXEC CICS HANDLE AID PF3(1000-EXIT-PARA) PA1(1100-REFRESH) END-EXEC.
  • Like HANDLE CONDITION, it stays active for the rest of the task once issued, until changed or the task ends.
  • When the user presses a handled key on the next RECEIVE MAP, control branches to the coded paragraph instead of continuing after the RECEIVE.

Common AID keys and their use

  • ENTER - the normal submit key. Usually no HANDLE AID is needed; the program just continues after RECEIVE MAP.
  • CLEAR - often handled to redisplay a fresh screen or to exit cleanly instead of abending with a map error.
  • PF3 / PF12 - the standard exit and cancel keys in most shops. Handle them to end the transaction gracefully.
  • PA1 / PA2 / PA3 - program access keys, often used for refresh, help, or interrupt functions.
  • You can also read the key that was pressed from the EIBAID field after RECEIVE, and branch with an EVALUATE instead of using HANDLE AID.

Example: handling PF and PA keys

  • The example below branches to different paragraphs based on the key pressed:
    PROCEDURE DIVISION. 0000-MAIN. EXEC CICS HANDLE AID PF3(8000-EXIT-TRAN) PF12(8000-EXIT-TRAN) PA1(8100-REFRESH-SCREEN) CLEAR(8100-REFRESH-SCREEN) END-EXEC. EXEC CICS SEND MAP('CUSTMAP') MAPSET('CUSTSET') ERASE END-EXEC. EXEC CICS RECEIVE MAP('CUSTMAP') MAPSET('CUSTSET') INTO(CUSTMAP-IN) END-EXEC. PERFORM 2000-PROCESS-INPUT. EXEC CICS RETURN END-EXEC. 8000-EXIT-TRAN. EXEC CICS SEND TEXT FROM('TRANSACTION ENDED') LENGTH(17) ERASE END-EXEC. EXEC CICS RETURN END-EXEC. 8100-REFRESH-SCREEN. EXEC CICS SEND MAP('CUSTMAP') MAPSET('CUSTSET') ERASE END-EXEC. EXEC CICS RETURN TRANSID(EIBTRNID) COMMAREA(WS-COMMAREA) END-EXEC.

HANDLE AID or EIBAID test

  • Use HANDLE AID when each key needs very different processing in its own paragraph. It keeps the mainline clean.
  • Use an EIBAID test after RECEIVE when the key handling is short, for example a small EVALUATE that sets a flag. Both styles are valid.
  • Remember that unhandled AID keys simply continue after RECEIVE. If PF3 is not handled, pressing it behaves like ENTER unless the map defines otherwise.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant