cancel
Showing results for 
Search instead for 
Did you mean: 

Move horizontal scroll from to table controls

Former Member
0 Kudos

I have to table controls in a screen that I'd like to move at the same time when I click the horizontal scroll bar.

Is it possible?

If it is... do you have an example?

Thanx in advance.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I'm using this and It doesn't work.

*&SPWIZARD: INPUT MODULE FOR TC 'T_101'. DO NOT CHANGE THIS LINE!

*&SPWIZARD: PROCESS USER COMMAND

MODULE T_101_USER_COMMAND INPUT.

OK_CODE = SY-UCOMM.

PERFORM USER_OK_TC USING 'T_101'

'G_T_101_ITAB'

' '

CHANGING OK_CODE.

SY-UCOMM = OK_CODE.

DATA W_PREF.

OK_CODE = SY-UCOMM.

SPLIT SY-UCOMM AT 'T_101' INTO W_PREF OK_CODE .

CONCATENATE 'T_102' OK_CODE INTO OK_CODE.

PERFORM USER_OK_TC USING 'T_102'

'G_T_102_ITAB'

' '

CHANGING OK_CODE.

SY-UCOMM = OK_CODE.

ENDMODULE. "T_101_USER_COMMAND INPUT

former_member186741
Active Contributor
0 Kudos

forgot to mention to change your pbo loop to use the 'other' table control:

loop at T_TAB2

  • with control TC2

with control TC01

  • cursor TC2-current_line.

cursor TC01-current_line.

module TC2_get_lines.

*&spwizard: module TC2_change_field_attr

endloop.

**************

It works on the 'scrolling' pfkeys but does not work if you scroll via the scrollbar on the right. The logic for this seems to be at gui level for some reason.

former_member186741
Active Contributor
0 Kudos

Yes! You can do it. The trick is to manipulate the okcode to operate on both table controls within the wizard generated <tablcontrol>_user_command pai module.

The wizard generated looks like this:

module TC2_user_command input.

OK_CODE = sy-ucomm.

perform user_ok_tc using 'TC2'

'T_TAB2'

' '

changing OK_CODE.

sy-ucomm = OK_CODE.

endmodule.

I changed one of them to do this:

MODULE tc01_user_command INPUT.

data w_pref.

ok_code = sy-ucomm.

PERFORM user_ok_tc USING 'TC01'

'T_TAB'

' '

CHANGING ok_code.

ok_code = sy-ucomm.

split sy-ucomm at 'TC01' into w_pref ok_code .

concatenate 'TC2' ok_code into ok_code.

perform user_ok_tc using 'TC2'

'T_TAB2'

' '

changing OK_CODE.

sy-ucomm = ok_code.

ENDMODULE. "TC01_user_command INPUT

Here's all my code:

REPORT znrw_tc_play .

SELECTION-SCREEN COMMENT 10(20) TEXT-001.

PARAMETERS: p_table TYPE tablename OBLIGATORY,

p_table2 TYPE tablename OBLIGATORY,

p_recs(3) type p decimals 2

default 11.

types: begin of znrw_tc,

COL01 type char20,

COL02 type char20,

COL03 type char20,

COL04 type char20,

COL05 type char20,

COL06 type char20,

COL07 type char20,

COL08 type char20,

COL09 type char20,

COL010 type char20,

end of znrw_tc.

DATA w_row TYPE znrw_tc.

DATA t_tab TYPE TABLE OF znrw_tc WITH HEADER LINE.

DATA t_tab2 TYPE TABLE OF znrw_tc WITH HEADER LINE.

data w_sel.

data w_sel_col type sytabix.

FIELD-SYMBOLS: <table> TYPE ANY,

<in_column> TYPE ANY,

<out_column> TYPE any.

START-OF-SELECTION.

DATA dref TYPE REF TO data.

perform fill_table using p_table changing t_tab[].

perform fill_table using p_table2 changing t_tab2[].

CALL SCREEN 0100.

*&spwizard: declaration of tablecontrol 'TC01' itself

CONTROLS: tc01 TYPE TABLEVIEW USING SCREEN 0100.

*&spwizard: lines of tablecontrol 'TC01'

DATA: g_tc01_lines LIKE sy-loopc.

