4

I have a short program COBOL CICS, it's a basic CRUD. In this program I have an options, when I press F12 I want to exit, close my transaction.

I want to press F12 and the transaction close.

Can I write any command to do that in my COBOL program?

Thanks

IanPoli
  • 99
  • 8

5 Answers5

5

Assuming you have a pseudo conversational program, each time it is invoked the key pressed will be in EIBAID

the scenario you have described is documented in the Knowledge center here https://www.ibm.com/support/knowledgecenter/SSGMCP_5.5.0/applications/designing/dfhp31i.html

Hope that helps

2

EXEC CICS RETURN will end your program, but you'll still have the contents of the screen.

If you do EXEC CICS SEND CONTROL ERASE command first, and then EXEC CICS RETURN, that will finish your program and clear the screen as well.

James
  • 331
  • 2
  • 9
2

In a pseudo-conversational 3270 CICS transaction, your code normally begins by checking to see if this is "first time in" by checking to see if EIBCALEN = 0 or if EIBRESP = DFHRESP( CHANNELERR ) after an EXEC CICS GET CONTAINER if you're using containers instead of a commarea.

If this is "first time in" your code normally does some housekeeping and then an EXEC CICS SEND MAP to put your BMS map up on the 3270 device. Then your code does an EXEC CICS RETURN TRANSID(EIBTRNID) and references either your commarea or your channel.

If this is not "first time in" your code normally examines either the commarea or one or more containers in its channel and EIBAID to determine what to do next, often this is an EXEC CICS RECEIVE MAP to retrieve the field contents of the fields in the map. Your code then performs whatever business function it needs to, possibly modifying fields in the map and doing an EXEC CICS SEND MAP DATAONLY, makes appropriate modifications to either the commarea fields or fields in your container(s) and an EXEC CICS PUT CONTAINER and again does an EXEC CICS RETURN TRANSID(EIBTRNID) and references either your commarea or your channel.

If, as in your case, examining these fields indicates the user wishes to exit the transaction, your code might do an EXEC CICS SEND TEXT ERASE FREEKB where the FROM and LENGTH refer to fields containing an appropriate message indicating end of transaction. This will erase your map from the screen. Then your code would do an EXEC CICS RETURN without the TRANSID option, ending your pseudo conversation.

Note that each EXEC CICS RETURN does an implied EXEC CICS SYNCPOINT committing resources such as DB2 updates and MQ messages.

cschneid
  • 10,237
  • 1
  • 28
  • 39
2

IMO, use the copybook DFHAID to capture "Key-Press" or attention. After receiving the map, check for EIBAID = DFHPF12 and then return RETURN See the below para for a better understanding -

P9000-RETURN-TERM.
      IF EIBAID = DFHPF12 
         EXEC CICS
              RETURN
         END-EXEC
      END-IF.

However, it is a good idea to free the keyboard and all before returning. So, the code becomes something like this -

P9000-RETURN-TERM.
      IF EIBAID = DFHPF12 
         EXEC CICS
              SEND CONTROL FREEKB ERASE
         END-EXEC
         EXEC CICS
              RETURN
         END-EXEC
      END-IF.
Saptarshi
  • 39
  • 1
  • 10
1

You need to use the copybook DFHAID to capture the attention. What you can do is, after receving the map, check EIBAID=DFHPF12 and then return to terminal by EXEC CICS RETURN