Skip to Content
avatar image
Former Member

Dialog programming : modify screen field based on check box

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    May 12, 2017 at 12:03 PM

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

    Add comment
    10|10000 characters needed characters exceeded

  • May 11, 2017 at 10:54 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • May 11, 2017 at 10:43 AM

    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

    Add comment
    10|10000 characters needed characters exceeded