I am struggling to find out how to change a field to be obligatory on a selection screen, but I want it to change dynamically based on a checkbox that is marked.
So for context I have a program with two options in the selection screen. So when I select the first checkbox, I want one of the fields to become obligatory, and when I select the other checkbox for the other option of the program I don't want the field to be obsolete, because the program won't use the value anyway so it does not matter.
Example code:
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_sel AS CHECKBOX,
p_num TYPE i.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME.
PARAMETERS: p_del AS CHECKBOX,
p_num2 TYPE i.
SELECTION-SCREEN END OF BLOCK b2.
"I want to do something like
INITIALIZATION.
LOOP AT SCREEN.
IF SCREEN-name = p_del AND p_del = abap_true.
screen-required = 2.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
But this does not seem to work
So when I select p_del
I want p_num2
to become OBLIGATORY.
Thanks ahead.