DATA: ok_code LIKE sy-ucomm.

*&spwizard: output module for tc 'TC01'. do not change this line!

*&spwizard: update lines for equivalent scrollbar

MODULE tc01_change_tc_attr OUTPUT.

DESCRIBE TABLE t_tab LINES tc01-lines.

ENDMODULE. "TC01_change_tc_attr OUTPUT

*&spwizard: output module for tc 'TC01'. do not change this line!

*&spwizard: get lines of tablecontrol

MODULE tc01_get_lines OUTPUT.

g_tc01_lines = sy-loopc.

ENDMODULE. "TC01_get_lines OUTPUT

*&spwizard: input module for tc 'TC01'. do not change this line!

*&spwizard: process user command

MODULE tc01_user_command INPUT.

data w_pref.

ok_code = sy-ucomm.

PERFORM user_ok_tc USING 'TC01'

'T_TAB'

' '

CHANGING ok_code.

ok_code = sy-ucomm.

split sy-ucomm at 'TC01' into w_pref ok_code .

concatenate 'TC2' ok_code into ok_code.

perform user_ok_tc using 'TC2'

'T_TAB2'

' '

changing OK_CODE.

sy-ucomm = ok_code.

ENDMODULE. "TC01_user_command INPUT

----


  • INCLUDE TABLECONTROL_FORMS *

----


&----


*& Form USER_OK_TC *

&----


FORM user_ok_tc USING p_tc_name TYPE dynfnam

p_table_name

p_mark_name

CHANGING p_ok LIKE sy-ucomm.

&SPWIZARD: BEGIN OF LOCAL DATA----


DATA: l_ok TYPE sy-ucomm,

l_offset TYPE i.

&SPWIZARD: END OF LOCAL DATA----


*&SPWIZARD: Table control specific operations *

*&SPWIZARD: evaluate TC name and operations *

SEARCH p_ok FOR p_tc_name.

IF sy-subrc <> 0.

EXIT.

ENDIF.

l_offset = STRLEN( p_tc_name ) + 1.

l_ok = p_ok+l_offset.

*&SPWIZARD: execute general and TC specific operations *

CASE l_ok.

WHEN 'INSR'. "insert row

PERFORM fcode_insert_row USING p_tc_name

p_table_name.

CLEAR p_ok.

WHEN 'DELE'. "delete row

PERFORM fcode_delete_row USING p_tc_name

p_table_name

p_mark_name.

CLEAR p_ok.

WHEN 'P--' OR "top of list

'P-' OR "previous page

'P+' OR "next page

'P++'. "bottom of list

PERFORM compute_scrolling_in_tc USING p_tc_name

l_ok.

CLEAR p_ok.

  • WHEN 'L--'. "total left

  • PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.

*

  • WHEN 'L-'. "column left

  • PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.

*

  • WHEN 'R+'. "column right

  • PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.

*

  • WHEN 'R++'. "total right

  • PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.

*

WHEN 'MARK'. "mark all filled lines

PERFORM fcode_tc_mark_lines USING p_tc_name

p_table_name

p_mark_name .

CLEAR p_ok.

WHEN 'DMRK'. "demark all filled lines

PERFORM fcode_tc_demark_lines USING p_tc_name

p_table_name

p_mark_name .

CLEAR p_ok.

  • WHEN 'SASCEND' OR

  • 'SDESCEND'. "sort column

  • PERFORM FCODE_SORT_TC USING P_TC_NAME

  • l_ok.

ENDCASE.

ENDFORM. " USER_OK_TC

&----


*& Form FCODE_INSERT_ROW *

&----


FORM fcode_insert_row

USING p_tc_name TYPE dynfnam

p_table_name .

&SPWIZARD: BEGIN OF LOCAL DATA----


DATA l_lines_name LIKE feld-name.

DATA l_selline LIKE sy-stepl.

DATA l_lastline TYPE i.

DATA l_line TYPE i.

DATA l_table_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

FIELD-SYMBOLS <lines> TYPE i.

&SPWIZARD: END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

*&SPWIZARD: get the table, which belongs to the tc *

CONCATENATE p_table_name '[]' INTO l_table_name. "table body

ASSIGN (l_table_name) TO <table>. "not headerline

