2009 Jun 26 9:56 AM
Hi,
I have a table control and I am able to delete lines via a button I've placed on the screen;
the problem is when I delete a line the cursor automatically goes back to the top of the screen (1st field) not even within the table control.
I've been told to use get_cursor and set_cursor to solve this but not sure exactly how to use it
can anybody assist?
My code is as follows:-
PROCESS BEFORE OUTPUT.
* MODULE STATUS_0203.
MODULE get_data_0203.
MODULE get_cursor. " RP 25.06.09
* This binds the table control and the table memory.
LOOP AT gtc_ipscale INTO zrc_gui_tc_ipscale
WITH CONTROL tc_scale_rate.
* Obtain number of lines on the table control.
MODULE tc_scale_rate_get_lines.
ENDLOOP.
MODULE modify_screen_0203.
MODULE hide_buttons.
*
PROCESS AFTER INPUT.
* Loop at the table rows.
LOOP AT gtc_ipscale.
CHAIN.
* Tranfer the screen field values to the ABAP work area.
FIELD: zrc_gui_tc_ipscale-selected,
zrc_gui_tc_ipscale-cost_group,
zrc_gui_tc_ipscale-scale_id,
zrc_gui_tc_ipscale-scale_name,
zrc_gui_tc_ipscale-ip.
MODULE modify_gtc_ipscale ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE user_command_0203.
module set_cursor. " RP 25.06.09
MODULE set_data_0203.module GET_CURSOR output.
PERFORM get_cursor. " RP 25.06.09
endmodule. " GET_CURSOR OUTPUTform GET_CURSOR .
data: l_fline type sy-index,
l_curline type sy-index.
l_fline = 1.
l_curline = 3.
CALL FUNCTION 'GET_CURSOR'
IMPORTING
FIRST_LINE = l_fline
CURSOR_LINE = l_curline
* CURSOR_OFFSET =
.
endform.
MODULE set_cursor INPUT.
PERFORM set_cursor. " RP 25.06.09
ENDMODULE.
form SET_CURSOR .
data: l_fline type sy-index,
l_curline type sy-index.
l_fline = 1.
l_curline = 3.
CALL FUNCTION 'SET_CURSOR'
EXPORTING
first_line = l_fline
cursor_line = l_curline
* cursor_offset =
* IMPORTING
* EDIT =
.
endform.
2009 Jun 26 10:03 AM
Chane code :
GET CURSOR in PAI and SET CURSOR in PBO.
Regards,
Siva.
Hi,
I have a table control and I am able to delete lines via a button I've placed on the screen;
the problem is when I delete a line the cursor automatically goes back to the top of the screen (1st field) not even within the table control.
I've been told to use get_cursor and set_cursor to solve this but not sure exactly how to use it
can anybody assist?
My code is as follows:-
PROCESS BEFORE OUTPUT.
* MODULE STATUS_0203.
MODULE get_data_0203.
MODULE get_cursor. " RP 25.06.09
* This binds the table control and the table memory.
LOOP AT gtc_ipscale INTO zrc_gui_tc_ipscale
WITH CONTROL tc_scale_rate.
* Obtain number of lines on the table control.
MODULE tc_scale_rate_get_lines.
ENDLOOP.
MODULE modify_screen_0203.
MODULE hide_buttons.
*
PROCESS AFTER INPUT.
* Loop at the table rows.
LOOP AT gtc_ipscale.
CHAIN.
* Tranfer the screen field values to the ABAP work area.
FIELD: zrc_gui_tc_ipscale-selected,
zrc_gui_tc_ipscale-cost_group,
zrc_gui_tc_ipscale-scale_id,
zrc_gui_tc_ipscale-scale_name,
zrc_gui_tc_ipscale-ip.
MODULE modify_gtc_ipscale ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE user_command_0203.
module set_cursor. " RP 25.06.09
MODULE set_data_0203.module GET_CURSOR output.
PERFORM get_cursor. " RP 25.06.09
endmodule. " GET_CURSOR OUTPUTform GET_CURSOR .
data: l_fline type sy-index,
l_curline type sy-index.
l_fline = 1.
l_curline = 3.
CALL FUNCTION 'GET_CURSOR'
IMPORTING
FIRST_LINE = l_fline
CURSOR_LINE = l_curline
* CURSOR_OFFSET =
.
endform.
MODULE set_cursor INPUT.
PERFORM set_cursor. " RP 25.06.09
ENDMODULE.
form SET_CURSOR .
data: l_fline type sy-index,
l_curline type sy-index.
l_fline = 1.
l_curline = 3.
CALL FUNCTION 'SET_CURSOR'
EXPORTING
first_line = l_fline
cursor_line = l_curline
* cursor_offset =
* IMPORTING
* EDIT =
.
endform.
2009 Jun 26 10:03 AM
Chane code :
GET CURSOR in PAI and SET CURSOR in PBO.
Regards,
Siva.
2009 Jun 26 3:20 PM
Thanks for that you are a star.
Was going around in circles.
+ I need to clear the cursor in the parent form.
Thanks once again.
2009 Jun 26 3:51 PM
full solution is as follows:-
PROCESS BEFORE OUTPUT.
* MODULE STATUS_0203.
MODULE get_data_0203.
* This binds the table control and the table memory.
LOOP AT gtc_ipscale INTO zrc_gui_tc_ipscale
WITH CONTROL tc_scale_rate.
* Obtain number of lines on the table control.
MODULE tc_scale_rate_get_lines.
MODULE set_cursor. " RP 25.06.09 - Note has to be within loop.
ENDLOOP.
MODULE modify_screen_0203.
MODULE hide_buttons.
*
PROCESS AFTER INPUT.
* Loop at the table rows.
LOOP AT gtc_ipscale.
CHAIN.
* Tranfer the screen field values to the ABAP work area.
FIELD: zrc_gui_tc_ipscale-selected,
zrc_gui_tc_ipscale-cost_group,
zrc_gui_tc_ipscale-scale_id,
zrc_gui_tc_ipscale-scale_name,
zrc_gui_tc_ipscale-ip.
MODULE modify_gtc_ipscale ON CHAIN-REQUEST.
ENDCHAIN.
MODULE get_cursor. " RP 25.06.09 - Note has to be within loop.
ENDLOOP.
MODULE user_command_0203.
module GET_CURSOR output.
PERFORM get_cursor. " RP 25.06.09
endmodule.
form GET_CURSOR .
IF g_cursor_field IS INITIAL.
GET CURSOR FIELD g_cursor_field LINE g_cursor_line.
ENDIF.
endform.
MODULE set_cursor INPUT.
PERFORM set_cursor. " RP 25.06.09
ENDMODULE.
form SET_CURSOR .
IF g_cursor_field IS NOT INITIAL.
SET CURSOR FIELD g_cursor_field LINE g_cursor_line.
ENDIF.
endform.
** In the parent form within the PBO clear the cursor.*
PROCESS BEFORE OUTPUT.
MODULE clear_cursor. " Only clear in the parent PBO
module CLEAR_CURSOR output.
PERFORM clear_cursor.
endmodule.
FORM clear_cursor .
CLEAR g_cursor_field.
CLEAR g_cursor_line.
ENDFORM.
2009 Jun 26 10:24 AM
In PBO, write the following code :
set cursor field '<table name>-<fieldname>' line v_line.
where v_line is the row number where you want to set ur cursor.
Eg. - The following code sets the cursor to the 3rd row of the field END_DATE in the tablecontrol.
controls: tabctrl type tableview using screen 9000.
data: v_line type i value 3.
set cursor field 'ZZZ_TAB1-END_DATE' line v_line.
where tabctrl is the table control,
ZZZ_TAB1 is the DDIC table structure associated with the table control in the screen,
END_DATE is the field of the table ZZZ_TAB1.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |