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 give error message while saving

Former Member
0 Likes
1,026

Hi Friends,

I have four input fields,I want to restrict the user from entering in more than one field.If it is so i have to give error message while saving saying that he should not enter in more than one field.

How to achieve this.....

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
934

Hi,

You can achieve this with foloowing:


PARAMETERS: p_a TYPE c,
            p_b TYPE c,
            p_c TYPE c,
            p_d TYPE c.
DATA : flag TYPE i VALUE 0.

AT SELECTION-SCREEN.
  IF p_a IS NOT INITIAL.
    flag = flag + 1.
  ENDIF.
  IF p_b IS NOT INITIAL.
    flag = flag + 1.
  ENDIF.

  IF p_c IS NOT INITIAL.
    flag = flag + 1.
  ENDIF.

  IF p_d IS NOT INITIAL.
    flag = flag + 1.
  ENDIF.
  IF flag > 1.
    MESSAGE e000(00) WITH 'No input in more than 1 fields'.
  ENDIF.

Regards,

Mansi.

7 REPLIES 7
Read only

former_member156446
Active Contributor
0 Likes
934

you will use at selection screen event

at selection- screen.

if not p_1 is initial.
    if not p_2 is initial or if not p_3 is initial or if not p_4 is initial.
         error message...
    endif.
endif.
     
if not p_2 is initial.
    if not p_1 is initial or if not p_3 is initial or if not p_4 is initial.
         error message...
    endif.
endif.
,,,,,,
,,,,,

Read only

Former Member
0 Likes
935

Hi,

You can achieve this with foloowing:


PARAMETERS: p_a TYPE c,
            p_b TYPE c,
            p_c TYPE c,
            p_d TYPE c.
DATA : flag TYPE i VALUE 0.

AT SELECTION-SCREEN.
  IF p_a IS NOT INITIAL.
    flag = flag + 1.
  ENDIF.
  IF p_b IS NOT INITIAL.
    flag = flag + 1.
  ENDIF.

  IF p_c IS NOT INITIAL.
    flag = flag + 1.
  ENDIF.

  IF p_d IS NOT INITIAL.
    flag = flag + 1.
  ENDIF.
  IF flag > 1.
    MESSAGE e000(00) WITH 'No input in more than 1 fields'.
  ENDIF.

Regards,

Mansi.

Read only

0 Likes
934

You can also check for each selection field that it is filled or not??

If more than one is NOT INITIAL. Give the error message.

Read only

Former Member
0 Likes
934

hi,

PARAMETERS: p_a TYPE c,

p_b TYPE c.

AT SELECTION-SCREEN.

IF SY-UCOMM = 'SAVE'.

CLEAR FLAG. "OTHER WISE FOR EVERY INPUT GET INCREMENT

IF p_a IS NOT INITIAL.

flag = flag + 1.

ENDIF.

IF p_b IS NOT INITIAL.

flag = flag + 1.

ENDIF.

IF flag > 1.

MESSAGE e000(00) WITH 'No input in more than 1 fields'.

ENDIF.

ENDIF.

Read only

Former Member
0 Likes
934

Hi ,

In AT SELECTION-SCREEN event.

if p1_a is not initial.

and if p1_b is not initial and if p1_c is not initial and ....

dispaly the error message

MESSAGE 'You have entered more than one text box. Enter only one' TYPE 'E'.

Check the rest of the text boxes also

Hope it helps

Read only

0 Likes
934

thanks mansi...solved

Read only

Former Member
0 Likes
934

hi,

there two ways one is after enter one value u can disable the other fields ..

or else u can check each field in AT selection-screen event ..

and u can give proper message.