Skip to Content
0

Dialog programming : modify screen field based on check box

May 11, 2017 at 10:15 AM

404

avatar image
Former Member

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Chintu adi May 12, 2017 at 12:03 PM
1

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Whats wrong with using the field properties in table screen ?

0

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

0
Richard Harper May 11, 2017 at 10:54 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

Evgeny

0
Evgeny Gubenko May 11, 2017 at 10:43 AM
0

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


capture.png (5.2 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

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

0