Application Development 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: 

Move cursor through fields in screen with ENTER like TAB

Former Member
0 Kudos

Hello experts !

I want to move the cursor between fields in a custom screen just like kay TAB do.

I have used command:

MOVE CURSOR TO FIELD mara-spart... but it doesnt work, Cursor remains in th first field..,

any help?

Thank you and regards,

Ibrahim Andres

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Hi, the trick here is that you need to know where the cursor is and what is the next logical field which will need to be handled manually. So use the GET CURSOR statement and SET CURSOR statement.

In the PAI, use the GET CURSOR statement when the user presses ENTER, then in the PBO, you can SET CURSOR, but you will need to do some logic. For example, say you have 3 fields, P_FLD1, P_FLD2, P_FLD3. The logic is that when the user is on P_FLD1, the next cursor position should be on P_FLD2, and so on. So in your PBO, you will need to do like so. Here CURSORFIELD is the variable holding the field name that the cursor is currently on.

data: cursorfield(30) type c.
data: new_cursorfield(30) type c.

case cursorfield.
  when 'P_FLD1'.
     new_cursorfield = 'P_FLD2'.
  when 'P_FLD2'.
     new_cursorfield = 'P_FLD3'.
  when 'P_FLD3'.
     new_cursorfield = 'P_FLD1'.
endcase.

set cursor field new_cursorfield.

Regards,

Rich Heilman

8 REPLIES 8

Former Member
0 Kudos

Hi,

Try like this

set cursor field 'V_SPART'.

leave to screen sy-dynnr.

here for you v_spart should be ur screen field.

Madhavi

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Hi, the trick here is that you need to know where the cursor is and what is the next logical field which will need to be handled manually. So use the GET CURSOR statement and SET CURSOR statement.

In the PAI, use the GET CURSOR statement when the user presses ENTER, then in the PBO, you can SET CURSOR, but you will need to do some logic. For example, say you have 3 fields, P_FLD1, P_FLD2, P_FLD3. The logic is that when the user is on P_FLD1, the next cursor position should be on P_FLD2, and so on. So in your PBO, you will need to do like so. Here CURSORFIELD is the variable holding the field name that the cursor is currently on.

data: cursorfield(30) type c.
data: new_cursorfield(30) type c.

case cursorfield.
  when 'P_FLD1'.
     new_cursorfield = 'P_FLD2'.
  when 'P_FLD2'.
     new_cursorfield = 'P_FLD3'.
  when 'P_FLD3'.
     new_cursorfield = 'P_FLD1'.
endcase.

set cursor field new_cursorfield.

Regards,

Rich Heilman

0 Kudos

Hello Rich...

I have used your code example, but doesnt work...:-(

this is my code:

-


GET CURSOR FIELD cursorfield.

case cursorfield.

when 'MAKT-MAKTX'.

new_cursorfield = 'MARA-SPART'.

when others.

...

endcase.

SET CURSOR FIELD new_cursorfield.

-


what else should happen?

thanks,

0 Kudos

Make sure that you are getting the cursorfield in the PAI and setting the cursor field in the PBO.

I know that it works, I have implemented this myself, still not working, post the code in your screen flow as well as the PBO modules and PAI modules.

Regards,

Rich Heilman

0 Kudos

For example, here is the exact code which is working in my system and has been for quite a while.

The screen flow logic.

PROCESS BEFORE OUTPUT.
 MODULE STATUS_1500.

PROCESS AFTER INPUT.
 MODULE USER_COMMAND_1500.

The code for module status_1500.



************************************************************************
*      Module  STATUS_1500  OUTPUT
************************************************************************
module status_1500 output.
  set pf-status 'STDCONSOLE'.
  set titlebar '1500_07'.

<b>  set cursor field cursorfield.</b>

endmodule.


The PAI module USER_COMMAND_1500



************************************************************************
*      Module  USER_COMMAND_1500  INPUT
************************************************************************
module user_command_1500 input.

  case sy-ucomm.
    when 'ENTER'.
<b>* Scroll thru fields when user hits enter
      get cursor field cursorfield.
      case cursorfield.
        when 'P_TICNO'.
          cursorfield = 'P_PERNR'.
        when 'P_PERNR'.
          cursorfield = 'P_WERKS'.
        when 'P_WERKS'.
          cursorfield = 'P_LGORT'.
        when 'P_LGORT'.
          cursorfield = 'P_AREAC'.
        when 'P_AREAC'.
          cursorfield = 'P_TICNO'.
      endcase.</b>

    ......
   endcase.

Here I'm using the same variable CURSORFIELD for setting/getting.

Regards,

Rich Heilman

0 Kudos

Also, cursorfield is a global variable in my program and defined like this.

data:  cursorfield(20) type c.

Regards,

Rich Heilman

0 Kudos

Hi Rich...

I had the code not in PBO !

Now Its works !!

Thank you very much !!!

Former Member
0 Kudos

The problem will be that when you move the cursor using the TAB key, the process is handled by the user's PC (Windows). If you want to have the same functionality with the ENTER key, you can do it, but the process will have to go back to the screen where it will run more slowly.

Rob