Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Called program sends a map !

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS
View previous topic :: :: View next topic  
Author Message
rackshit

New User


Joined: 19 Dec 2009
Posts: 16
Location: Mumbai

PostPosted: Fri Sep 23, 2011 3:21 am    Post subject: Called program sends a map !
Reply with quote

Hi,

Please see the following image,



which shows the various Flow of control between COBOL programs, run units, and CICS.

Based on this I have some questions:

Question1:

What will happen if in Program Y, a statement SEND MAP (MENU) is encountered and the program Y has the following statements at the end of the program

Code:

EXEC CICS
            RETURN TRANSID(‘MENU’)
            COMMAREA(COMMUNICATION-AREA)
END-EXEC


TRANSID-MENU is associated with program Y.

In the second run will the Program Y or Program W or Program U be executed ?
icon_rolleyes.gif icon_rolleyes.gif

Assume: program control flow reaches program Y



Question 2:

Suppose Program W has following send map which is executed

Code:
SEND MAP (MENW)


and at the end of program W, the following statements are present

Code:

EXEC CICS
            RETURN TRANSID(‘MENUW’)
            COMMAREA(COMMUNICATION-AREAW)
END-EXEC

TRANSID-MENUW is associated with program W.

In the second run will the Program W or Program U be executed ?

Thanks in advance !
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Sep 23, 2011 4:28 am    Post subject: Reply to: Called program sends a map !
Reply with quote

RETURN TRANSID can only be issued when a program is at Logical Level 0. If it's issued from a non Logical Level 0 program, an INVREQ condition will be raised.

You can issue a SEND MAP from a non Logical Level 0 program.

All CICS/COBOL programs should have a CICS RETURN followed by a GOBACK. All sub-programs that are CALLED as opposed to LINK-TO, should terminate with a GOBACK and not a RETURN.

Inasmuch as a STOP RUN (according to IBM) can be used, I'd stick with the GOBACK (I'm a creature of old habits).

When I was coding and a given sub-program was CALLED as opposed to LINKED-TO, I would issue a GOBACK to return to the Caller.

You can tell if a program had been Called or Linked-To by checking (as the first line of code), whether EIBRSRCE equals or does NOT equal the sub-program name. When equal, then the program had been accessed via a LINK-API.

Keep in mind that because a CALL is outside of the scope of CICS API's, the Logical Level doesn't change, as opposed to a LINK-API. Of course, an XCTL-API is a horizontal move and therefore the current Logical Level remains.

Also (last time I looked), WS in a Called sub-program is not freed until Task Termination as opposed to a LINK-API, whose storage is freed upon return to the Linker.

When storage is freed at the return of a sub-program who had been Linked-To, this is recognized as the termination of an LE Enclave.

You can find all of these interesting tidbits in a transaction dump with a trace or a standalone trace.

Mr. Bill
Back to top
View user's profile Send private message
rackshit

New User


Joined: 19 Dec 2009
Posts: 16
Location: Mumbai

PostPosted: Fri Sep 23, 2011 9:23 am    Post subject:
Reply with quote

Thanx Bill.

Quote:
You can issue a SEND MAP from a non Logical Level 0 program.


So if we do a SEND MAP from non logical level 0 then in the next pseudoconversational run of the transaction the program flow will start from the logical level 0 program ?

And in the below level 0 program
Code:

PROCEDURE DIVISION.

.
.
.
.

SEND-MAP SECTION.


EXEC CICS
SEND MAP
END-EXEC

.
.
.
.




EXEC CICS
RETURN TRANSID(XXXX)
COMM-AREA(COMMUNICATION-AREA)
END-EXEC.




The control never reaches to RETURN verb, since SEND MAP sends the map and RETURN is never executed, then how does CICS come to know that it has to return the control to TRANSID XXXX when running it second time in pseudoconversational program? Is this thing internal to CICS?

Thanks in advance.
Back to top
View user's profile Send private message
Eshwar CICS

New User


Joined: 18 May 2011
Posts: 47
Location: India

PostPosted: Fri Sep 23, 2011 12:49 pm    Post subject:
Reply with quote

Bill,

I have seen RETURN TRANSID issued by the programs not executing at logical level 0 (I believe CICS gets executed at logical level 0) & they work properly. Please correct me if there is a mistake in my understanding.
Back to top
View user's profile Send private message
Eshwar CICS

New User


Joined: 18 May 2011
Posts: 47
Location: India

PostPosted: Fri Sep 23, 2011 12:54 pm    Post subject:
Reply with quote

rackshit,

In your supplied code, RETURN executes after the SEND MAP. Let us know, Why do you think RETURN will not execute?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Sep 23, 2011 4:23 pm    Post subject:
Reply with quote

