‎2022 Mar 07 10:11 AM
Goodmorning,
I am new to SAP and ABAP programming and I am trying to make field visible dynamically, but only when a dropdown menu has a certain value, but I cant get it to work.
So first i set the field inactive in the PBO:
LOOP AT SCREEN.
CASE SCREEN-NAME.
WHEN 'FIELD A'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
WHEN 'FIELD B'.
SCREEN-ACTIVE = 0.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
And then in the PAI i read the value of the dropdown and if its the correct value, set them to active again.
IF dropdown-field = 1.
LOOP AT SCREEN.
CASE SCREEN-NAME.
WHEN 'FIELD A'.
SCREEN-INPUT = 1.
MODIFY SCREEN.
WHEN 'FIELD B'.
SCREEN-ACTIVE = 1.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
ENDIF.
I tried with a error message, and that shows perfectly, but the fields just won't show up, what am I doing wrong??
Thanks in advance!
‎2022 Mar 07 12:28 PM
Let's start with a reproducible example, you can see that FIELD_A is changed into an input field:
PARAMETERS p_number TYPE i.
PARAMETERS field_a TYPE i.
PARAMETERS field_b TYPE i.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CASE screen-name.
WHEN 'FIELD_A'.
screen-input = 0.
MODIFY SCREEN.
WHEN 'FIELD_B'.
screen-active = 0.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
AT SELECTION-SCREEN.
IF p_number = 1.
LOOP AT SCREEN.
CASE screen-name.
WHEN 'FIELD_A'.
screen-input = 1.
MODIFY SCREEN.
WHEN 'FIELD_B'.
screen-active = 1.
MODIFY SCREEN.
ENDCASE.
ENDLOOP.
MESSAGE 'error' TYPE 'E'.
ENDIF.
‎2022 Mar 07 3:29 PM
Hi,
kwiznix
1. So first you need to add your code(which you have written in PBO) in AT SELECTION-SCREEN OUTPUT event. This will help you see FIELD_A read only and FIELD_B as active on selection screen.2. When you want to modify the screen dynamically you will write your code(written by you in PAI) into AT SELECTION-SCREEN event. Here you can dynamically show fields based on whatever your dropdown value is.Regards,Anurag