Problem:
By default, the tab and back tab pass the cursor to the next field if you are accepting a screen with several fields.
By default, pressing tab in the last field of an accept gives you an error message that there are no more fields and it doesn't terminate the accept...
The same happens with the back tab key (shift tab), it makes the cursor to go back to the previous field, but when you are in the first field of the screen, it gives you a "no further fields" error message and it doesn't terminate the accept.
This article explains what you would need to do if you want to control the behavior of the tab and back keys for example, to implement a "circular" behaviour where pressing the tab key in the last field makes the cursor to go back to the first field and pressing the back tab key in the first field positions the cursor in the last field.
Resolution:
You can change the default behavior using adiscf and keybcf from a Net Express Command Prompt (Start / Programs / Micro Focus Net Express / Net Express Command Prompt).
But you need to set the properties of the Command Prompt window correctly to be able to use adiscf and keybcf, see kb article 21274.
http://support.microfocus.com/mf_kb_display.asp?kbnumber=21274
This would be the steps that you have to perform in adiscf to ensure that pressing the tab key in the last field terminates your ACCEPT so you can control what to do within your COBOL program:
adiscf
F2=Alter
F3=Accept/Display Options
F3=Individual Options
8
Termination of an accept
Ensure that you have selected option 2 and press enter to accept your change:
2 : Using the 'Next Field' key in the last field of an accept will cause
the accept to terminate.
Esc, Esc, Esc to come back to the main menu
F4=Save
F3=Overwrite Existing Configuration
Select the configuration that you have active, by default it will be:
1 Default Configuration
and press enter to Save.
Esc to exit adiscf
Unfortunately, this only affects the key that is configured as "Move to Next Field". Pressing the Back tab still won't terminate an accept. For this you will need to run keybcf in your Net Express Command prompt. These are the steps:
keybcf
2. Alter function key definitions.
1. Alter Adis keys.
Press space several times to skip a few keys until you see
ADIS Function Key List
----------------------
Move to previous tab stop 00 0F
Enter required key sequence :
D=Delete
Q=Quit
1. Alter Adis keys.
You see
ADIS Function Key List
----------------------
Terminate accept Undefined
Enter required key sequence :
Press Shift Tab
You should now see
ADIS Function Key List
----------------------
Terminate accept 00 0F
Enter required key sequence :
Q=Quit
5. Exit to main menu.
3. Save function key definitions.
4. Exit.
Now we have to come back to adiscf to enable the Terminate accept mapping that we have just made.
adiscf
F2=Alter
F8=Key Control
F3=Function Mappings
Change the terminate accept function mappings to these values:
Function Valid Align Mapped to
Number Name -ate Number Name
--------------------------------------------------------------------------------
0 Terminate accept
[__0] Terminate accept
Esc, Esc, Esc to come back to the main menu
F4=Save
F3=Overwrite Existing Configuration
Select the configuration that you have active, by default it will be:
1 Default Configuration
and press enter to Save.
Esc to exit adiscf
The changes that you have made with adiscf have been saved to a file called ADISCTRL that should be in your Net Express\\Base\\BIN folder.
The changes that you have made with keybcf have been saved to a file called cobkeymp that should be in your current directory.
Remember to ship both ADISCTRL and cobkeymp with your application to get your users to have the same behavior that you have in your development environment.
The following COBOL program shows how you could control in your program the tab and the back tab keys to implement a "circular" movement where pressing the tab key in the last field makes the cursor to go back to the first field and pressing the back tab key in the first field positions the cursor in the last field. You will find this COBOL program and the necessary ADISCTRL and cobkeymp attached to this article.
environment division.
special-names.
crt status is lastkey.
data division.
working-storage section.
01 lastkey.
02 crt-status-key-1 PICTURE 9 USAGE DISPLAY.
88 terminator-key value 0. *> indicates a terminator key
*> or auto-skip out of the final field
88 user-function-key value 1. *> indicates a user-defined
*> function key
88 system-function-key value 2. *> indicates a COBOL
*> system-defined function key
88 error-in-accept value 9. *> indicates an error
02 crt-status-key-2.
05 key-2-terminator-key PIC 9 USAGE DISPLAY.
*> when terminator-key is true
88 no-auto-skip value 0.
88 auto-skip-at-end value 1.
05 key-2-function-key REDEFINES key-2-terminator-key
PIC 99 COMP.
88 esc-key value 0. *> when user-function-key is true
02 crt-status-key-3 PIC 99 COMP-X.
*> when terminator-key and no-auto-skip are true
88 tab-key value 9.
88 back-tab-key value 0.
88 enter-key value 13.
01 fld1 pic x(68).
01 fld2 pic x(68).
01 fld3 pic x(68).
01 fieldno pic 9.
screen section.
01 myscreen.
02 line 1 col 1 value "Field 1:".
02 line 2 col 1 value "Field 2:".
02 line 3 col 1 value "Field 3:".
01 moving-forward.
02 line 4 col 1 BLANK LINE.
02 line 4 col 1 value "MOVING FORWARD TO FIELD NO".
02 line 4 col 28 pic 99 from fieldno.
01 moving-back.
02 line 4 col 1 BLANK LINE.
02 line 4 col 1 value "MOVING BACK TO FIELD NO".
02 line 4 col 28 pic 99 from fieldno.
01 bye-bye.
02 line 4 col 1 BLANK LINE.
02 line 4 col 1 value "BYE BYE".
procedure division.
display myscreen
move 1 to fieldno.
accept fld1 at line 1 col 10.
perform until (user-function-key and esc-key)
or (terminator-key and no-auto-skip
and enter-key)
if terminator-key and no-auto-skip
if tab-key
if fieldno < 3 *> last field
add 1 to fieldno
DISPLAY moving-forward
else
move 1 to fieldno *> first field
DISPLAY moving-back
end-if
end-if
if back-tab-key
if fieldno > 1 *> first field
subtract 1 from fieldno
DISPLAY moving-back
else
move 3 to fieldno *> last field
DISPLAY moving-forward
end-if
end-if
end-if
evaluate fieldno
when 1
accept fld1 at line 1 col 10
when 2
accept fld2 at line 2 col 10
when 3
accept fld3 at line 3 col 10
end-evaluate
end-perform
DISPLAY bye-bye
stop run.