‎2013 Dec 05 8:12 AM
Hi colleagues abapers,
I have a problem with cursor positioning in dialog program. There is tabstrip control with two tabs and on each is one table control. I want, when a hit Enter, that cursor stay in same field of table control instead of returning to starting position, first enabled column/row.
Until now I always did like this and it worked:
DATA : cursor_field TYPE fieldname, "char 30
cursor_line TYPE sy-linno.
In PAI user command module: GET CURSOR FIELD cursor_field LINE cursor_line.
In PBO status module: SET CURSOR FIELD cursor_field LINE cursor_line.
I tried different combinations, without LINE, or setting and getting in tabstrip subscreens modules, but the problem is that cursor_field never get read when it is in table control, which I see from debugger.
Got any suggestions?
Thanks
‎2013 Dec 05 11:16 AM
Ok, after much of experimenting I finally made it. Now cursor stays in field, in header box and in table controls, which I want at the beginning. This is how I did:
In main screen flow logic:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
*&SPWIZARD: PBO FLOW LOGIC FOR TABSTRIP 'TS_STAVKE'
MODULE ts_stavke_active_tab_set.
CALL SUBSCREEN ts_stavke_sca
INCLUDING g_ts_stavke-prog g_ts_stavke-subscreen.
PROCESS AFTER INPUT.
*&SPWIZARD: PAI FLOW LOGIC FOR TABSTRIP 'TS_STAVKE'
CALL SUBSCREEN ts_stavke_sca.
MODULE ts_stavke_active_tab_get.
MODULE user_command_0100.
In subscreens PAI and PBO modules:
SET CURSOR FIELD cursor_field LINE cursor_line.
ENDMODULE. " STATUS_0101 OUTPUT
*&SPWIZARD: INPUT MODULE FOR TC 'TC_RAD1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE tc_rad1_user_command INPUT.
ok_code = sy-ucomm.
PERFORM user_ok_tc USING 'TC_RAD1'
'RAD1_ITAB'
'FLAG'
CHANGING ok_code.
sy-ucomm = ok_code.
GET CURSOR FIELD cursor_field LINE cursor_line.
ENDMODULE. "TC_RAD1_USER_COMMAND INPUT
In main screen PBO and PAI:
SET CURSOR FIELD cursor_field LINE cursor_line.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
IF cursor_field IS INITIAL.
GET CURSOR FIELD cursor_field LINE cursor_line.
ENDIF.
Thank you all for help!
‎2013 Dec 05 8:42 AM
In PBO your set cursor shoudl be after the loop endloop of table control and in PAI it shoudl be at the beginning
‎2013 Dec 05 8:54 AM
Hello Vladimir,
in PAI, keep a condition for sy-ucomm. check the sy-ucomm for enter action.
lets say ENTR is the sy-ucomm then u can place like below.
if sy-ucomm = 'ENTR'.
get cursor position into a variable.
endif.
in the PBO you can make use of this variable and set the position again.
make sure that your VARIABLE is accessible in both modules.
Let us know in case of issues.
Regards,
Bhaskar
‎2013 Dec 05 9:09 AM
Here is the code from screen flow logic:
PROCESS BEFORE OUTPUT.
*&SPWIZARD: PBO FLOW LOGIC FOR TABSTRIP 'TS_STAVKE'
MODULE ts_stavke_active_tab_set.
CALL SUBSCREEN ts_stavke_sca
INCLUDING g_ts_stavke-prog g_ts_stavke-subscreen.
MODULE status_0100.
PROCESS AFTER INPUT.
MODULE user_command_0100.
*&SPWIZARD: PAI FLOW LOGIC FOR TABSTRIP 'TS_STAVKE'
CALL SUBSCREEN ts_stavke_sca.
MODULE ts_stavke_active_tab_get.
MODULE exit_command_0100 AT EXIT-COMMAND.
And snippet from PAI user command and PBO status modules where I set/get cursor variable:
SET CURSOR FIELD cursor_field LINE cursor_line.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
GET CURSOR FIELD cursor_field LINE cursor_line.
‎2013 Dec 05 9:19 AM
Hi Vladimir
Please keep these statement in your subscreen where you have table control defined. Plus it should be in PBO of subscreen after endloop and in PAI before everything
‎2013 Dec 05 11:16 AM
Ok, after much of experimenting I finally made it. Now cursor stays in field, in header box and in table controls, which I want at the beginning. This is how I did:
In main screen flow logic:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
*&SPWIZARD: PBO FLOW LOGIC FOR TABSTRIP 'TS_STAVKE'
MODULE ts_stavke_active_tab_set.
CALL SUBSCREEN ts_stavke_sca
INCLUDING g_ts_stavke-prog g_ts_stavke-subscreen.
PROCESS AFTER INPUT.
*&SPWIZARD: PAI FLOW LOGIC FOR TABSTRIP 'TS_STAVKE'
CALL SUBSCREEN ts_stavke_sca.
MODULE ts_stavke_active_tab_get.
MODULE user_command_0100.
In subscreens PAI and PBO modules:
SET CURSOR FIELD cursor_field LINE cursor_line.
ENDMODULE. " STATUS_0101 OUTPUT
*&SPWIZARD: INPUT MODULE FOR TC 'TC_RAD1'. DO NOT CHANGE THIS LINE!
*&SPWIZARD: PROCESS USER COMMAND
MODULE tc_rad1_user_command INPUT.
ok_code = sy-ucomm.
PERFORM user_ok_tc USING 'TC_RAD1'
'RAD1_ITAB'
'FLAG'
CHANGING ok_code.
sy-ucomm = ok_code.
GET CURSOR FIELD cursor_field LINE cursor_line.
ENDMODULE. "TC_RAD1_USER_COMMAND INPUT
In main screen PBO and PAI:
SET CURSOR FIELD cursor_field LINE cursor_line.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
IF cursor_field IS INITIAL.
GET CURSOR FIELD cursor_field LINE cursor_line.
ENDIF.
Thank you all for help!
‎2013 Dec 05 12:48 PM
Hii Vladmir,
You can also use System structure variable SY-STEPL And it works in table control for the index of current step loop line for current field.
Just try with it and hope will work without creating a variable cursorl_line.
Syntax:
SET/GET CURSOR FIELD <fieldname> LINE SY-STEPL.
SET CURSOR FIELD cursor_field LINE sy-stepl.
regards
Syed