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: 

required fields IF radio button selected

0 Kudos
328

HI All,

this is my screen :


and I want the field "Sales Organization" be required (obligatory) only if the first radio button (RB_BYSAL) selected.

screen code:

SELECTION-SCREEN BEGIN OF BLOCK by_Sales_field WITH FRAME.

PARAMETERS rb_bysal RADIOBUTTON GROUP a.


SELECTION-SCREEN SKIP 1.

SELECT-OPTIONS: so_bukrs FOR knb1-bukrs .
SELECT-OPTIONS: so_vkorg FOR knvv-vkorg OBLIGATORY .
SELECT-OPTIONS: so_vtweg FOR knvv-vtweg .
SELECT-OPTIONS: so_spart FOR knvv-spart  .
SELECT-OPTIONS: so_kunnr FOR knvv-kunnr .

SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN SKIP 1.

PARAMETERS rb_byId RADIOBUTTON GROUP a.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: so_stcd1 FOR KNA1-STCD1.

SELECTION-SCREEN END OF BLOCK by_Sales_field.

START-OF-SELECTION.


INITIALIZATION.

THANKS!

6 REPLIES 6

MateuszAdamus
Active Contributor
256

Hello alon121

Make the field not obligatory. If the radio button is selected check if Sales Organization is provided. If not raise an error.

Kind regards,
Mateusz

0 Kudos
256

thank you!

former_member1716
Active Contributor
256

Hello alon121,

Do not declare the field as obligatory, instead you can handle it in AT SELECTION SCREEN EVENT. Only then you will be able to achieve the requirement. Below code Should help you understand the concept better.

SELECTION-SCREEN BEGIN OF BLOCK by_sales_field WITH FRAME.

PARAMETERS rb_bysal RADIOBUTTON GROUP a.
SELECTION-SCREEN SKIP 1.

SELECT-OPTIONS: so_bukrs FOR knb1-bukrs .
SELECT-OPTIONS: so_vkorg FOR knvv-vkorg .
SELECT-OPTIONS: so_vtweg FOR knvv-vtweg .
SELECT-OPTIONS: so_spart FOR knvv-spart  .
SELECT-OPTIONS: so_kunnr FOR knvv-kunnr .

SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN SKIP 1.

PARAMETERS rb_byid RADIOBUTTON GROUP a.
SELECTION-SCREEN SKIP 1.
SELECT-OPTIONS: so_stcd1 FOR kna1-stcd1.

SELECTION-SCREEN END OF BLOCK by_sales_field.

AT SELECTION-SCREEN.
  IF rb_bysal IS NOT INITIAL AND so_vkorg IS INITIAL.
* HAVE YOUR MESSAGE HERE
  ENDIF.

START-OF-SELECTION.
INITIALIZATION.

Regards!

256

thank you!

raymond_giuseppi
Active Contributor
256

Easiest solution is (as already written)

  • define the field as not mandatory
  • perform an explicit check in AT SELECTION-SCEEN ON so_vkorg.

Else

  • define the field as not mandatory
  • add a dummy function code on the radiobutton (to trigger a PAI/PBO cycle)
  • in AT SELECTION-SCREEN OUTPUT change the field screen attributes (use a MODIF ID, check SCREEN-GROUP1 for this modif id and eitherSCREEN-GROUP3 = 'LOW' or 'HGH' or SCREEN-INPUT = 1 to identify fields for which SCREEN-REQUIRED value should be changed)

0 Kudos
256

thank you!