Eshwar CICS wrote:
Bill,

I have seen RETURN TRANSID issued by the programs not executing at logical level 0 (I believe CICS gets executed at logical level 0) & they work properly. Please correct me if there is a mistake in my understanding.

Unless Hursley-Park has recently eased up on internal restrictions, I don't believe with certainty RETURN TRANSID at a non Logical Level 0 will execute without error as a RETURN TRANSID has always implied/signaled Task Termination.

I'd be surprised if this restriction has been lifted....

Mr. Bill
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Fri Sep 23, 2011 4:54 pm    Post subject:
Reply with quote

The CICS Application Programming Reference manual says this about RETURN:
Quote:
TRANSID(name)
specifies the transaction identifier (1-4 characters) to be used with the next input message entered from the terminal with which the task that issued the RETURN command has been associated. The specified name must have been defined as a transaction to CICS.

If TRANSID is specified for a program running on a terminal that is defined with a permanent transaction ID, the terminal's permanent transaction is initiated next rather than the transaction specified on the RETURN.

If you specify a TRANSID of binary zeros, the transaction identifier for the next program to be associated with the terminal may be determined from subsequent input from the terminal. Issuing a RETURN with a TRANSID of binary zeros and a COMMAREA can cause unpredictable results if the next transaction is not coded to handle the COMMAREA or if it receives a COMMAREA not intended for it.

If you specify TRANSID on a program that is not at the highest level, and there is a subsequent error on COMMAREA or INPUTMSG on the final RETURN, the TRANSID is cleared.

The next transaction identifier is also cleared on an abnormal termination of the transaction.

If IMMEDIATE is specified with this option, control is passed to the transaction specified in the TRANSID option in preference to any transactions enqueued by ATI.

If IMMEDIATE is not specified with this option, an ATI initiated transaction of the same name enqueued to the terminal nullifies this option.

This option is not valid if the transaction issuing the RETURN command is not associated with a terminal, or is associated with an APPC logical unit.
which indicates CICS will allow a RETURN TRANSID at non Logical Level 0. This would be poor system design, however, as it allows for multiple ways to exit a module.
Back to top
View user's profile Send private message
Eshwar CICS

New User


Joined: 18 May 2011
Posts: 47
Location: India

PostPosted: Fri Sep 23, 2011 5:22 pm    Post subject: Reply to: Called program sends a map !
Reply with quote

All our CICS application programs execute starting at Level 1, Level 2 etc...coding of RETURN command always happens in our application programs...how can we code it at level 0? and how coding of it at non zero logical level is considered as poor design?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Fri Sep 23, 2011 5:29 pm    Post subject:
Reply with quote

Modular coding mandates one entry and one exit point per program. If the program was entered on logical level 2, for example, via a CICS LINK then the exit should be via CICS RETURN to go back to level 1. Having a CICS RETURN TRANSID in the program allows the module to have two exits.

And note that EXEC CICS RETURN and EXEC CICS RETURN TRANSID have very different outcomes -- another case where terminology is so critical to IT.
Back to top
View user's profile Send private message
Eshwar CICS

New User


Joined: 18 May 2011
Posts: 47
Location: India

PostPosted: Fri Sep 23, 2011 5:33 pm    Post subject: Reply to: Called program sends a map !
Reply with quote

RETURN with trans-id can be coded at logical level 1 (non zero logical level)...i doubt if it is considered a bad design.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Fri Sep 23, 2011 6:00 pm    Post subject: Reply to: Called program sends a map !
Reply with quote

Robert,

Yes, should have checked the doc rather than to rely upon my memory. icon_rolleyes.gif

But, I agree that it can be somewhat confusing to code the RETURN TRANSID at a non Logical Level 0.

Began coding CICS command in the mid-70's (CICS/OS 1.4) and always issued a RETURN TRANSID at Logical Level 0. To this day (if I was still coding), I'd do the same (agreed, one entry/one exit).

With that, issuing the RETURN TRANSID at a non Logical Level 0; just because you CAN doesn't mean you SHOULD. icon_wink.gif

Mr. Bill
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Sep 23, 2011 6:29 pm    Post subject:
Reply with quote

Quote:
RETURN with trans-id can be coded at logical level 1 (non zero logical level)...i doubt if it is considered a bad design.


is like using a GO TO when one can not properly code functional/modular logic.

it is just a short-cut when one is being lazy and does not want to properly extend the modular construct of a module/sub-system.

it prohibits any future extension.
Back to top
View user's profile Send private message
Eshwar CICS

New User


Joined: 18 May 2011
Posts: 47
Location: India

PostPosted: Fri Sep 23, 2011 7:18 pm    Post subject:
Reply with quote