*&SPWIZARD: get looplines of TableControl *

CONCATENATE 'G_' p_tc_name '_LINES' INTO l_lines_name.

ASSIGN (l_lines_name) TO <lines>.

*&SPWIZARD: get current line *

GET CURSOR LINE l_selline.

IF sy-subrc <> 0. " append line to table

l_selline = <tc>-lines + 1.

*&SPWIZARD: set top line *

IF l_selline > <lines>.

<tc>-top_line = l_selline - <lines> + 1 .

ELSE.

<tc>-top_line = 1.

ENDIF.

ELSE. " insert line into table

l_selline = <tc>-top_line + l_selline - 1.

l_lastline = <tc>-top_line + <lines> - 1.

ENDIF.

*&SPWIZARD: set new cursor line *

l_line = l_selline - <tc>-top_line + 1.

*&SPWIZARD: insert initial line *

INSERT INITIAL LINE INTO <table> INDEX l_selline.

<tc>-lines = <tc>-lines + 1.

*&SPWIZARD: set cursor *

SET CURSOR LINE l_line.

ENDFORM. " FCODE_INSERT_ROW

&----


*& Form FCODE_DELETE_ROW *

&----


FORM fcode_delete_row

USING p_tc_name TYPE dynfnam

p_table_name

p_mark_name .

&SPWIZARD: BEGIN OF LOCAL DATA----


DATA l_table_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

FIELD-SYMBOLS <wa>.

FIELD-SYMBOLS <mark_field>.

&SPWIZARD: END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

*&SPWIZARD: get the table, which belongs to the tc *

CONCATENATE p_table_name '[]' INTO l_table_name. "table body

ASSIGN (l_table_name) TO <table>. "not headerline

*&SPWIZARD: delete marked lines *

DESCRIBE TABLE <table> LINES <tc>-lines.

LOOP AT <table> ASSIGNING <wa>.

*&SPWIZARD: access to the component 'FLAG' of the table header *

ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.

IF <mark_field> = 'X'.

DELETE <table> INDEX syst-tabix.

IF sy-subrc = 0.

<tc>-lines = <tc>-lines - 1.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " FCODE_DELETE_ROW

&----


*& Form COMPUTE_SCROLLING_IN_TC

&----


  • text

----


  • -->P_TC_NAME name of tablecontrol

  • -->P_OK ok code

----


FORM compute_scrolling_in_tc USING p_tc_name

p_ok.

&SPWIZARD: BEGIN OF LOCAL DATA----


DATA l_tc_new_top_line TYPE i.

DATA l_tc_name LIKE feld-name.

DATA l_tc_lines_name LIKE feld-name.

DATA l_tc_field_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <lines> TYPE i.

&SPWIZARD: END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

*&SPWIZARD: get looplines of TableControl *

CONCATENATE 'G_' p_tc_name '_LINES' INTO l_tc_lines_name.

ASSIGN (l_tc_lines_name) TO <lines>.

*&SPWIZARD: is no line filled? *

IF <tc>-lines = 0.

*&SPWIZARD: yes, ... *

l_tc_new_top_line = 1.

ELSE.

*&SPWIZARD: no, ... *

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_ok

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.

ENDIF.

*&SPWIZARD: get actual tc and column *

GET CURSOR FIELD l_tc_field_name

AREA l_tc_name.

IF syst-subrc = 0.

IF l_tc_name = p_tc_name.

*&SPWIZARD: et actual column *

SET CURSOR FIELD l_tc_field_name LINE 1.

ENDIF.

ENDIF.

*&SPWIZARD: set the new top line *

<tc>-top_line = l_tc_new_top_line.

ENDFORM. " COMPUTE_SCROLLING_IN_TC

&----


*& Form FCODE_TC_MARK_LINES

&----


  • marks all TableControl lines

----


  • -->P_TC_NAME name of tablecontrol

----


FORM fcode_tc_mark_lines USING p_tc_name

p_table_name

p_mark_name.

&SPWIZARD: EGIN OF LOCAL DATA----


DATA l_table_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

FIELD-SYMBOLS <wa>.

FIELD-SYMBOLS <mark_field>.

&SPWIZARD: END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

*&SPWIZARD: get the table, which belongs to the tc *

