‎2014 Oct 22 8:05 AM
Hi,
This is a requirement I have in a module pool program:
On clicking a button "ADD COMMENT" on screen number 200 which calls screen 300, the screen 300 should automatically be scrolled down to the last entered comment and point at the new empty line.
Is it feasible, thoughts please....
Thanks in advance.
Regards,
Mamatha
‎2014 Oct 22 8:21 AM
‎2014 Oct 22 11:04 AM
Thanks Yogendra.
I am using a table control and when I used:
set cursor field it_lines cursor 50.
The cursor didn't get set at the line 50.
what should I change..
Regards,
Mamatha
‎2014 Oct 22 11:18 AM
Hi mamatha ,
How many lines are visible on the table control ?
you have to scroll accordingly and set the cursor
regards
Yogendra
‎2014 Oct 22 11:29 AM
‎2014 Oct 22 11:35 AM
Hi mamatha ,
there will be a function code related to scroll i.e page down function , generally it is P+ or P++
if you have created table control using wizard in that case you can use following perform
PERFORM compute_scrolling_in_tc USING 'TC_TEST' 'P+'.
" Replace TC_TEST with your Table Control Name
Regards
Yogendra
‎2014 Oct 22 12:08 PM
Yogendra,
I couldn't find
PERFORM compute_scrolling_in_tc USING 'TC_TEST' 'P+'.
in my program.. but I found this subroutine in another Z program in the system.
Should I do something to get this perform created automatically in my program as well.
Someone else created the table control so am not able to make out how it was created.
Regards,
Mamatha
‎2014 Oct 22 12:20 PM
Hi ,
actually FORM compute_scrolling_in_tc is created automatically when table control is created through wizard.
I suppose now you have to scroll the table control using the function code ,
create a push button page down , assign a function code to it.
Regard
Yogendra
‎2014 Oct 27 9:32 AM
Hi Yogendra,
with the push buttons, what is the code I should write for scrolling up and down.
I used com_300-top_line = comm_300-top_line + 1 to scroll up
com_300-top_line = comm_300-top_line - 1 to scroll down
But it doesn't work correctly.
Is there any other piece of code I can write to do this.
Thanks.
Regards,
Mamatha
‎2014 Oct 27 9:47 AM
to be more clear my req is - when user clicks a button "ADD COMMENT" in screen 300 the cursor should be directly placed at the next available line in screen 400.
Set cursor field works but that is only for the visible lines in the table control.
If I set to a value that is much beyond the visibility - then it doesn't work. I think I have to scroll down and then set the cursor..
‎2014 Oct 27 10:06 AM
Hi mamatha ,
copy the code of form compute_scrolling_in_tc and paste it in your code .
You have to call the for with two parameters
1 > name of tablecontrol
2 > ok code
Try it out
Regards
Yogendra
‎2014 Oct 27 10:19 AM
Yogendra,
I was just trying that.
But in my program the subroutine dumps at the place : assign (p_tc_name) to <tc>.
The field symbol doesn't get assigned.
My table control name is COMM_300.
I have called the subroutine like this:
Please let me know if I am going wrong somewhere
Regards,
Mamatha
‎2014 Oct 27 10:55 AM
Hi Mamatha ,
You have declared control as com_300 ( with single m )
replace it
perform compute_scrolling_in_tc using 'COM_300' sy-ucomm .
Regards
Yogendra
‎2014 Oct 27 11:15 AM
Hi Yogendra,
The subroutine executes but it is not working..
There are few comments in the Z program that says SAPWIZARD but I couldn't see this particular subroutine.
I am not able to make sure whether the table control is created using wizard or not....
I have created two buttons "UP" and "DOWN" giving fct code as UP and DOWN.
I have called the subroutine perform compute_scrolling_in_tc using 'COM_300' sy-ucomm when these buttons are clicked.. but nothing happens on clicking the button....
Thanks
Regards,
Mamatha
‎2014 Oct 27 11:34 AM
Hi Mamatha ,
In the form compute_scrolling_in_tc , while calling the FM SCROLLING_IN_TABLE , pass the value of ok_code as P++
like this :
CALL FUNCTION 'SCROLLING_IN_TABLE'
EXPORTING
entry_act = <tc>-top_line
entry_from = 1
entry_to = <tc>-lines
last_page_full = 'X'
loops = <lines>
ok_code = 'P++'
overlapping = 'X'
IMPORTING
entry_new = l_tc_new_top_line
EXCEPTIONS
* NO_ENTRY_OR_PAGE_ACT = 01
* NO_ENTRY_TO = 02
* NO_OK_CODE_OR_PAGE_GO = 03
OTHERS = 0.
If it is working then change the function code of DOWN as P++
Regards
Yogendra Bhaskar
‎2014 Oct 22 8:33 AM
Hi Mamatha,
Are you using a control to display the text, class cl_gui_textedit has several methods that maybe can help you:
SET_LAST_VISIBLE_LINE
SET_SELECTION_INDEXES
SET_SELECTION_POS
SET_SELECTION_POS_IN_LINE
SET_FIRST_VISIBLE_LINE
Regards.
JCD
‎2014 Oct 22 10:53 AM
Thanks Juan..
I used set_first_visible_line but it didn't make any difference in the screen.
All the lines are still visible... I have pasted my code below, could you please take a look
and let me know if something needs to be corrected
DATA: G_EDI_0300 TYPE REF TO CL_GUI_TEXTEDIT,
g_editor_container TYPE REF TO cl_gui_custom_container,
g_mycontainer(30) TYPE c. " string for the containers.
CONSTANTS: line_length TYPE i VALUE 256.
CREATE OBJECT g_editor_container
EXPORTING
container_name = 'TEXTEDITOR1'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
IF sy-subrc NE 0.
* add your handling
ENDIF.
g_mycontainer = 'TEXTEDITOR1'.
* create calls constructor, which initializes, creats and links
* TextEdit Control
CREATE OBJECT G_EDI_0300
EXPORTING
parent = g_editor_container.
* wordwrap_mode =
** cl_gui_textedit=>wordwrap_off
* cl_gui_textedit=>wordwrap_at_fixed_position
** cl_gui_textedit=>WORDWRAP_AT_WINDOWBORDER
* wordwrap_position = line_length
* wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
call method g_edi_0300->SET_FIRST_VISIBLE_LINE
EXPORTING
line = 10.
‎2014 Oct 22 11:18 AM