07-03-2013 12:43 PM
Hi All,
I have 2 radio buttons , say A and B . And 1 Field say FIELD1 which is disabled by deafult.
Now if I select Radio button A , Field1 Should become mandatory
Whereas If I select radio button B then - field A should be disabled again
Now if I declare field 1 as mandatory, the problem is that if the user selects A, which Enables Field 1 and then
he changes his mind and wants to select radio button B instead. He gets an error since Field 1 has become
enabled and mandatory...
How do we handle this problem. Please help
Regards,
Faiz
07-03-2013 12:51 PM
Instead of obligatory addition, u need to put coding in AT selection screen event or start-of-selection, based on radiobutton click, and raised a error message over thr
07-04-2013 6:14 AM
Hi Gagan ,
I've tried putting the code in AT SELECTION SCREEN, but it doesn't work simply because AT SELECTION SCREEN events triggers before AT SELCTION SCREEN OUTPUT.
Therefore, If the end user selects the other radio button. The field corresponding to it doesnt not get enabled and the user gets the error msg 'Fill in the mandatory fileds'.
Regards,
Faiz
07-04-2013 6:27 AM
Put the disabling code based on radio button in the AT SELECTION-SCREEN OUTPUT. And the mandatory check in START_OF_SELECTION. Refer the code I have given below. It works perfectly fine for me.
07-03-2013 12:51 PM
Hi,
Check the below link to know the possible attributes that you can set AT SELECTION SCREEN event by looping on the SCREEN table.
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbab6f35c111d1829f0000e829fbfe/content.htm
The attribute REQUIRED & OUTPUT should help you achieve the same. Check the snippet below:
http://wiki.sdn.sap.com/wiki/display/Snippets/USE+OF+AT+SELECTION-SCREEN+OUTPUT
Cheers,
Arindam
07-03-2013 12:55 PM
Hi Faizur,
One way of addressing your issue is making the input field as RECOMMENDED instead of REQUIRED via screen painter.
Then write logic to check and validate that input field.
Regards.
07-03-2013 1:10 PM
Hi,
Write to code in AT SELECTION SCREEN.
LOOP AT SCREEN.
IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
Regards,
Kumar.
07-03-2013 1:03 PM
Hi Faizur,
Gagan is right..... Dont make it obligatory instead put a check in At Selection screen that if radio button A is selected and Field is initial then throw an error meesage.
This will solve your problem.
Thanks,
Jyoti
07-03-2013 1:12 PM
PARAMETER : r_a RADIOBUTTON GROUP rad1 USER-COMMAND fc ,
r_b RADIOBUTTON GROUP rad1 .
parameter belnr type belnr.
AT SELECTION-SCREEN output.
LOOP AT SCREEN.
if screen-name = 'BELNR'.
IF r_a = 'X'.
screen-input = 1.
ELSEIF r_b = 'X'.
screen-input = 0.
ENDIF.
MODIFY SCREEN.
endif.
ENDLOOP.
START-OF-SELECTION.
if r_a = 'X' and belnr is INITIAL.
MESSAGE 'Enter values' type 'I'.
exit.
endif.
07-03-2013 1:20 PM
Hi,
Use AT SELECTION SCREEN event.
in the SCREEN structure, there is a field REQUIRED. If you want to make it mandatory then set the value to 1 and when not to make mandatory set to 0.
Sample code based on Susmitha logic.
PARAMETER : r_a RADIOBUTTON GROUP rad1 USER-COMMAND fc ,
r_b RADIOBUTTON GROUP rad1 .
PARAMETER belnr TYPE belnr.
AT SELECTION-SCREEN.
LOOP AT SCREEN.
IF screen-name = 'BELNR'.
IF r_a = 'X'.
screen-required = 1.
ELSEIF r_b = 'X'.
screen-required = 0.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
Thanks & Regards
Bala Krishna
Message was edited by: Bala Krishna
07-04-2013 7:01 AM
hi,
check this sample code.
REPORT ZSCN_TEST1.
tables mara.
PARAMETERS : P_PRRAN TYPE char4 OBLIGATORY MODIF ID DI1 .
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-006.
PARAMETERS: R3 RADIOBUTTON GROUP RAD1 USER-COMMAND FLAG.
PARAMETERS: R4 RADIOBUTTON GROUP RAD1 DEFAULT 'X'.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN END OF BLOCK B2.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF R3 <> 'X' AND
screen-group1 = 'DI1'.
screen-active = '0'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
for disabling the mandatory field type some thing in the input field and then click radio button ..it will disable mandatory input field....
REGARDS,
PRABHAKARAN.K
07-04-2013 7:44 AM
Hi Faizur,
1. Make input field as 'Possible' using Screen editor.
2. Use AT SELECTION-SCREEN OUTPUT and value date you input of radio button.
*SCREEN MODIFICATIONS
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN..
IF R1 = 'X' AND SCREEN-GROUP1 = 'S1'.
SCREEN-INPUT = 1.
SCREEN-REQUIRED = 1.
MODIFY SCREEN.
ENDIF.
IF R2 = 'X' AND SCREEN-GROUP1 = 'S1'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
*SCREEN VALIDATIONS & SELECTION AREA.
IF p_input is initial.
Message 'Please enter the input vaule' type 'E'.
ELSE.
* Start you query
ENDIF.