‎2010 Nov 09 7:47 AM
Hi All,
I am facing an issue while doing validations on selections screen of a report program.
On selecting a checkbox, a field related to that should become mandatory.
But if I do the validation in selection screen events,
for the first time also, when I select the check box, it is displaying error message saying no data in mandatory field.
So I am doing the validation in start-of-selection event.
Is there any work around for this?
Please help me in this regard.
‎2010 Nov 09 10:44 AM
Hi Nagapallavi,
Try using the below statement along with your loop at screen statements
screen-required = '2'.
the above statement is make the selection fields as conditional mandatory.
Hope this may be helpful.
Regards,
Sharin.
‎2010 Nov 09 8:42 AM
HI,
You could check for the checkbox input in the event at selection on the chck box field. If the field to be made mandatory is not passed on teh selection screen, you could display an error message on the selection screen.
‎2010 Nov 09 8:45 AM
Hi,
Remove OBLIGATORY from your selection screen and do the validation on even AT SELECTION-SCREEN ON FIELD.
Regards,
Prashant
‎2010 Nov 09 9:45 AM
Hi
maybe you could try coding the validations at selection-screen.
Also remove OBLIIGATORY syntax in selection screen coding.
check the value in your check box and make the required field mandatory there.
at selection-screen.
if chk_val = 'X'.
if s_mblnr[] is initial.
if s_ebeln[] is initial.
if s_matnr is initial or s_budat is initial.
message e000(fb) with 'Enter at least a PO and material number/GR date!'.
endif.
endif.
endif.
else.
...
endif.
regards
Isaac Prince
Edited by: prince isaac on Nov 9, 2010 11:45 AM
‎2010 Nov 09 9:51 AM
HI
Thanks for your inputs.
But validating in selection screen events is not working for me, as I have user command for my check box.
ex: I tick my check box, as there is a user command for that, the selection screen events get triggered, and it displays the error message saying 'NO data entered' , even if the user plans to enter a message now.
‎2010 Nov 09 10:01 AM
Hi
If these are selection screen checks you want to employ i would suggest removing the user-command and impleneting the checks at selection screen. I think its much easier to do so.
regards
Isaac Prince
‎2010 Nov 09 10:15 AM
Hi
Based on the checkbox selected or not, some of the selection screen fields have to be disabled in my program, so I should have user command edition to my check box.
‎2010 Nov 09 10:34 AM
Hi,
If you are using a radio button or a Check box You should give USER-COMMAND addition to the declarations.So when an user clicks on these boxes or buttons the fcode(Function code) which you mentioned in user-command gets populated in SY-UCOMM.
Best Regards,
lakshman.
‎2010 Nov 09 10:40 AM
Yes this can still be achieved without the user-command code.
Place your code in at selection-screen
loop at screen.
if chk_val = 'X'.
if screen-name = 'S_MATNR'.
screen-input = 0.
endif.
else.
if screen-name = 'S_MATNR'.
screen-input = '1'.
endif.
endif.
modify screen
endloop.
I hope this is helpfull.
regards
Isaac Prince
Edited by: prince isaac on Nov 9, 2010 12:40 PM
‎2010 Nov 09 10:45 AM
Hi,
If your mandatory field is suppose 'p_field'. then write your code under AT SELECTION-SCREEN ON p_field event. p_chk is the parameter name for the checkbox. For eg:
AT SELECTION-SCREEN ON p_field.
IF p_chk = 'X'.
IF p_field IS INITIAL.
MESSAGE e000 with 'Enter mandatory field'.
ENDIF.
ENDIF.
Hope this works.
Sudip
‎2010 Nov 09 10:46 AM
Hi Prince
Thanks for you time.
I tried with this.
But when the user selects the check box, the program has to allow the user to enter the field, and when he tries to execute the same it has to throw an error.
With this code, it throws the error immediately when the check box is selected.
‎2010 Nov 09 11:07 AM
‎2010 Nov 09 10:44 AM
Hi Nagapallavi,
Try using the below statement along with your loop at screen statements
screen-required = '2'.
the above statement is make the selection fields as conditional mandatory.
Hope this may be helpful.
Regards,
Sharin.
‎2010 Nov 09 10:53 AM