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: 

how to make mandatory optin for a field when particlr rbutton is selected

Former Member
0 Kudos

Hi All,

I am having one requirement.

In my selection screen i am having three fields they are plant , product group and purchase group. Here plant is the mandatory field in my selection screen and i am having 2 radiobuttons they are normal(r1) and live share(r2). when i select the live share radiobutton by that time plant and purchase group should be mandatory . when i select normal radiobutton plant should be mandatory. anybody can send me the code how to do this.

thanks,

maheedhar

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

write in at selection-screen event

if Rad1_share = 'X'.

if p_werks is initial and p_ekgrp is initial.

message e000 with ; enter plant and pur group'.

endif.

else.

if p_werks is initial.

message e000 with ; enter plant'.

endif.

endif.

Regards

Anji

6 REPLIES 6

Former Member
0 Kudos

Hi

write in at selection-screen event

if Rad1_share = 'X'.

if p_werks is initial and p_ekgrp is initial.

message e000 with ; enter plant and pur group'.

endif.

else.

if p_werks is initial.

message e000 with ; enter plant'.

endif.

endif.

Regards

Anji

Former Member
0 Kudos

Hi,

Use AT selection-screen on field-name.

if rb1 = 'X'.

IF PLANT-FIELD IS INITIAL.

MESSAGE E000 .

ENDIF.

ENDIF.

DO LIKE THIS.

Regards,

Santosh

Former Member
0 Kudos

Hi

Use MODIF ID

Addition 7

... MODIF ID modid

Effect

The addition MODIF ID assigns all the screen elements of the parameter to the modification group modid, which is assigned to the column group1 of the system table screen. This enables them to be modified before the selection screen is displayed, using the statement MODIFY SCREEN. The name of the modification group modid must be directly specified and can have a maximum length of three characters.

Note

The modification groups that are assigned to columns group2 and group3 of the system table screen are set when the system generates a selection screen and are described in the screen elements of a selection screen.

Example:

The elements of block b2 are assigned to the modification group bl2. A checkbox show_all allows the user to select whether or not these elements are displayed. The display is changed immediately, as selecting the checkbox triggers the event AT SELECTION-SCREEN. The function code is not required. Instead, the content of show_all is evaluated during PBO.

PARAMETERS show_all AS CHECKBOX USER-COMMAND flag.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.

PARAMETERS: p1 TYPE c LENGTH 10,

p2 TYPE c LENGTH 10,

p3 TYPE c LENGTH 10.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.

PARAMETERS: p4 TYPE c LENGTH 10 MODIF ID bl2,

p5 TYPE c LENGTH 10 MODIF ID bl2,

p6 TYPE c LENGTH 10 MODIF ID bl2.

SELECTION-SCREEN END OF BLOCK b2.

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF show_all <> 'X' AND

screen-group1 = 'BL2'.

screen-active = '0'.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

Thanks

Vasudha

former_member404244
Active Contributor
0 Kudos

Hi,

we can handle this without going for mandatory statement,by making fields editable and non editable..Becoz if we use mandatory then when u don' t fill value to it and check the radio button ,then u will get error message...Please have a look at the sample code and do like that..

PARAMETERS : p_lpn TYPE filename-pathintern

DEFAULT c_lpn OBLIGATORY , "Logical Path Name

p_aserv RADIOBUTTON GROUP grp

USER-COMMAND app, "Application server

p_afile1 TYPE filename-fileextern , "Application File

"Name for contracts

p_afile2 TYPE filename-fileextern , "Application

"FileName for

"Long text

p_aerfl1 TYPE filename-fileextern , "Error File

"forcontracts

p_aerfl2 TYPE filename-fileextern , "Error File

"for Longtext

p_pserv RADIOBUTTON GROUP grp, "Presentation Server

p_pfile1 TYPE rlgrap-filename , "Presentation File

"Name forcontracts

p_pfile2 TYPE rlgrap-filename , "Presentation File

"Name for long

"texts

p_errfl1 TYPE rlgrap-filename ,

"Error File for

"contracts

p_errfl2 TYPE rlgrap-filename . "Err File Long text

IF p_pserv IS INITIAL.

LOOP AT SCREEN.

CASE screen-name.

WHEN 'P_PFILE1'.

screen-input = 0.

MODIFY SCREEN.

WHEN 'P_PFILE2'.

screen-input = 0.

MODIFY SCREEN.

WHEN 'P_ERRFL1'.

screen-input = 0.

MODIFY SCREEN.

WHEN 'P_ERRFL2'.

screen-input = 0.

MODIFY SCREEN.

ENDCASE.

ENDLOOP.

ELSE.

LOOP AT SCREEN.

CASE screen-name.

WHEN 'P_AFILE1'.

screen-input = 0.

MODIFY SCREEN.

WHEN 'P_AFILE2'.

screen-input = 0.

MODIFY SCREEN.

WHEN 'P_AERFL1'.

screen-input = 0.

MODIFY SCREEN.

WHEN 'P_AERFL2'.

screen-input = 0.

MODIFY SCREEN.

ENDCASE.

ENDLOOP.

ENDIF.

Reward if helpful.

regards,

Nagaraj

Former Member
0 Kudos

hi

you can use loop at screen for this one.

in this

IF screen-name = ' '.

screen-input = 0.

ENDIF.

MODIFY SCREEN.

u can use like this.try on this.

Rewards points if useful .

Former Member
0 Kudos

HI

see this code and select one radiobutton and click on enter button

it will change

REPORT  ZNNR_REPORT NO STANDARD PAGE HEADING MESSAGE-ID ZNNR LINE-SIZE 100 LINE-COUNT 65(4).

*******DATA DECLARATIONS***********
DATA : BEGIN OF IT_PLANT OCCURS 0,
        MATNR LIKE MARA-MATNR,
        WERKS LIKE MARC-WERKS,
        PSTAT LIKE MARC-PSTAT,
        EKGRP LIKE MARC-EKGRP,
       END OF IT_PLANT.

DATA : BEGIN OF IT_PONO OCCURS 0,
        EBELN LIKE EKKO-EBELN,
        EBELP LIKE EKPO-EBELP,
        MATNR LIKE EKPO-MATNR,
        WERKS LIKE EKPO-WERKS,
        LGORT LIKE EKPO-LGORT,
       END OF IT_PONO.

TABLES EKKO.
*********END OF DATA DECLARATIONS**********

********SELECTION SCREEN DESIGN ***********

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER : P_WERKS LIKE MARC-WERKS MODIF ID S1.
SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.

SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.
SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS : R2 RADIOBUTTON GROUP G1.
SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK B2.


*******END OF SELECTION SCREEN DESIGN*****************

**********INITIALIZATION OF SELECTION SCREEN ELEMENTS.******

INITIALIZATION.

P_WERKS = '1000'.

S_EBELN-LOW = '4500016926'.
S_EBELN-OPTION = 'EQ'.
S_EBELN-SIGN = 'I'.
APPEND S_EBELN.
CLEAR S_EBELN.

*************END OF INITIALIZATION************************

************SCREEN MODIFICATIONS********************

AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.

    IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.
      SCREEN-REQUIRED = 1.
      MODIFY SCREEN.
    ENDIF.

    IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.
      SCREEN-REQUIRED = 1.
      MODIFY SCREEN.
    ENDIF.

  ENDLOOP.

********END OF SCREEN MODIFICATIONS*****************

<b>Reward if usefull</b>