CONCATENATE p_table_name '[]' INTO l_table_name. "table body

ASSIGN (l_table_name) TO <table>. "not headerline

*&SPWIZARD: mark all filled lines *

LOOP AT <table> ASSIGNING <wa>.

*&SPWIZARD: access to the component 'FLAG' of the table header *

ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.

<mark_field> = 'X'.

ENDLOOP.

ENDFORM. "fcode_tc_mark_lines

&----


*& Form FCODE_TC_DEMARK_LINES

&----


  • demarks all TableControl lines

----


  • -->P_TC_NAME name of tablecontrol

----


FORM fcode_tc_demark_lines USING p_tc_name

p_table_name

p_mark_name .

&SPWIZARD: BEGIN OF LOCAL DATA----


DATA l_table_name LIKE feld-name.

FIELD-SYMBOLS <tc> TYPE cxtab_control.

FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

FIELD-SYMBOLS <wa>.

FIELD-SYMBOLS <mark_field>.

&SPWIZARD: END OF LOCAL DATA----


ASSIGN (p_tc_name) TO <tc>.

*&SPWIZARD: get the table, which belongs to the tc *

CONCATENATE p_table_name '[]' INTO l_table_name. "table body

ASSIGN (l_table_name) TO <table>. "not headerline

*&SPWIZARD: demark all filled lines *

LOOP AT <table> ASSIGNING <wa>.

*&SPWIZARD: access to the component 'FLAG' of the table header *

ASSIGN COMPONENT p_mark_name OF STRUCTURE <wa> TO <mark_field>.

<mark_field> = space.

ENDLOOP.

ENDFORM. "fcode_tc_mark_lines

form fill_table using us_table like p_table

changing ch_tab like t_tab[].

CREATE DATA dref TYPE (p_table).

ASSIGN dref->* TO <table>.

refresh ch_tab.

SELECT * UP TO p_recs ROWS

FROM (p_table)

INTO <table>.

DO 7 TIMES.

ASSIGN COMPONENT sy-index OF STRUCTURE <table> TO <in_column>.

IF sy-subrc <> 0.

EXIT.

ENDIF.

ASSIGN COMPONENT sy-index OF STRUCTURE w_row TO <out_column>.

<out_column> = <in_column>.

ENDDO.

append w_row to ch_tab.

...

ENDSELECT.

endform.

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module USER_COMMAND_0100 input.

if w_sel_col <> 0.

read table t_tab index w_sel_col.

delete t_tab where col02 <> t_tab-col02.

else.

perform fill_table using p_table changing t_tab[].

perform fill_table using p_table2 changing t_tab2[].

endif.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Module line_selected INPUT

&----


  • text

----


module line_selected input.

if not w_sel is initial.

w_sel_col = sy-stepl.

endif.

endmodule. " line_selected INPUT

&----


*& Module init_100 OUTPUT

&----


  • text

----


module init_100 output.

set pf-status '100'.

clear w_sel_col.

endmodule. " init_100 OUTPUT

&----


*& Module exit_100 INPUT

&----


  • text

----


module exit_100 input.

leave to screen 0.

endmodule. " exit_100 INPUT

*&spwizard: declaration of tablecontrol 'TC2' itself

controls: TC2 type tableview using screen 0100.

*&spwizard: lines of tablecontrol 'TC2'

data: g_TC2_lines like sy-loopc.

*&spwizard: output module for tc 'TC2'. do not change this line!

*&spwizard: update lines for equivalent scrollbar

module TC2_change_tc_attr output.

describe table T_TAB2 lines TC2-lines.

endmodule.

*&spwizard: output module for tc 'TC2'. do not change this line!

*&spwizard: get lines of tablecontrol

module TC2_get_lines output.

g_TC2_lines = sy-loopc.

endmodule.

*&spwizard: input module for tc 'TC2'. do not change this line!

*&spwizard: process user command

module TC2_user_command input.

OK_CODE = sy-ucomm.

perform user_ok_tc using 'TC2'

'T_TAB2'

' '

changing OK_CODE.

sy-ucomm = OK_CODE.

endmodule.

Former Member
0 Kudos

Jose,

I don't think it will be possible.

If you can explain the scenario, we can try designing it in a different way.

regards,

Ravi