2023 Aug 22 7:11 AM
Hello everyone,
I am relatively new to ABAP programming, and I need some help with a certain requirement.
I currently have a task where I need to make select-options mandatory/optional based on which radio button is checked. Seeing as I cannot define select-options in screen painter, I decided to create a subscreen containing them, and inserting it into a subscreen area.
Unfortunately, I cannot figure out a way to change the 'required' attribute for the select-options programmatically. How can I achieve this requirement?
*-Group1 'REQ' contains the select-*options. If r_manage/r_display radio button is checked, the select-*options should be made optional
LOOP AT SCREEN INTO wa_screen.
CASE 'X'.
WHEN r_entry.
IF wa_screen-group1 EQ 'ENT'.
wa_screen-active = '0'.
ENDIF.
WHEN r_manage.
CASE wa_screen-group1.
WHEN'ENT'.
wa_screen-active = '1'.
WHEN 'REQ'.
vl_req_flag = 'X'.
ENDCASE.
WHEN r_display.
CASE wa_screen-group1.
WHEN'ENT'.
wa_screen-active = '1'.
WHEN 'REQ'.
vl_req_flag = 'X'.
ENDCASE.
ENDCASE.
MODIFY SCREEN FROM wa_screen.
ENDLOOP.
*-Preparing values in listbox
vl_vrm_id = 'P_STATUS'.
wa_vrm-key = '1'.
wa_vrm-text = 'Available'.
APPEND wa_vrm TO it_vrm.
wa_vrm-key = '2'.
wa_vrm-text = 'Out'.
APPEND wa_vrm TO it_vrm.
wa_vrm-key = '3'.
wa_vrm-text = 'Both'.
APPEND wa_vrm TO it_vrm.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = vl_vrm_id
VALUES = it_vrm.
ENDFORM.
The above subroutine is called whenever the PBO module is called. I am using 'vl_req_flag' as a global variable to determine whether the select-options should be mandatory or optional. I am just stuck on how to access the attributes for the inputs to modify the 'required' attribute.
Any help would be greatly appreciated.
2023 Aug 22 8:01 AM
to change the parameter / select option as required, you need to pass the screen-required = 1
*assuming your optional word mean not mandatory
2023 Aug 22 8:27 AM
Why do you use subscreens? Are you mixing dynpro and selection screen?
If yes, make sure you do LOOP AT SCREEN, MODIFY SCREEN in the right event (at selection-screen output, or PBO module).
As it varies according to the checkbox, it should be "recommended" (required = 2) otherwise you'll get into many troubles (+ you will need to check the mandatory value by ABAP):
screen-required = '2'.
2023 Aug 22 9:22 AM
Yes I had to mix dynpro and selection-screen due to dynpro not supporting multiple entry input fields. I managed to get it working with your advice though, thank you.