how RETURN TRANS-ID (or any other CICS command) can be coded at level 0.....when application programs triggered by transaction in CICS environment start at Level 1
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Sep 23, 2011 7:27 pm    Post subject:
Reply with quote

Eshwar CICS wrote:
how RETURN TRANS-ID (or any other CICS command) can be coded at level 0.....when application programs triggered by transaction in CICS environment start at Level 1


yadadadada,

point was being made that the RETURN should be issued at the same level as invokation.

if point was lost at lvl/0,lvl/1 or whatever,
then of course you are correct. (as if anybody cares, except you of course)
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Sep 23, 2011 7:53 pm    Post subject:
Reply with quote

Hello,

Quote:
i doubt if it is considered a bad design.
People who do good work do consider this a bad design. Just because something can be done does not make it "good".

Beginner's doubts should not weigh as heavily as senior developers. . .

Suggest you do lots of research and get to an understanding of why this is a bad design.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Sep 23, 2011 9:27 pm    Post subject: Reply to: Called program sends a map !
Reply with quote

Eshwar CICS,

So it was an old requirment. No, then, no point in starting a new topic.

What you required was probably achievable (I certainly can't be exact without the details, but...) but if you want to get tied up with it being a "run-unit" and grab at the first straw to "confirm" that you and your colleagues were failing for a very good reason, go with that, have a good weekend as well.

When faced with a task I've never thought "that can only be done with XYZ like we can under QRTJ, so let's get that working in batch and then deal with the task". OK, I'm sure I'd have looked a lot cleverer at parties if I'd done that (actually, I am far from sure, but I can't see any other use for the technique except for firing blanks), but I think I'd have got less done. I'm annoyed if the later-revealed complexity of a task means it takes longer than budgeted for. I've never had a "can't be done, so we didn't do it" moment.

Why am I getting annoyed about this? Thought we'd get an interesting question before the weekend, then it turned out to be the above.

EDIT: Sorry Robert, I was typing while you were splitting.
Back to top
View user's profile Send private message
Eshwar CICS

New User


Joined: 18 May 2011
Posts: 47
Location: India

PostPosted: Fri Sep 23, 2011 9:29 pm    Post subject: Reply to: Called program sends a map !
Reply with quote

Robert,

Thanks again for making it much clear why this cannot be done in COBOL alone.
Back to top
View user's profile Send private message
rackshit

New User


Joined: 19 Dec 2009
Posts: 16
Location: Mumbai

PostPosted: Sat Sep 24, 2011 11:48 am    Post subject:
Reply with quote

Eshwar CICS wrote:
rackshit,

In your supplied code, RETURN executes after the SEND MAP. Let us know, Why do you think RETURN will not execute?


Thanks all for replies, its a good discussion and knowledge sharing.

As per my understanding, once the send map is done the control goes to CICS and when the user enters any attention key or function key, CICS sends the control to the program associated with RETURN TRANSID (XXXX). So CICS will return to that program which is mapped to TRANSID (XXXX)

It may be a non logical level 0 program. But when a send map is done, the program flow (control) never reaches the end of program where RETURN statement is coded. (this understanding i got from Murach's book, where pseudoconversational is explained). So is there a mechanism where CICS looks out for RETURN statement in the program to let it understand which program is to be invoked when user presses function key ?

Please let me know if my understanding is incorrect.

Thanks in advance.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Sep 24, 2011 3:27 pm    Post subject:
Reply with quote

from what I understand,
Murach's book
is too good a book to have made such a comment.

you are miss/reading/understanding.

if you have a pc background / visual basic / forget what you knew.
is not even remotely related to how a mainframe works.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Sat Sep 24, 2011 5:33 pm    Post subject:
Reply with quote

Quote:
But when a send map is done, the program flow (control) never reaches the end of program where RETURN statement is coded. (this understanding i got from Murach's book, where pseudoconversational is explained). So is there a mechanism where CICS looks out for RETURN statement in the program to let it understand which program is to be invoked when user presses function key ?
Your understanding is wrong. If this were the case, how could a conversational program ever work?

Once the SEND MAP has been done, the program may do whatever it needs to do -- including RETURN -- and you can easily confirm this by using CEDF on your program. You will discover that after the SEND MAP is done, your program is still running until the RETURN is executed.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CICS All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How does a called pgm know if its cal... Graeme Westerman COBOL Programming 4 Tue Nov 29, 2016 9:25 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts A sample of exit program for exit XMN... lind sh CICS 2 Mon Oct 03, 2016 5:07 pm
No new posts Need points to tune IMS Checkpoint Pr... satish.ms10 IMS DB/DC 2 Fri Sep 30, 2016 4:12 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us