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: 

Dialog programming : modify screen field based on check box

Former Member
0 Kudos

I have a requirement in module pool programming. I have to modify an existing custom screen. Requirement is to display a new input field if a existing check box is checked and make it mandatory. if again the check box is unchecked, new field should not be displayed on screen. Please suggest a solution. Thanks a lot.

1 ACCEPTED SOLUTION

Chintu6august
Contributor

Hello,

In PBO:

Loop at screen.

if screen-name = '<Fieldname>'.

if checkbox = 'X'.

screen-active = 1.

Flag = 'X'. <<<< to make field to act like mandatory field

else.

screen-active = 0.

Flag = ' '

endif.

MODIFY SCREEN

endif.

ENDLOOP.

and in PAI to make the field mandatory..

CHAIN.

FIELD <FIELDNAME> MODULE <MODULENAME>

ENDCHAIN.

MODULE <MODULENAME>.

IF checkbox = 'X' and Flag = 'X' and <fieldname> IS INITIAL.

message 'Field is mandatory' TYPE 'E'.

endif.

ENDMODULE.

thank you!!

8 REPLIES 8

former_member400468
Active Participant
0 Kudos

Hi!

You should set FCODE for your checkbox, and perform PBO processing depending on the checkbox like this:

LOOP AT SCREEN INTO ls_screen
  IF ls_screen-name = 'GV_FIELD' 
  AND p_cbox = abap_true.
    ls_screen-active = '1'.
    ls_screen-required = '1'.
    MODIFY SCREEN FROM ls_screen.
  ENDIF.
ENDLOOP.

Hope it's helpful

Evgeny

0 Kudos

Thank you Evgeny.

But with this solution, new screen field is available with initial execution of program.

My requirement is that new field should be displayed only when check box is ticked.

Regards,

Rahul

0 Kudos

You can add one more branch in the screen processing for empty checkbox, where you will hide this field via setting parameters I pointed in the answer to '0'.

former_member182550
Active Contributor
0 Kudos

Rather than use SCREEN-NAME I would use a modification group such as SCREEN-GROUP1. Whilst this may not matter in this development, using screen-groups is a better idea since you can then modify multiple fields without having to check each field name. So, in this case I would assign a group to the text field and the input field for the field to be displayed and check the screen group.

Rich

0 Kudos

Thanks for your notice, I've written this code just for example, how it can be set as required field.

Evgeny

Chintu6august
Contributor

Hello,

In PBO:

Loop at screen.

if screen-name = '<Fieldname>'.

if checkbox = 'X'.

screen-active = 1.

Flag = 'X'. <<<< to make field to act like mandatory field

else.

screen-active = 0.

Flag = ' '

endif.

MODIFY SCREEN

endif.

ENDLOOP.

and in PAI to make the field mandatory..

CHAIN.

FIELD <FIELDNAME> MODULE <MODULENAME>

ENDCHAIN.

MODULE <MODULENAME>.

IF checkbox = 'X' and Flag = 'X' and <fieldname> IS INITIAL.

message 'Field is mandatory' TYPE 'E'.

endif.

ENDMODULE.

thank you!!

0 Kudos

Whats wrong with using the field properties in table screen ?

0 Kudos

Field property will give error message of required field when you will uncheck the checkbox.