cancel
Showing results for 
Search instead for 
Did you mean: 

How to make selection screen field mandatory at runtime

Former Member

How to selection screen field mandatory at runtime

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member

You can use the addition 'OBLIGATORY' to make a selection screen field mandatory while declaring the same.

Eg.

PARAMETERS: p_carr TYPE spfli-carrid OBLIGATORY.

SELECT-OPTIONS : s_carr for spfli-carrid OBLIGATORY.

Former Member
0 Kudos

what's the diffirent between the at seletion-screen output and obligatory.

Former Member
0 Kudos

Using slection screen output enables the programmer to control the properties of screen field dynamically.

Let us say that we do not want to display a field in the screen if a particular checkbox is marked. This can be accomplished only via at slection screen output.

Former Member
0 Kudos

Hi,

If you make it mandatory during runtime using

screen-required = '1'.

Then you may not be able to make it not mandatory later(If the user takes some other option).

So better try with user-command option with select-option

and give message(Status) forcing the user to enter the field.

Regards,

Bejoy

ssimsekler
Active Contributor

Hi

To compile;

"OBLIGATORY" addition sets the parameter's or select-option's attribute staticaly, however it can be overwritten at

standard event 'AT SELECTION-SCREEN OUTPUT' .

Using 'AT SELECTION-SCREEN OUTPUT' event you can dynamically set selection screen field properties.

That is; it is like PBO of the selection screen. It is triggered before whenever the screen is displayed.

To change a screen field attribute, you can use 'LOOP AT SCREEN'. (no WHERE clause available)

<u><b>e.g.</b></u>


PARAMETERS p_par1 LIKE sy-datum .
....
AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN .
  IF screen-name = 'P_PAR1' . "always use uppercase"
    screen-required = '1' .
    MODIFY SCREEN . "do not forget to commit your change with this line"
  ENDIF .
ENDLOOP .

To group some fields which will be treated similar at this manner, you can group them.

For example, the code snippet below will make <i>p_par1</i> and <i>p_par2</i> obligatory at runtime.


PARAMETERS: p_par1 LIKE sy-datum MODIF ID m01 ,
            p_par2 LIKE mara-matnr MODIF ID m01 ,
            p_par3 LIKE p0001-pernr .
AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN .
  IF screen-group1 = 'M01' . "always use uppercase"
    screen-required = '1' .
    MODIFY SCREEN . "do not forget to commit your change with this line"
  ENDIF .
ENDLOOP .

For more information;

You can refer to Horst Keller's ABAP book, standard SAP courses and <a href="http://help.sap.com">online SAP Help</a>.

*--Serdar

Former Member
0 Kudos

LOOP AT SCREEN.
CASE SCREEN-NAME.
WHEN 'FIELDNAME'.
SCREEN-REQUIRED = 'X'. " or probably '1'
ENDCASE.
MODIFY SCREEN.
ENDLOOP.

For more help, you can refer PARAMETERS --> MODIF-ID

Regards,

Subramanian V.

Former Member
0 Kudos

HiKaushik,

Yes you can:

PARAMETERS:

pa_check TYPE c.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

CASE screen-name.

WHEN 'PA_CHECK'.

screen-required = '1'.

MODIFY SCREEN.

ENDCASE.

ENDLOOP.

Regards,

John.

athavanraja
Active Contributor
0 Kudos

On selection screen output .

Loop at screen .

set the scree-required field to '1' .

modify screen.

endloop .

Regards

Raja

Former Member
0 Kudos

To avoid making all the fields as mandaory it is a good practice to use screen groups for all the fields which needs to be made as mandatory and check for this group when we are looping.

Regards,

Saji.