‎2007 Sep 26 10:13 PM
In screen painter, I have two fields er_id and er_name.In er_id I have validated
for duplication record.Once user enters er_id,I checked for its existence in its table
if exists warning message is displayed and if not exists cursor should go to next field i.e er_name.How to acheive this?My code is
select * from t1 where er_id = er_id
if sy-dbcnt <> o
message 'er id exists'
else
set cursor field 'er_name'.
endif
But this is not working,i placed above code in module m1 input',some said that set cursor should be in PBO.So I assigned boolean value to one variable and checked in PBO,even then its not working.
else
status = 'yes'.
endif
PBO:
if status = 'yes'.
set cursor field 'er_name'.
endif.
Help me.Thanks in advance.
Note : I admit that in SAP validations are not done at field level. Its just my curiosity to know.
‎2007 Sep 27 6:26 AM
Hi again.
Try the program below as a demo... it includes comments to explain... I think your problem may be that you are using lowercase in the variable name you are trying to place the cursor on, but without seeing your original code I cannot be sure.
Jonathan
report zlocal_jc_set_cursor_in_pbo.
data:
*" Dynnr fields need to be global
g_er_id(10) type c,
g_er_name(30) type c.
*=======================================================================
* Mainline
*=======================================================================
start-of-selection.
**" screen has just:
**" process before output.
**" module d9999_pbo.
**
**" process after input.
**" module d9999_pai.
*"
call screen '9999'. "screen with G_ER_ID and G_ER_NAME input fields
* "and a button with ZEXIT as fcode
*----------------------------------------------------------------------*
* MODULE d9999_pbo OUTPUT
*----------------------------------------------------------------------*
module d9999_pbo output.
*" Move cursor to second field if user keys "2" into first field in
*" prior PAI
if g_er_id = '2'.
set cursor field 'G_ER_NAME'.
endif.
endmodule.
*----------------------------------------------------------------------*
* MODULE d9999_pai INPUT
*----------------------------------------------------------------------*
module d9999_pai input.
*" Leave if they click button:
if sy-ucomm = 'ZEXIT'. "Exit button on screen has this Fcode
leave program.
endif.
endmodule. "d9999_pai INPUT