Started tasks
In the pseudoconversational case, the ‘receive’ program is started by FEPI as a CICS started task, with a start code of 'SZ' (for FEPI) which can be checked using EXEC CICS ASSIGN STARTCODE.
FEPI supplies start data that identifies the reason for starting the task and gives information about the FEPI resources, such as the node-target connection, the data mode and format, and the conversation ID involved. The program that processes the transaction issues EXEC CICS RETRIEVE to get this data (the CICS rules relating to transactions and start data apply; in particular, you must retrieve all of the start data to prevent multiple initiations). Copy books DFHSZAPA, DFHSZAPO, DFHSZAPC, and DFHSZAPP contain declarations of the start data structure. You can provide your own data to be included in the start data, so that your programs can communicate with each other about their processing state and so on.
The first thing such a program must do is get ownership of the conversation using the conversation ID from the start data; it should then use FEPI RECEIVE to get the actual data from the back-end. Then it can do whatever it likes: end the conversation, send more data to the back-end system (and start itself or a new task to receive the reply), and so on.
In addition to inbound data arriving, anything else that would cause a FEPI RECEIVE command to complete causes the ‘receive program’ to be started. This includes a ‘previous SEND failed’ error, and a response from the back-end system without any data. The FEPI RECEIVE that you issue shows these cases, as if FEPI START had not been used.
The program is also started if the time limit set by the FEPI START command expires, or if the session is lost. These cases are indicated by the value of EVENTTYPE, in the start data, being TIMEOUT or SESSIONLOST rather than DATA. They should be handled as if a FEPI RECEIVE command had caused the error.
If your ‘send’ program is associated with a front-end terminal, your FEPI START command would normally specify that the ‘receive’ program uses the same terminal. You should be aware that it is not possible for FEPI to guarantee that another transaction will not use the terminal while the inbound data is awaited. In the majority of cases, this does not happen or does not matter. If it does happen and it is critical (perhaps for security reasons), you can prevent user input at the terminal by issuing an EXEC CICS SET TERMINAL command specifying NEXTTRANSID(itran) before issuing FEPI START; remember to reset NEXTTRANSID to blank in the started task. itran is the name of a transaction that you provide which rejects any user input, and sets NEXTTRANSID(itran) again. If this is unacceptable, you must avoid using pseudoconversational applications.
The handlers mentioned in topics on pages Begin-session handler , Unsolicited-data handler and End-session handler —begin-session, unsolicited data, end-session—are also CICS started tasks. Again, the start data (obtained with EXEC CICS RETRIEVE) tells you why the task was started and the identity of the conversation. The started task must get ownership of the conversation so that it can continue the conversation and so that FEPI knows that the event is being handled.