Application Development and Automation 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: 
Read only

Problem with selection screen in disabling mandatory fields

former_member1716
Active Contributor
0 Likes
5,210

Hello experts,

I have a requirement as below,

I should have two radiobuttons let it be r1 and r2, and i have two fields say f1 and f2, of which f1 is mandatory.

Now when i click r1 both the fields both the fields f1 and f2 must be disabled which i was able to acheive.

Now when i click r2 these fields f1 and f2 must be enabled, this also i acheived.

Now when again i click r1 these fields are not getting disabled and throwing an error message for filling mandatory fields, now if i fill the mandatory field and press enter the fields are getting disabled also if i fill the mandatory field and then press r1 these two fields are getting disabled.

Now when i press r1 again Can i make these two fileds disabled without filling the mandatory field.

Please help me in sorting out this issue

1 ACCEPTED SOLUTION
Read only

atul_mohanty
Active Contributor
0 Likes
3,830

Hi -

Use the event - AT SELECTION-SCREEN OUTPUT event to perform this.

Let us know, in case any further help.

Regards,

Atul Mohanty

21 REPLIES 21
Read only

Former Member
0 Likes
3,830

Hi Kumar,

       Remove the Mandatory statement in your code(Obligatory).

Read only

0 Likes
3,830

HI Kumar,

I need to mainatain the field as mandatory, that is the requirement.

Read only

atul_mohanty
Active Contributor
0 Likes
3,831

Hi -

Use the event - AT SELECTION-SCREEN OUTPUT event to perform this.

Let us know, in case any further help.

Regards,

Atul Mohanty

Read only

0 Likes
3,830

Hi Atul,

I have coded in the same event only.

Read only

0 Likes
3,830

Hi Sathish,

If you are using user command for radio button, fields should be as mandatory.

Instead of please check that field is not initial.

Then only you can disable the field.

Arivazhagan S

Read only

0 Likes
3,830

Do as mentioned below.

  • Remove obligatory check in parameter declaration.
  • Second in AT SELECTION SCREEN event put your validation as mentioned below.

if sy-ucomm eq 'ONLI'.

if field1 is initial.

message Please enter field

endif.

endif.

Nabheet

Read only

0 Likes
3,830

Can you pls explain your answer through code

This is how i declared my fields

   SELECT-OPTIONS xxx  FOR  yyy OBLIGATORY.

Read only

0 Likes
3,830


Hi nabheet,

I need to mainatain the field as mandatory, that is the requirement.

Read only

0 Likes
3,830

Hi Satish

Field will be mandatory only. Only thing is we will be checking the field via code when you execute it

Nabheet

Read only

0 Likes
3,830

Hi Satish,

As mentioned, you need to acheive the mandatory requirement by explicit coding.

You can code it either in the at selection screen event or start of selection event.

START-OF-SELECTION.
   if mnd_fld is INITIAL.
     Message 'Enter value for mand field' type 'S' display like 'E'.
     exit.
   endif.


Read only

0 Likes
3,830

Hi Satish -

You need to remove the 'OBLIGATORY' key word and write code for that in

AT SELECTION SCREEN OUTPUT event to modify the SCREEN structure Otherwise you can put some code in START OF SELECTION like check initial and throw a infornation mesaage and LEAVE LIST Processing.

Let us know , in case any further help.

Regards,

Atul Mohanty

Read only

0 Likes
3,830

Hi nabheet,

Am almost done with this requirement. Could you please explain what is this 'onli' in your code below

if sy-ucomm eq 'ONLI'.

I implemented the logic as per your advice but the problem now is error message is being thrown even when i select the first radio button and click execute

Read only

0 Likes
3,830

Create a dummy function code and attach it to the radiobutton group (option USER-COMMAND on the first button of the group) so in the AT SELECTION-SCREEN you would be able to not execute the tests for mandatory field when user just pressed the button.

* Always add a top of report
   TABLES: sscrfields.
* Attach dummy function code to radio button
   PARAMETERS: b1 RADIOBUTTON GROUP radi USER-COMMAND but DEFAULT 'X'.
   " (...)
* Validations in PAI
AT SELECTION-SCREEN.
   CASE sscrfields-ucomm.
     WHEN 'BUT'.
       " ignore
     WHEN 'ONLI' OR 'PRIN'.
       " perform "heavy checks" only when Execute/Print (select single from transaction data)
       " perform "light checks" (like mandatory fields, select single from master data)
     WHEN OTHERS. " Enter, etc.
       " perform "light checks
   ENDCASE.

Regards,

Raymond


Read only

0 Likes
3,830

Hi Nabheet,

Thanks for your answer i completed the requirement

thanks and regards,

Satish Kumar

Read only

Former Member
0 Likes
3,830

Dear Satish,

Just move the obligatory statement from your selection screen deceleration part. The place where you have written code (Must be in event AT Selection Screen Output) to make the field disable just put:

if screen-name eq 'F1'.

Screen-require = 1.

endif.

Thanks,

Prakash

Read only

0 Likes
3,830

Hi Prakash,

I need to mainatain the field as mandatory, that is the requirement.

Read only

0 Likes
3,830

Hi Satish,

  The same mandatory thing can be achieved by code. It will not hamper the requirement. You make F1 mandatory when its enabled and non mandatory when its not enabled.

Thanks,

Prakash

Read only

0 Likes
3,830

Hi Satish,

If you are using the obligatory statement then the system will take care of validating. It causes problem to your requirement, whereas If you remove the obligatory and add the external coding in AT selection screen event for validating the field you can acheive your requirement. The only change you can view is, the mandatory symbol will not be present in the selection screen field but the explicit code which you are writing will take care of it and in the error message you can state that the particular field has to be filled.

Hope it is clear now.

With Regards,

Giriesh M

Read only

0 Likes
3,830

Hi giriesh,

thanks for your explanation.

Regards,

satish

Read only

Former Member
0 Likes
3,830

Hi,

You can try this.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

PARAMETERS : p_y RADIOBUTTON GROUP rg  USER-COMMAND s DEFAULT 'X',

              p_m RADIOBUTTON GROUP rg.

PARAMETERSp_one TYPE Numc04 OBLIGATORY MODIF ID one,

              p_two TYPE  Numc04 OBLIGATORY MODIF ID two.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN OUTPUT.

IF p_y = 'X'.                                                         "Suppressing  The  Month and Year Field

     LOOP AT SCREEN.

       IF screen-group1 = 'ONE'.

         screen-input = '0'.

       ELSEIF screen-group1 = 'TWO'.

         screen-input = '0'.

       ENDIF.

       MODIFY SCREEN.

     ENDLOOP.

ELSEIF p_m = 'X'.

      LOOP AT SCREEN.

       IF screen-group1 = 'ONE'.

         screen-Input = '1'.

       ELSEIF screen-group1 = 'TWO'.

         screen-input = '1'.

       ENDIF.

       MODIFY SCREEN.

     ENDLOOP.

ENDIF.

AT SELECTION-SCREEN.

       IF p_m EQ 'X'.

         p_one = '1000'.

         p_two = '2000'.

       ENDIF.

      IF p_y EQ 'X'.

         p_one = ' '.

         p_two = ' '.

       ENDIF.


Or you can use initialization event to avoid the error message.

Or paste your code.

Regards.


Read only

0 Likes
3,830

Hi Amarnatha,

Thanks for your reply.:)