The RETURN command passes control to the next higher level. When the program is at the highest logical level under CICS (level 1), the RETURN command will pass the control back to CICS.
EXEC CICS RETURN [TRANSID(next-id)] [COMMAREA(comm-area)] [LENGTH(length)] END-EXEC.
Specifies the next transaction identifier to be executed from the terminal associated with the current transaction. This is the transaction that is executed the next time that terminal sends input. This can be issued only by transactions at the logical level 1.
An optional parameter. It is the name of the area containing the data to be passed to the next transaction that will be executed at that terminal. LENGTH specifies the length of the COMMAREA.
When control is passed back to CICS, two additional options to the RETURN command can be specified:
Next transaction can be specified to be executed when the next input comes from the same terminal. This option is used to develop applications in pseudo conversational mode which will be discussed shortly.
Data to be passed to the next transaction can be specified.
Sub program has just issued a RETURN without any options as below.
EXEC CICS RETURN END-EXEC.
For example, If some data needs to be send back to the calling program, it can be passed back via commarea. For this required data needs to be filled in DFHCOMMAREA before issuing the return.
MOVE WW-CUST-DATA TO DFHCOMMAREA. EXEC CICS RETURN END-EXEC.
EXEC CICS RETURN TRANSID(WS-TRAN-ID) COMMAREA(WS-COMM-AREA) LENGTH(WS-COMM-LGTH) END-EXEC.
This option is generally used in programs where screens are involved. Once the initial screen sends the control back on to the screen and when the user enters any attention identifier keys the specified transaction id gets active and the commarea sent would be used in that process.
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!