View previous topic :: View next topic |
Author |
Message |
lal Beginner
Joined: 21 Oct 2003 Posts: 70 Topics: 25
|
Posted: Tue Jul 05, 2005 12:57 pm Post subject: CICS Questions |
|
|
Hi All,
I was analysing some CICS programs in our installation and I have some questions to be clarified.
1)
To implement the pseudo-conversational techniques..we are sending the map and returning the control back to CICS and initiating other transaction which is fine..but my question why is that they are having an extra EXEC CICS RETURN END-EXEC statement ???
E200-SEND-MAP.
EXEC CICS SEND MAP ('MENUMAP')
CURSOR ERASE
END-EXEC.
EXEC CICS RETURN
TRANSID('INVO')
COMMAREA(WS-COMMAREA)
LENGTH(WS-COMMAREA-LENGTH)
END-EXEC.
EXEC CICS RETURN
END-EXEC.
2)
We know that, when one program transfers control to another using XCTL, the first program is considered terminated, and the second program operates at the same level as the first...by my question here is
it necessary to have a GOBACK statement ???
X100-VALIDATE-PARA.
IF EIBAID = DFHPF12
OR EIBCALEN = ZEROS
PERFORM E400-XCTL-ACTION-RTN THRU E400-EXIT
GOBACK
ELSE
NEXT SENTENCE.
...
...
...
E400-XCTL-ACTION-RTN.
EXEC CICS XCTL
PROGRAM('ACTION')
COMMAREA(WS-COMMAREA)
LENGTH(WS-COMMAREA-LENGTH)
END-EXEC.
E400-EXIT.
EXIT.
Thanx in advance for clarifying doubts,
Lal |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Tue Jul 05, 2005 1:53 pm Post subject: |
|
|
lal,
Quote: |
we are sending the map and returning the control back to CICS and initiating other transaction which is fine..but my question why is that they are having an extra EXEC CICS RETURN END-EXEC statement ???
|
Sending a MAP does not return the control to CICS. It just returns to the application program. RETURN command returns control from an application program either to an application program at the next higher logical level, or to CICS. It is similar to GOBACK in regular cobol program.
Quote: |
We know that, when one program transfers control to another using XCTL, the first program is considered terminated, and the second program operates at the same level as the first...by my question here is it necessary to have a GOBACK statement ???
|
Some Programmers code both RETURN as well as a GOBACK. Once the RETURN command is excueted , the Goback will never excuete. So it is kind of redundant having a RETURN and GOBACK. Another Way of having both RETURN & GOBACK is if your shop has both CALL as well as XCTL commands in the same program. If you CALL a routine, this routine should use GOBACK. If the routine executes instead of GOBACK a RETURN, control goes 1 layer up from CICS perspective. Eg. If A is the first program within a transaction, makes CALL to B and B executes RETURN, task will be finished as control goes back to CICS. If A makes a LINK to B, B CALLS C and C executes Return, control goes back to A.
Here is a summary of terminating programs in CICS/COBOL
CICS Cobol Program Termination.
For CICS programs you can terminate the program in more ways than a batch program.
You can terminate a program with an EXEC CICS XCTL command. The program that issues the XCTL will stop running and the named program will start. Control will not return to the original program.
STOP RUN and GOBACK can be used in CICS Cobol Programs (depending on the version of the Compiler). They are both equivalent to an EXEC CICS RETURN (without the TRANID option).
EXEC CICS RETURN will transfer control back to whatever called it - either another program or CICS itself. Using the TRANID option lets you specify a CICS transaction Id, to which control will be passed.
Cobol Program Termination
The most common way to terminate a batch program is to use a STOP RUN or GOBACK.
A STOP RUN in a program will terminate the run unit - all processing will stop, so a STOP RUN in a called program will stop the program that called it as well.
GOBACK will stop the current program running - in a called program, control will return to the calling program which will continue with the next statement after the CALL verb.
EXIT PROGRAM does the same as a GOBACK, but with subtle differences:
GOBACK and EXIT PROGRAM both allow you to specify an exit point from a COBOL program, usually they are used to exit a program that has been CALLed from another program . Normally you won't notice any difference between the two methods of leaving a program.
When GOBACK or EXIT PROGRAM is executed in a CALLed program control is returned to the CALLing program.
The difference occurs when EXIT PROGRAM appears in a program that has not been CALLed by another program. In this case the EXIT PROGRAM is ignored, and processing continues. This can cause all sorts of problems, so you should use GOBACK instead of EXIT PROGRAM
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
lal Beginner
Joined: 21 Oct 2003 Posts: 70 Topics: 25
|
Posted: Tue Jul 05, 2005 2:24 pm Post subject: |
|
|
Hi Kolusu,
Thanx for your quick response. Sorry I would like to get specific answers to my question
1) I know that sending MAP doesn't return control to CICS but returns to the application program.
But my question was why is the extra EXEC CICS RETURN END-EXEC statment after the first
EXEC CICS RETURN
TRANSID('INVO')
COMMAREA(WS-COMMAREA)
LENGTH(WS-COMMAREA-LENGTH)
END-EXEC.
2) You explanied very well about the CICS COBOL/COBOL program termination, thank u very much. But my question was
once we execute E400-XCTL-ACTION-RTN THRU E400-EXIT para which does an XCTL, is it necessary to code an
GOBACK/RETURN for that matter after XCTL is issued???.
Sorry if I was not specific in my queries.
Regards,
Lal |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed Jul 06, 2005 6:07 am Post subject: |
|
|
lal,
Your return statements are different. One is returning to a transaction named 'INVO' and the other is returning to CICS. Based on the logic in your pgm , the pgm either returns the control to the transaction named INVO or to CICS.
Quote: |
But my question was once we execute E400-XCTL-ACTION-RTN THRU E400-EXIT para which does an XCTL, is it necessary to code an GOBACK/RETURN for that matter after XCTL is issued???.
|
An XCTL lets the to run the new program at the same logical level. The Old program which issued the XCTL is just released from the main storage. It is a standarad/good method to return the control to CICS. So you DO need a GOBACK/RETURN even after XCTL is issued.
Hope this helps...
Cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
lal Beginner
Joined: 21 Oct 2003 Posts: 70 Topics: 25
|
Posted: Wed Jul 06, 2005 9:14 am Post subject: |
|
|
Hi Kolusu,
Thanx for your response. Yes its true that control is returned
to a new transaction(with first return) and to the CICS(with the second return).
But these two return statments are in the same program and same paragraph and are back to
back(I have just copied the code from the program).
According to my understanding once we return the control to the CICS the current
task is ended and later if we want we can initiate a new task (which they are doing here with the first return
statement by initiating a new task for transaction 'INVO'). If my understanding is true till now..then there is no
need of the second return statment. Is it true???
E200-SEND-MAP.
EXEC CICS SEND MAP ('MENUMAP')
CURSOR ERASE
END-EXEC.
EXEC CICS RETURN
TRANSID('INVO')
COMMAREA(WS-COMMAREA)
LENGTH(WS-COMMAREA-LENGTH)
END-EXEC.
EXEC CICS RETURN
END-EXEC.
Thanx..
Lal |
|
Back to top |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Thu Jul 07, 2005 10:45 am Post subject: |
|
|
lal,
Both the second RETURN and the GOBACK in your two cases are redundant and not needed. In fact, they are never executed.
I guess, somebody just put them there because he was not that clear on transaction and task control and wanted to be on the safe side.
Regards,
Manas |
|
Back to top |
|
|
lal Beginner
Joined: 21 Oct 2003 Posts: 70 Topics: 25
|
Posted: Thu Jul 07, 2005 11:59 am Post subject: |
|
|
Thanx Manas Biswal ... I was expecting the answer you gave...
Regards,
Lal |
|
Back to top |
|
|
|
|