‎2011 Oct 11 1:49 PM
Hi,
I have designed selection screen with two input fields and two radio buttons.
if i select one radio button the respective input field is only able take input and
the second input field should be disable mode or invisible. in the same way if i
select second radio button.. the respective input field only able take input and the rest
should be in disable mode.
i have written some code... for second radiobutton it is not working fine(respective input field in disable mode)
please see the below code and give me your suggesitons..
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : p_date FOR payr-zaldt NO-EXTENSION OBLIGATORY MODIF ID C.
SELECT-OPTIONS : s_budat FOR bkpf-budat NO-EXTENSION OBLIGATORY MODIF ID R .
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN SKIP.
PARAMETERS : rb_chek RADIOBUTTON GROUP g1 DEFAULT 'X' MODIF ID CH,
rb_rtgs RADIOBUTTON GROUP g1 MODIF ID RT.
SELECTION-SCREEN END OF BLOCK b2.
INITIALIZATION.
s_budat-high = sy-datum - 1.
APPEND s_budat.
p_date-high = sy-datum - 1.
APPEND p_date.
AT SELECTION-SCREEN OUTPUT.
IF rb_chek = 'X'.
LOOP AT SCREEN.
IF screen-group1 = 'R'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSEIF RB_RTGS = 'X'.
LOOP AT SCREEN.
screen-group1 = 'C'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
Thanks & Regards
‎2011 Oct 11 1:56 PM
Set User Command for the radiobuttons. Or else AT SELECTION-SCREEN OUTPUT will not get triggered when you click the radio button.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN SKIP.
PARAMETERS : rb_chek RADIOBUTTON GROUP g1 DEFAULT 'X' MODIF ID CH USER-COMMAND 'UC1',
rb_rtgs RADIOBUTTON GROUP g1 MODIF ID RT.
SELECTION-SCREEN END OF BLOCK b2.
‎2011 Oct 11 2:14 PM
‎2011 Oct 11 2:29 PM
Hi Anurag ,
I have modified your code and it works , please see the code below .
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : p_date FOR bkpf-budat NO-EXTENSION MODIF ID c.
SELECT-OPTIONS : s_budat FOR bkpf-budat NO-EXTENSION MODIF ID r .
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN SKIP.
PARAMETERS : rb_chek RADIOBUTTON GROUP g1 DEFAULT 'X' MODIF ID ch USER-COMMAND AR,
rb_rtgs RADIOBUTTON GROUP g1 MODIF ID rt.
SELECTION-SCREEN END OF BLOCK b2.
INITIALIZATION.
s_budat-high = sy-datum - 1.
APPEND s_budat.
p_date-high = sy-datum - 1.
APPEND p_date.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN .
IF rb_rtgs = 'X'.
IF screen-group1 = 'R'.
screen-input = 1 .
ELSEIF screen-group1 = 'C'.
screen-input = 0 .
endif .
MODIFY SCREEN.
ELSEIF rb_chek = 'X'.
IF screen-group1 = 'C'.
screen-input = 1 .
ELSEIF screen-group1 = 'R'.
screen-input = 0 .
endif .
MODIFY SCREEN.
ENDIF.
ENDLOOP.Regards
Arun
‎2011 Oct 11 2:38 PM
In AT SELECTION-SCREEN OUTPUT. Loop the screen first and set the screen-input to 0 as posted by Arun.
‎2011 Oct 11 2:31 PM
Hii Anurag,
u r question is if 1st radio button select taht time 1st input field is enable and 2nd input field disable and vicecersa ?
ok
if r1= 'X'.
loop at screen.
if screen-name = 'field2'.
screen-input = '0'.
screen-output = '0'.
endif.
modfiy screen.
else.
loop at screen.
if screen-name = 'field1'.
screen-input = '0'.
screen-output = '0'.
endif.
modfiy screen.
endloop.
this code write on PROCESS BEFORE OUTPUT side.
Hope this is helpful for u..
Regards
Vshal
Edited by: vshal13feb on Oct 11, 2011 3:31 PM
‎2011 Oct 11 2:44 PM
‎2011 Oct 12 4:51 AM
Arun,
Your code might Work, But you have Removed the keyword 'OBLIGATORY' which was the problematic part without any mention of it :). SO, you change business requirement
Anurag,
Actually, you have mentioned both your fields OBLIGATORY but you want to FILL only 1 field based on your radio button condition. This is actually your problem because SAP checks LOW field of select-options when you mark it as OBLIG.. but you need to fill only 1 field, so other field will always give an error.
So, what you need to do is that DON'T MARK it as OBLIGATORY and make them mandatory based on coding as done below.
I try to change minimum within your code.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : p_date FOR payr-zaldt NO-EXTENSION MODIF ID c. "remove OBLIGATORY
SELECT-OPTIONS : s_budat FOR bkpf-budat NO-EXTENSION MODIF ID r . "remove OBLIGATORY
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN SKIP.
PARAMETERS : rb_chek RADIOBUTTON GROUP g1 DEFAULT 'X' MODIF ID CH USER-COMMAND u1, "Add USER-COMM
rb_rtgs RADIOBUTTON GROUP g1 MODIF ID RT.
SELECTION-SCREEN END OF BLOCK b2.
INITIALIZATION.
s_budat-high = sy-datum - 1.
APPEND s_budat.
p_date-high = sy-datum - 1.
APPEND p_date.
AT SELECTION-SCREEN OUTPUT.
IF rb_chek = 'X'.
LOOP AT SCREEN.
IF screen-group1 = 'R'.
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSEIF rb_rtgs = 'X'.
LOOP AT SCREEN.
if screen-group1 = 'C'. "U missed IF HERE :), added
screen-input = 0.
MODIFY SCREEN.
endif.
ENDLOOP.
ENDIF.
"added below
START-OF-SELECTION.
if rb_chek = 'X' and p_date[] is INITIAL.
MESSAGE S208(00) with 'Date is mandatory' DISPLAY LIKE 'E'.
elseif rb_rtgs = 'X' and s_budat[] is INITIAL.
MESSAGE S208(00) with 'Date is mandatory' DISPLAY LIKE 'E'.
endif.
"also it is better to add 01.01.0001 in your LOW date fields rather that leaving it blank for clarity
‎2011 Oct 12 5:54 AM
‎2011 Oct 12 5:19 AM
Hi anurag. radha
Try this way,
selection-screen begin of screen 100.
SELECT-OPTIONS : p_date FOR payr-zaldt NO-EXTENSION OBLIGATORY MODIF ID C.
selection-screen end of screen 100.
selection-screen begin of screen 200.
SELECT-OPTIONS : s_budat FOR bkpf-budat NO-EXTENSION OBLIGATORY MODIF ID R .
selection-screen end of screen 200.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
SELECTION-SCREEN SKIP.
PARAMETERS : rb_chek RADIOBUTTON GROUP g1 DEFAULT 'X' MODIF ID CH,
rb_rtgs RADIOBUTTON GROUP g1 MODIF ID RT.
SELECTION-SCREEN END OF BLOCK b2.
if rb_chek = 'X'.
call selection-screen 100 starting at 10 10 ending at 100 10.
else.
call selection-screen 200 starting at 10 10 ending at 100 10.
endif.
Regards,
koolspy.
‎2011 Oct 12 5:25 AM
you have to use 'screen-invisible' to maintain visibility,and you have to use this one in loop and endloop.
regards,
PavanKumar.G
‎2011 Oct 12 5:26 AM
you have to use 'screen-invisible' to maintain visibility,and you have to use this one in loop and endloop.
regards,
PavanKumar.G