Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
SAP Community Downtime Scheduled for This Weekend

Date Problem

Former Member
0 Kudos
148

Hi,

Is it possible to set the default value in select options & at the same time make that field mandatory??

Pls suggest me asap.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
124

Hi ,

Yes it is possible,

syntax is:

select-options: s_vendor for lfa1-lifnr default '20001355' obligatory.

if you want to fill more than one value then ,

REFRESH s_mwskz.

CLEAR s_mwskz.

SELECT mwskz INTO s_mwskz-low

FROM t007a CLIENT SPECIFIED

WHERE mandt = sy-mandt

AND kalsm = 'TAXINN'

AND mwart = 'V'.

s_mwskz-sign = 'I'.

s_mwskz-option = 'EQ'.

APPEND s_mwskz.

ENDSELECT.

9 REPLIES 9

Former Member
0 Kudos
124

Yes this is possible. You can use F1 help to get the exact syntax.

REWARDS IF HELPFUL!!

Former Member
0 Kudos
124

Hi,

Put "obligatory" at the end.

select-options : s_lifnr for lfa1-lifnr obligatory.

Thanks,

Reward If Helpful.

Former Member
0 Kudos
124

Hi,

Yes , It is possible to have default value and mandtory too...

Refer below link

parameters: sdate like sy-datum default sy-datum obligatory.

Hope this info will help you.Rewards points if useful.

With Regards,

K K V

Former Member
0 Kudos
124

Yes you can do so

you can do so

pass the default value from the initialization event

and make the mandatory when declaring the select-options

Regards,

siva.

Former Member
0 Kudos
125

Hi ,

Yes it is possible,

syntax is:

select-options: s_vendor for lfa1-lifnr default '20001355' obligatory.

if you want to fill more than one value then ,

REFRESH s_mwskz.

CLEAR s_mwskz.

SELECT mwskz INTO s_mwskz-low

FROM t007a CLIENT SPECIFIED

WHERE mandt = sy-mandt

AND kalsm = 'TAXINN'

AND mwart = 'V'.

s_mwskz-sign = 'I'.

s_mwskz-option = 'EQ'.

APPEND s_mwskz.

ENDSELECT.

Former Member
0 Kudos
124

Hi Neha,

It is possible to set the default value in select options & at the same time make that field mandatory. Please have a look at the given example.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.

SELECT-OPTIONS : s_mtart FOR mara-mtart obligatory.

SELECTION-SCREEN END OF BLOCK b2.

INITIALIZATION.

s_mtart-sign = 'E'.

s_mtart-option = 'EQ'.

s_mtart-low = 'RELI'.

APPEND s_mtart.

s_mtart-sign = 'E'.

s_mtart-option = 'EQ'.

s_mtart-low = 'DOC'.

APPEND s_mtart.

Hope this will resolve ur problem.

former_member194152
Contributor
0 Kudos
124

hi neha,

use code like..

Tables : MKPF

select-options : budat for mkpf-Budat default sy-datum to sy-datum obligatory.

Regards

Gagan

Former Member
0 Kudos
124

Hi,

For mandatory field you can specify "OBLIGATORY".

To assign default values to a selection criterion, you use the following syntax:

SELECT-OPTIONS <seltab> FOR <f> DEFAULT <g> [TO <h>] ....

Default values <g> and <h> can be literals or field names. You can only use fields that contain a value when the program is started. These fields include several predefined data objects.

For each SELECT-OPTIONS statement, you can specify only one DEFAULT addition. This means that you can fill only the first row of selection table <seltab> with default values. To fill more rows with default values, the selection table must be processed before the selection screen is called, for example, during the AT SELECTION-SCREEN -OUTPUT event.

You use the DEFAULT addition as follows to address the individual components of the first row:

To fill only the LOW field (single field comparison), use:

........DEFAULT <g>.

To fill the LOW and HIGH fields (range selection), use:

........DEFAULT <g> TO <h>.

To fill the OPTION field, use:

........DEFAULT <g> [to <h>] OPTION <op>.

For single field comparisons, <op> can be EQ, NE, GE, GT, LE, LT, CP, or NP. The default value is EQ. For range selections, <op> can be BT or NB. The default value is BT.

To fill the SIGN field, use:

........DEFAULT <g> [to <h>] [OPTION <op>] SIGN <s>.

The value of <s> can be I or E. The default value is I.

The input fields of the selection criterion are filled with the default values. The user can accept or change these values.

Ex

REPORT DEMO.

DATA WA_SPFLI TYPE SPFLI.

SELECT-OPTIONS AIRLINE FOR WA_SPFLI-CARRID

DEFAULT 'AA'

TO 'LH'

OPTION NB

SIGN I obligatory.

Regards,

Bhaskar

Former Member
0 Kudos
124

Hi Neha,

Use the below code.

SELECT-OPTIONS: s_date FOR sy-datum DEFAULT '20070901' TO '20070921' obligatory.

*To make S_DATE-HIGH Also mandatory.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF screen-name = 'S_DATE-HIGH'.

screen-required = '1'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.