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

how to validate screen fields from different tables

Former Member
0 Likes
496

hai,

how to validate screen fields from different tables,

the requirement is, if i enter value in first screen, if entry exits in any one of three tables its displays error message in status bar other wise is goes to next screen.plz forward this soultion as early as possible.

hai,

how to validate screen fields from different tables,

the requirement is, if i enter value in first screen, if entry exits in any one of three tables its displays error message in status bar other wise is goes to next screen.plz forward this soultion as early as possible.

3 REPLIES 3
Read only

Former Member
0 Likes
434

Hi satya,

1. I would personally do like this.

2. data : flag1 type c,

flag2 type c,

flag3 type c.

select * from table1 where condtion.

if sy-subrc = 0.

flag1 = 'X'.

endif.

select * from table2 where condtion.

if sy-subrc = 0.

flag2 = 'X'.

endif.

select * from table3 where condtion.

if sy-subrc = 0.

flag3 = 'X'.

endif.

If flag1 = 'X' or flag2 = 'X' or flag3 = 'X'.

message 'Entry already exists' Type 'E'.

endif.

set screen 2000.

regards,

amit m.

Read only

Former Member
0 Likes
434

Hi

do like this

initialization.

data : flag1 type c.

At-selection-screen on <fieldname>.

select * from table1 where condtion.

if sy-subrc = 0.

flag1 = 'X'.

endif.

select * from table2 where condtion.

if sy-subrc = 0.

flag1 = 'X'.

endif.

select * from table3 where condtion.

if sy-subrc = 0.

flag1 = 'X'.

endif.

If flag1 = 'X'

message 'Entry already exists' Type 'E'.

endif.

This will work.

If helpful Pls reward me points.

Regards

Manas Ranjan Panda

Read only

Former Member
0 Likes
434

Try:


SELECT SINGLE field1 from tab1 into f1.
IF sy-subrc <> 0.
  SELECT SINGLE field1 from tab2 into f1.
    IF sy-subrc <> 0.
      SELECT SINGLE field1 from tab3 into f1.
    ENDIF.
  ENDIF.
ENDIF.

IF sy-subrc = 0.
  MESSAGE E(001) WITH 'Field exists'.
ENDIF.

This method avoids unnecessary SELECTS.

Rob