‎2009 May 19 11:27 AM
Hi Experts,
Is it possible to make a parameter obligatory based on a certain condition on the selection screen.
Here's my code:
SELECTION-SCREEN BEGIN OF BLOCK prg_selection WITH FRAME TITLE text-001.
PARAMETERS: p_offcy RADIOBUTTON GROUP g1 DEFAULT 'X',
p_year RADIOBUTTON GROUP g1,
p_leave RADIOBUTTON GROUP g1.
SELECTION-SCREEN BEGIN OF BLOCK thr WITH FRAME TITLE text-002.
PARAMETERS: p_offdt TYPE sy-datum MODIF ID thr,
p_offkdt TYPE sy-datum MODIF ID thr.
SELECT-OPTIONS: s_konfe FOR p0002-konfe MODIF ID thr.
SELECTION-SCREEN END OF BLOCK thr.
SELECTION-SCREEN BEGIN OF BLOCK year_alw WITH FRAME TITLE text-003.
SELECTION-SCREEN: BEGIN OF LINE,
COMMENT 1(20) text-005 MODIF ID yea
FOR FIELD p_lowdt,
POSITION POS_LOW.
PARAMETERS: p_lowdt TYPE dats MODIF ID yea,
p_updt TYPE dats MODIF ID yea.
SELECTION-SCREEN: END OF LINE.
PARAMETERS: p_keydt TYPE dats MODIF ID yea.
SELECTION-SCREEN END OF BLOCK year_alw.
SELECTION-SCREEN BEGIN OF BLOCK out_leave WITH FRAME TITLE text-004.
PARAMETERS: p_lvdat TYPE dats MODIF ID lv.
SELECTION-SCREEN END OF BLOCK out_leave.
SELECTION-SCREEN END OF BLOCK prg_selection.
What I would like to have is when p_offcy is selected then the parameter p_offdt and p_offkdt should be obligatory. Or when the field P_YEAR is selected then the field P_LOWDT, P_updt and P_keydt is the one which should be obligatory.
Is there any solution for my condition?
Many Thanks
‎2009 May 19 11:31 AM
this can be checked by the following logic,
1.by using the MODIF ID you can make the required PARAMETERS to be visible or not visible as per your requirement.
this can be done by
LOOP AT SCREEN.
ENDLOOP.
2.then once a raio button is selected
you can write the logic as
if p_oofcy EQ 'X'.
check the parameter is entered or not,if not raise a message saying
Please enter the value for that paramter.
endif.
same way you can validate by using the
if p_year EQ 'X'.
check the parameters are entered or not.
endif.
‎2009 May 19 11:32 AM
Hi ,
You will have to use the event AT SELECTION SCREEN OUTPUT , in that loop at screen and check your condition and set the REQUIRED fields as X .
but i think you will have a problem , because once you make a field obligatory , you can reset it and make it optional.
so the code will look some thing like tis
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF <CONDITION>
IF SCREEN-NAME = < >
SCREEN-REQUIRED = 1.
modify screen.
ENDIF.
ENDIF.
ENDLOOP.
A better option will be not make it obligatory and check in the at selection screen event if the value is enetred and give the required maeesage .
Regards
Arun
‎2009 May 19 11:33 AM
Hi,
You cannot make the fields obkigatory so you need to handle them in AT SELECTION-SCREEN ON <Field> Event . If you make the field as obligatory using LOOP AT SCREEN then you cannot shuffle between the radio buttons with entering the obligatory fields.
Check this code..
AT SELECTION-SCREEN ON p_offdt.
IF p_offcy EQ 'X' AND p_offdt IS INITIAL.
" Error Message.
ENDIF.
AT SELECTION-SCREEN ON p_offkdt .
IF p_offcy EQ 'X' AND p_offkdt IS INITIAL.
" Error Message.
ENDIF.
AT SELECTION-SCREEN ON p_lowdt .
IF p_year EQ 'X' AND p_lowdt IS INITIAL.
" Error Message.
ENDIF.
AT SELECTION-SCREEN ON p_updt .
IF p_year EQ 'X' AND p_updt IS INITIAL.
" Error Message.
ENDIF.
and so on..
‎2009 May 19 11:33 AM
Hello,
In this way we can make the field obligatory.The error message should be in understandable formate for filling the values.
In AT SELECTION-SCREEN ON p_offdt.
check the condition of the p_offcy.
if p_offcy is initial.
then give the error message.
leave list-processing.
endif.
In AT SELECTION-SCREEN ON p_offkdt .
check the condition of the p_offcy.
if p_offcy is initial.
then give the error message.
leave list-processing.
endif.
‎2009 May 19 11:35 AM
You need to capture it by error messages in AT SELECTION-SCREEN event.
Alternatively, you can handle it in AT SELECTION-SCREEN output event, by looping at screen and based on particular radio-button selected, making the field manatory or not.
‎2009 May 19 11:36 AM
Hi,
Use the following logic
at selection-screen.
if p_offcy is not initial.
loop at screen.
if screen-name = p_offdt.
screen-required = 'X'.
endif.
if screen-name = p_offkdt .
screen-required = 'X'.
endif.
modify screen.
endloop.
endif.
if p_year is not initial.
loop at screen.
if screen-name = P_LOWDT.
screen-required = 'X'.
endif.
if screen-name = P_updt.
screen-required = 'X'.
endif.
if screen-name = P_keydt.
screen-required = 'X'.
endif.
modify screen.
endloop.
endif.
‎2009 May 19 11:36 AM
Hi,
At selection-screen on p_offcy.
LOOP AT SCREEN.
IF screen-group1 = 'THR'.
screen-Required = ' 1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
Thanks,
Bindu.
‎2009 May 19 11:37 AM
Hi,
You can achieve the following requirment by looping at the screen.
PARAMETER: rb1 TYPE char1 RADIOBUTTON GROUP rb USER-COMMAND f1,
rb2 TYPE char1 RADIOBUTTON GROUP rb.
PARAMETER: v_matnr TYPE matnr,
v_bukrs TYPE bukrs.
AT SELECTION-SCREEN OUTPUT.
IF rb2 = 'X'.
LOOP AT SCREEN.
IF screen-name = 'V_MATNR'.
screen-required = '1'.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDIF.
Regards,
Nikhil Kayal
‎2009 May 19 11:40 AM
Hi Suwardi Nursalim ,
make use of the below code.
At selection-screen.
LOOP AT SCREEN.
if p_offcy = 'x'.
if screen-name = 'p_offdt ' or screen-name = 'p_offkdt' .
SCREEN-REQUIRED = 'X'.
endif.
elseif p_year = 'X'.
if screen-name = 'P_LOWDT' or screen-name = 'P_updt' or screen-name = 'P_keydt .
SCREEN-REQUIRED = 'X'.
endif.
endif.
MODIFY SCREEN.
ENDLOOP.
‎2009 May 19 11:58 AM
try it this way:
AT SELECTION-SCREEN ON p_offdt.
IF p_offcy eq 'X'.
IF p_offdt is initial.
MESSAGE 'enter a value in p_offdt' type 'E'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON p_offkdt.
IF p_offcy eq 'X'.
IF p_offkdt is INITIAL.
MESSAGE 'enter a value in p_offkdt' type 'E'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON p_lowdt.
IF p_year eq 'X'.
IF p_lowdt is initial.
MESSAGE 'enter a value in p_lowdt' type 'E'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON p_updt.
IF p_year eq 'X'.
IF p_updt is INITIAL.
MESSAGE 'enter a value in p_updt' type 'E'.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON p_keydt.
IF p_year eq 'X'.
IF p_keydt is INITIAL.
MESSAGE 'enter a value in p_keydt' type 'E'.
ENDIF.
ENDIF.With luck,
Pritam.