Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using table control

Former Member
0 Likes
414

I want step or example coding for table control has be able to move line item has up or down with button command Up - Down.

1 REPLY 1
Read only

Former Member
0 Likes
363

Hi,

You can create the table contro; using the Table control wizard which by dafult created the UP and Down buttons with functionality.

Or you can have this login in PAI..

I have created the 4 buttons 
'P--'                "top of list
'P-'                 "previous page
'P+'                "next page
'P++'              "bottom of list

{code

MODULE val_disc_maint_user_command INPUT.

" need to pass the Table Control Name and Sy-ucomm

PERFORM user_ok_tc USING 'VAL_DISC_MAINT'

CHANGING ok_code.

ENDMODULE. "VAL_DISC_MAINT_user_command INPUT

FORM user_ok_tc USING p_tc_name TYPE dynfnam

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----


  • Table control specific operations *

  • 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.

  • Execute general and TC specific operations *

CASE l_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.

ENDCASE.

ENDFORM. " USER_OK_TC

&----


*& Form COMPUTE_SCROLLING_IN_TC

&----


  • text

----


  • -->P_TC_NAME Nname of tablecontrol

  • -->P_OK Ok code

----


FORM compute_scrolling_in_tc USING p_tc_name TYPE any

p_ok TYPE any.

&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{code}