I am just getting into mainframe development so excuse any ignorance, but is there a way to identify which map is being displayed or was last sent to the terminal?
For example, I have MAP1
& MAP2
in mapset MAPS
. The maps would alternate by the press of a PF key (PF7/PF8)
. On each map the user can enter a value to be evaluated by the program (SLCTOPTI)
. Is there a proper way to determine which map should be evaluated when receiving from the user?
Here's what I currently have to attempt this:
** some code before **
WHEN DFHENTER
+0103
%+0104 IF CURRENT-MAP-SCREEN = 1
%+0104 EXEC CICS RECEIVE
%+0104 MAP ('MAP1')
%+0104 INTO (MAP1I)
%+0104 RESP (WS-RESP)
%+0104 END-EXEC
%+0104 ELSE
%+0104 EXEC CICS RECEIVE
%+0104 MAP ('MAP2')
%+0104 INTO (MAP2I)
%+0104 RESP (WS-RESP)
%+0104 END-EXEC
%+0104 END-IF
+0103
%+0104 EVALUATE SLCTOPTI
+0103
%+0104 WHEN ' 1'
%+0104 WHEN '01'
%+0104 WHEN '1'
+0103
%+0104 MOVE 'XXXX' TO WS-START-TRAN
%+0104
%+0104 WHEN ' 2'
%+0104 WHEN '02'
%+0104 WHEN '2'
+0103
%+0104 MOVE 'XXXX' TO WS-START-TRAN
** some code after **
I'm not sure if this works yet, but I would like to know if there is already a command for this or a better way to do it.
Presuming CURRENT-MAP-SCREEN
is set to indicate which map is being sent when you send the map to the screen and is stored in your DFHCOMMAREA
, this is how I normally see it done.
Normally, the way a pseudo-conversational CICS transaction's initial program is written is to check for EIBCALEN = 0
which indicates this is the initial invocation of the transaction. EIBCALEN
(the CALEN is an abbreviation for Communication Area LENgth) is a field in the EIB
(the Execute Interface Block) which is automatically passed to your transaction's initial program (as DFHEIBLK
) and inserted into your Linkage Section
by either the precompiler or the coprocessor (whichever you are using). The EIB
contains a number of fields describing the context of your transaction.
If EIBCALEN = 0
you know to initialize your WS-COMMAREA
, send your initial map, store the indicator of which map you sent in CURRENT-MAP-SCREEN
, and EXEC CICS RETURN TRANSID(EIBTRNID) COMMAREA(WS-COMMAREA) LENGTH(...)
.
Your transaction's initial program is also automatically passed a pointer to the DFHCOMMAREA
, also automatically inserted into your Linkage Section
by either the precompiler or the coprocessor (whichever you are using). The DFHCOMMAREA
is preserved on your behalf by CICS between invocations of your transaction.
If EIBCALEN NOT = 0
you know to MOVE DFHCOMMAREA TO WS-COMMAREA
and check CURRENT-MAP-SCREEN
to see which map to RECEIVE
.
When you EXEC CICS RETURN TRANSID(EIBTRNID) COMMAREA(WS-COMMAREA) LENGTH(...)
you are providing CICS with the data to be preserved and passed back to your transaction's initial program in the DFHCOMMAREA
on its next invocation. The memory allocated for your Working-Storage and Local-Storage is freed once the EXEC CICS RETURN
happens.
It is very common for people to MOVE DFHCOMMAREA TO WS-COMMAREA
and then work with the copy of the data in their Working-Storage. If EIBCALEN = 0
you don't do this of course, there's no data to move.
Some shops try to have a 1:1 relationship between programs and maps to eliminate the need to keep track of which map is currently displayed.
Hopefully later in your studies your instructor will talk about using channels and containers instead of the DFHCOMMAREA
. The latter is how CICS applications were built for several decades so you will definitely see code written this way, the former is a newer capability.