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: 

SET CURSOR ON PARTICULAR INPUT/OUTPUT FIELD OF THE DIALOG SCREEN

0 Kudos

Hello ABAPers,

I have gone through many threads but did not find the solution. My requirement is that I am taking screen elements from table on the screen and I am performing validations on each field of the screen. Now, what I want now is that after failing of validation cursor focus should come on a particular field of the dialog screen where validation is failed.

I am using like this

SET CURSOR FIELD 'ZDB_TUSER-USER_EMPNAME'.


but still not getting cursor on this field.

Please help me..


points will be rewarded..

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

May this sample code help you out,

REPORT xyz

DATA:  field1(14) TYPE c, field2(14) TYPE c, field3(14) TYPE c,
       name(10) TYPE c.

SELECTION-SCREEN BEGIN OF BLOCK bloc WITH FRAME.
PARAMETERS: def RADIOBUTTON GROUP rad,
            txt RADIOBUTTON GROUP rad,
            f1  RADIOBUTTON GROUP rad,
            f2  RADIOBUTTON GROUP rad,
            f3  RADIOBUTTON GROUP rad.
SELECTION-SCREEN END OF BLOCK bloc.

PARAMETERS pos TYPE i.

IF txt = 'X'.
  name = 'TEXT'.
ELSEIF f1 = 'X'.
  name = 'FIELD1'.
ELSEIF f2 = 'X'.
  name = 'FIELD2'.
ELSEIF f3 = 'X'.
  name = 'FIELD3'.
ENDIF.

CALL SCREEN 100.

MODULE cursor OUTPUT.
  IF def NE 'X'.
    SET CURSOR FIELD name OFFSET pos.
  ENDIF.
  SET PF-STATUS 'SCREEN_100'.
ENDMODULE.

MODULE back INPUT.
  LEAVE SCREEN.
ENDMODULE.

14 REPLIES 14

rodrigo_paisante3
Active Contributor
0 Kudos

Hi.

Are you using set cursor field command at PBO?

Regards

0 Kudos

Hi Rodrigi,

no, I am using it in PAI..

0 Kudos

hum..

i think it does not work at PAI, only in PBO!

0 Kudos

Hi

Try using the set cursor field in PBO.

Warm Regards

Suneesh

Former Member
0 Kudos

Hi,

May this sample code help you out,

REPORT xyz

DATA:  field1(14) TYPE c, field2(14) TYPE c, field3(14) TYPE c,
       name(10) TYPE c.

SELECTION-SCREEN BEGIN OF BLOCK bloc WITH FRAME.
PARAMETERS: def RADIOBUTTON GROUP rad,
            txt RADIOBUTTON GROUP rad,
            f1  RADIOBUTTON GROUP rad,
            f2  RADIOBUTTON GROUP rad,
            f3  RADIOBUTTON GROUP rad.
SELECTION-SCREEN END OF BLOCK bloc.

PARAMETERS pos TYPE i.

IF txt = 'X'.
  name = 'TEXT'.
ELSEIF f1 = 'X'.
  name = 'FIELD1'.
ELSEIF f2 = 'X'.
  name = 'FIELD2'.
ELSEIF f3 = 'X'.
  name = 'FIELD3'.
ENDIF.

CALL SCREEN 100.

MODULE cursor OUTPUT.
  IF def NE 'X'.
    SET CURSOR FIELD name OFFSET pos.
  ENDIF.
  SET PF-STATUS 'SCREEN_100'.
ENDMODULE.

MODULE back INPUT.
  LEAVE SCREEN.
ENDMODULE.

nabheetscn
Active Contributor
0 Kudos

Hi

Please dont use words like points will be rewarded...We are not here for points.

Coming to your question are you throwing some error mesage if yes when are you calling set cursor after message or before?

Nabheet

0 Kudos

Sorry to all ABPers,

Yes Nabheet, I am throwing error message in PAI. After that I am calling SET CURSOR in PAI itself.

My code will be like this

START OF THE CODE



MODULE user_command_0101 INPUT.


CASE ok_code.

     WHEN 'TR_CREATE'.      
       IF zdb_tuser-user_empid IS NOT INITIAL.
              FIND FIRST OCCURRENCE OF REGEX '[[:punct:]]' IN zdb_tuser-user_empid. "regular expression validation for alphanumeric field
              IF sy-subrc = 0.                                 

                    MESSAGE 'PLEASE ENTER ONLY ALPHANUMERIC VALUES IN EMPLOYEE ID.' TYPE 'I' DISPLAY LIKE 'E'.

                    SET CURSOR FIELD 'zdb_tuser-user_empid'.

              ENDIF.

       ENDIF.

ENDCASE.

              

0 Kudos

Hi Dhammadeep,

Please refer this document.

Setting the Cursor Position (SAP Library - SAP NetWeaver by Key Capability)

Move the code for check and SET CURSOR to PBO. I think it will work.

Regards,

Anoop

0 Kudos

Hi,

Try like this .

IN PAI

     IF zapt_cust_detail-cname IS INITIAL.

       SET CURSOR FIELD 'ZAPT_CUST_DETAIL-CNAME'.

       MESSAGE e015.

     ENDIF.

0 Kudos

Hi,

Try to use the message type 'E' or use the exit command to stop the flow of the program.

Regards,

Riju Thomas.

Former Member
0 Kudos

Hi,


In PBO, use statement SET CURSOR FIELD to control where the cursor will be .... also, create some flag to tell you what field to choose in every interaction.


Regards,

Thiru.

Former Member
0 Kudos

0 Kudos

Hello,

Thank you all. I solve it. Set cursor statement should be in PBO. I have maintain flag for each validation and checking in PBO for setting cursor

kesavadas_thekkillath
Active Contributor
0 Kudos

Did you try to validate in PAI using the FIELD statement ?

It should work. Read the f1 help.

Something like below:


FIELD: ls-matnr MODULE validate.