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

Table control

Former Member
0 Likes
1,634

In a table control how i can put the cursor on the colomn that i want when i click enter?

For exaple if i put with the mouse the cursor on the 5 column when i click enter i want the cursor on the fist column

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,604

use set_cusror_field..

14 REPLIES 14
Read only

Former Member
0 Likes
1,605

use set_cusror_field..

Read only

former_member182371
Active Contributor
0 Likes
1,604

Hi,

you can find this in SAP HELP:

Cursor Position on Table Controls

At PBO you can set the cursor on a specific field of a specific row of a table control.

SET CURSOR FIELD f LINE lin [OFFSET off].

Using the optional addition OFFSET, you can enter the offset of the cursor in the field as described under Setting the Cursor Position .

At PAI you can read the current cursor position.

GET CURSOR FIELD f LINE lin ...

In addition to the information given under Finding Out the Cursor Position , field lin contains information on which row of the table control the cursor is currently on. You can also use

GET CURSOR LINE lin.

. sy-subrc allows you to check if the cursor is placed in a row of a table control.

Best regards

Read only

Former Member
0 Likes
1,604

hiiii

i think you should write SET CURSOR for that column ...

when you press ENTER button in that use this statement.

regards

twinkal

Read only

Former Member
0 Likes
1,604

Sorry, but i am in a table control and so i haven' t field for use SET CURSOR FIELD , how i can resolve the problem?

Edited by: Pippo Pluto on Jul 28, 2008 12:55 PM

Read only

0 Likes
1,604

Hi,

Check this Link for Cursor in Table Contro and How to use-

http://help.sap.com/saphelp_nw04/helpdata/EN/9f/dbac9f35c111d1829f0000e829fbfe/content.htm

Regards,

Sujit

Read only

0 Likes
1,604

Hi,

Get cursor .. statement would not satisfy your requirement - while hovering the mouse.

You might find some method in relevant class (OO concept).

Regards,

Wajid Hussain P.

Read only

Former Member
0 Likes
1,604

hi,

try the below logic

PAI ,

user Command write GET CURSOR FIELD F and

PBO

write SET CURSOR FIELD F

Read only

Former Member
0 Likes
1,604

Yes i know but i have't a filed for get cursor field because i have a table control ad if i write set cursor fiels <nametablecontrol>-<Field> i have an error message

Read only

0 Likes
1,604

Hi,

Yes you have a table Control but in the table control you have to Set the Cursor to a particular field.

Use the Statement-

SET CURSOR FIELD <f> LINE <line>.

In 'f' mention table control field.

Regards,

Sujit

Read only

Former Member
0 Likes
1,604

yes but if I write :

set cursor field <nametablecontro>-<Fieldoftablecontrol>.

or set cursor field <Fieldoftablecontrol>.

when i active i have a massage of error

Edited by: Pippo Pluto on Jul 28, 2008 1:25 PM

Read only

0 Likes
1,604

Hi,

why not starting anew your table control but this time using the table control wizard?.

In this way you will have the whole functionality of the table control available

e.g.


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

Best regards.

Edited by: pablo casamayor on Jul 28, 2008 6:31 PM

Read only

Former Member
0 Likes
1,604

I have't use wizard

Read only

Former Member
0 Likes
1,604

Hi,

We can use get and set statement but you have to findout

exact line num by using the example and the below site.

&----


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

this is the site for table control:

http://help.sap.com/saphelp_nw04/helpdata/EN/9f/dbac9f35c111d1829f0000e829fbfe/content.htm

Regards,

Naveen.

Read only

Former Member
0 Likes
1,604

Hi,

We can use get and set statement but you have to findout

exact line num by using the example and the below site.

&----


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

this is the site for table control:

http://help.sap.com/saphelp_nw04/helpdata/EN/9f/dbac9f35c111d1829f0000e829fbfe/content.htm

Regards,

Naveen.