2006 May 24 10:21 PM
Hi folks,
I need to display slection screen fileds with obligatory function but i have 3 radiao button, but i need to make selection screen fileds obligatory only when we select rb1 not for all radiao button. When i try to use obligatory command its validating for all radio buttions, but it should valide when rb1 = 'x'.when we select rb2 it should not validate sleection screen fields. I tryied using if condition in at select-screen, but it is checking before entering any value or when we select radio button also.
Please give me ur valuable inputs, thanks.
Regards
Rajesh
2006 May 24 10:31 PM
It's what I have been trying to do since I can remember and unfirtunately what I know, is impossible. The OBLIGATORY check takes place before anything we program and therefore is sort of indispensable. But for most practical purposes, there are work aorunds. e.g. if you want to make a field mandatory depending upon rb chosen, my preferable way is:
AT SELECTION-SCREEN output.
<check if the radio button is checked>
screen-required = 1 or 0 (depending upon whether you want to make or mandatory or not).
modify screen.
Hi Sandip/Rich ,
THanks for your valuable inputs , I already tried with validating using if condition in at selection-screen. But its giving message for input even if we select radio button. I dont want to get msg when i am selecting different radion button. Any way to do this, pls let me know. Thnaks.
Regards
Rajesh
2006 May 24 10:31 PM
It's what I have been trying to do since I can remember and unfirtunately what I know, is impossible. The OBLIGATORY check takes place before anything we program and therefore is sort of indispensable. But for most practical purposes, there are work aorunds. e.g. if you want to make a field mandatory depending upon rb chosen, my preferable way is:
AT SELECTION-SCREEN output.
<check if the radio button is checked>
screen-required = 1 or 0 (depending upon whether you want to make or mandatory or not).
modify screen.
2006 May 24 11:07 PM
Sandip is right, the "Required" will not work for you because it will stop you when switching the radiobuttons. You will have to check the fields manually.
at selection-screen.
if p_rad1 = 'X'
and p_field1 is initial.
message e001(00) with 'Please enter a value in field 1'.
endif.
if p_rad2 = 'X'
and p_field2 is initial.
message e001(00) with 'Please enter a value in field 2'.
endif.
if p_rad3 = 'X'
and p_field3 is initial.
message e001(00) with 'Please enter a value in field 3'.
endif.
Regards,
Rich Heilman
2006 May 24 11:18 PM
For example, check this program, you will notice that when you try to switch radiobuttons, the first field still remains as required. There is really nothing that can be done about that.
report zrich_0001.
parameters: p_rad1 radiobutton group grp1 default 'X'
parameters: p_rad2 radiobutton group grp1.
parameters: p_rad3 radiobutton group grp1.
parameters: p_field1 type c.
parameters: p_field2 type c.
parameters: p_field3 type c.
at selection-screen output.
loop at screen.
screen-required = '0' .
case screen-name.
when 'P_FIELD1'.
if p_rad1 = 'X'.
screen-required = '1'.
endif.
when 'P_FIELD2'.
if p_rad2 = 'X'.
screen-required = '1'.
endif.
when 'P_FIELD3'.
if p_rad3 = 'X'.
screen-required = '1'.
endif.
endcase.
modify screen.
endloop.
You will have to check them manually.
Regards,
Rich Heilman
2006 May 24 11:20 PM
HEre is the complete solution.
report zrich_0001.
parameters: p_rad1 radiobutton group grp1 default 'X'.
parameters: p_rad2 radiobutton group grp1.
parameters: p_rad3 radiobutton group grp1.
parameters: p_field1 type c.
parameters: p_field2 type c.
parameters: p_field3 type c.
at selection-screen.
if p_rad1 = 'X'
and p_field1 is initial.
message e001(00) with 'Please enter a value in field 1'.
endif.
if p_rad2 = 'X'
and p_field2 is initial.
message e001(00) with 'Please enter a value in field 2'.
endif.
if p_rad3 = 'X'
and p_field3 is initial.
message e001(00) with 'Please enter a value in field 3'.
endif.
Regards,
Rich Heilman
2006 May 24 11:50 PM
Rich, Kudos!! I gave Rajesh the wrong solution (probably too much drink for me!!), and thanks a lot for the correction.
Rajesh, the solution I gave (modify screen) works fine as long as you have some value given in the field you are trying to make (or break) mandatory. But the most neat solution is to check whether there is a value in the field, and if not, put a message <the field is mandatory>.
2006 May 25 12:38 AM
Hi Sandip/Rich ,
THanks for your valuable inputs , I already tried with validating using if condition in at selection-screen. But its giving message for input even if we select radio button. I dont want to get msg when i am selecting different radion button. Any way to do this, pls let me know. Thnaks.
Regards
Rajesh
2006 May 25 12:46 AM
2006 May 25 12:48 AM
Hi Rajesh,
To make this work the way you want, do not define the select-option or parameter as obligatory (as Sandip pointed out). Do that only as shown in the code samples provided by Rich. Regards,
Den
2006 May 25 12:56 AM
2006 May 25 1:29 AM
Rich,
You didn't get my qsn. As you said it is working fine but my problem is , even when i click on radio button to change from rb1 to rb2 or rb3, its triggering error msg. But i need to get error msg only after selecting the rb and if dont enter the required value. This is what i am asking since i posted my qsn. Below is my code. Pls check.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
select-options : s_bukrs for REGUH-ZBUKR MODIF ID M1 no intervals no-extension ,
s_laufd for REGUH-LAUFD MODIF ID M1 no intervals no-extension ,
S_LAUFI FOR REGUH-LAUFI MODIF ID M1 no intervals no-extension ,
s_BLART for bsad-BLART MODIF ID M1,
s_kunnr for REGUH-kunnr MODIF ID M1.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS : RB1 RADIOBUTTON GROUP G1,
RB2 RADIOBUTTON GROUP G1 ,
RB3 RADIOBUTTON GROUP G1 .
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
PARAMETERS : FNAME LIKE RLGRAP-FILENAME modif id M2. " no-display .
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN END OF BLOCK B2.
----
EVENT: validate users entries on the selection screen *
----
AT SELECTION-SCREEN output.
LOOP AT SCREEN.
if SCREEN-GROUP1 = 'M2'.
IF RB2 = 'X'.
SCREEN-input = '1'.
MODIFY SCREEN.
ELSE.
SCREEN-input = '0'.
MODIFY SCREEN.
endif.
endif.
ENDLOOP.
AT SELECTION-SCREEN.
IF RB1 = 'X'.
IF S_BUKRS is initial.
MESSAGE E000 WITH 'Enter the Company Code'.
EXIT.
elseif s_laufd is initial.
message E000 with 'Enter clearing date'.
exit.
elseif s_laufi is initial.
message E000 with 'Enter the identification'.
EXIT.
else.
SELECT SINGLE * FROM REGUH WHERE ZBUKR IN S_BUKRS and LAUFD IN S_LAUFD. " AND LAUFI IN S_LAUFI.
IF SY-SUBRC NE 0.
message E000 with 'No records found for this selection'.
exit.
ELSE.
MOVE REGUH-LAUFD TO I_LAUFD.
MOVE REGUH-LAUFI TO I_LAUFI.
ENDIF.
ENDIF.
elseif RB2 = 'X'.
if fname is initial.
MESSAGE E000 WITH 'Enter the file path'.
exit.
endif.
elseif RB3 = 'X'.
IF S_BUKRS is initial.
MESSAGE E000 WITH 'Enter the Company Code'.
EXIT.
ELSEIF s_laufd is initial.
MESSAGE E000 WITH 'Enter the Clearing Date'.
exit.
else.
SELECT SINGLE * FROM BSAD
WHERE BUKRS IN S_BUKRS AND AUGDT IN s_laufd AND BLART = 'ZX'.
IF SY-SUBRC <> 0.
message E000 with 'No records found for this selection'.
EXIT.
ENDIF.
ENDIF.
endif.
2006 May 25 1:36 AM
I have tried your code with some modifications since I am running it on a was 7.0 system. But it does not fire any messages when change the radiobuttons. It does fire the message when pressing enter after changing the radiobutton. Is this not the behavior that you are looking for?
Regards,
Rich Heilman
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |