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

Dialog programming : modify screen field based on check box

Former Member
0 Likes
4,207

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
Read only

Chintu6august
Contributor
2,438

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
Read only

former_member400468
Active Participant
0 Likes
2,437

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

Read only

0 Likes
2,437

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

Read only

0 Likes
2,437

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'.

Read only

Former Member
0 Likes
2,437

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

Read only

0 Likes
2,437

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

Evgeny

Read only

Chintu6august
Contributor
2,439

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!!

Read only

0 Likes
2,437

Whats wrong with using the field properties in table screen ?

Read only

0 Likes
2,437

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