‎2007 May 04 7:06 AM
Hi all,
How is it possible to make a select-option 'obligatory' based on some 'if-else' logic in simple ABAP code?
regards,
vishy
‎2007 May 04 7:12 AM
Hi Vishwanath,
use this statement.
select-options : s_matnr for mara-matnr obligatory.
U can use <b>Ranges</b> to make them obligatory on some if..else condition
Read help on <b>'Ranges'.</b>
Reward points if helpful.
Regards,
Hemant
‎2007 May 04 7:08 AM
Hi
Why to write code straight away you can make it as Obligatory
select-options:s_bukrs for t001-bukrs no intervals no-extension
obligatory.
Reward points if useful
Regards
Anji
‎2007 May 04 7:09 AM
You can make the entry for the field obligatory by writing obligatory itself in the select-option like this...
select-options: s_matnr type matnr obligatory.
there is no need for if endif logic..
Regards,
jayant
‎2007 May 04 7:10 AM
Hi Vishy,
Its better give like this.
SELECT-OPTIONS : s_budat FOR bkpf-budat obligatory,
s_dbacct FOR bseg-hkont obligatory,
s_cracct FOR bseg-hkont obligatory,
s_amt FOR bseg-dmbtr.
Reward for useful answers.
‎2007 May 04 7:11 AM
Hi Vishwanath ,
If you want to make a select option obligatory based on a condition then you can do it in the event AT SELECTION SCREEN , in the event if your condition is true then check if an entry is there in the select option , if it is not there then raise an error message.
Regards
Arun
‎2007 May 04 7:12 AM
Hi vishy,
we can restrict the users using Messages.
Consider this Example,
IF FIELD1 IS INITIAL AND FIELD2 IS INITIAL.
MESSAGE 'PLEASE ENTER YOUR NAME AND DOB AND PRESS ENTER' TYPE 'I'.
ENDIF.
Thanks.
Reward If Helpful.
‎2007 May 04 7:12 AM
Hi Vishwanath,
use this statement.
select-options : s_matnr for mara-matnr obligatory.
U can use <b>Ranges</b> to make them obligatory on some if..else condition
Read help on <b>'Ranges'.</b>
Reward points if helpful.
Regards,
Hemant
‎2007 May 04 7:15 AM
Hi vishwanath
Try this sample code
*****************
*selection-screen
******************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 25(23) text-002.
*SELECT-OPTIONS: s_lifnr FOR ekko-lifnr.
PARAMETERS:p_lifnr LIKE ekko-lifnr obligatory.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 25(20) text-006.
*PARAMETERS:p_ebeln LIKE ekko-ebeln obligatory.
SELECT-OPTIONS:s_ebeln FOR ekko-ebeln OBLIGATORY.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 25(23) text-003.
*PARAMETERS:p_ekorg LIKE ekko-ekorg.
*SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 25(20) text-004.
*PARAMETERS:p_werks LIKE ekpo-werks obligatory.
*SELECT-OPTIONS: S_werks FOR ekpo-werks obligatory.
SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN COMMENT 25(23) text-005.
*SELECT-OPTIONS:s_bedat FOR ekko-bedat.
*SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_data.
PERFORM field_catalog.
PERFORM display_data.
END-OF-SELECTION.
Rewards if helpfull
Regards,
Pavan
‎2007 May 04 7:18 AM
Hi,
Try this and reward points if it helps.
tables mara.
select-options s_matnr for mara-matnr obligatory.
initialization.
loop at screen.
if screen-name = 'S_MATNR-HIGH'.
screen-required = '1'.
modify screen.
endif.
endloop.
‎2007 May 04 7:45 AM
Thanks all for the overwhelming response, but the requirement is like:
there is a check box and a select-option in the same selection screen. Whenever the check box is checked, the select-option should be made obligatory. How can this be achieved? I hope this is more clear.
Regards,
Vishy.
‎2007 May 04 7:55 AM
Hi Vishwanath ,
Here is a sample code for your requirement.
Tables : mard.
parameters : p_test as checkbox USER-COMMAND test .
select-options : s_matnr for mard-matnr.
data : v_flag type c..
at selection-screen output.
clear v_flag.
loop at screen.
if screen-name = 'S_MATNR-LOW'.
if p_test is initial.
screen-REQUIRED = '0'.
else.
screen-REQUIRED = '1'.
endif.
MODIFY SCREEN.
ENDIF.
endloop.But this has one shortcomming , once you make the select option obligatory by checking the check box , and then you uncheck the check box , the select option remains obligatory .
So a better solution would be as i said in my previous post , check if the check box is checked in the event AT SELECTION SCREEN and if if is checked then check is values have been entred in the select option.
Feel free to revert back in case of further queries.
Regards
Arun
‎2007 May 07 11:07 AM
Hi,
Another way is to do that with validations.
tables mara.
parameters c1 as checkbox .
select-options s_matnr for mara-matnr .
at selection-screen output.
if c1 = 'X' and s_matnr[] is initial.
message s000 with 'Enter values in s_matnr' .
leave list-processing.
endif.
write 'Correct'.
‎2007 May 04 8:05 AM
Hi,
Try this.After you pressed enter,you can see the fields are made obligatory.
tables mara.
parameters c1 as checkbox .
select-options s_matnr for mara-matnr .
at selection-screen output.
if c1 = 'X'.
loop at screen.
if ( screen-name = 'S_MATNR-HIGH' or screen-name = 'S_MATNR-LOW' ) .
screen-required = '1'.
modify screen.
endif.
endloop.
endif.
‎2007 May 07 1:23 PM
hi,
selection-screen : begin of block blk1 with frame title text-001.
select-option : s_werks for marc-werks obligatory,
s_matnr for mara-matnr obligatory.
selection-screen : end of block blk1.
reward with points if helpful
‎2007 May 07 1:40 PM
u can use keywords like no-intervals and no extension for select options to make as a parameter.
ex: s_matnr like mara-matnr no-intervals no extensions.
then s_matnr acts as a simple parameter.