Skip to Content
-2

change in mandatory field in selection screen dynamically

Mar 22, 2017 at 10:38 AM

84

avatar image

Hi Experts,

I have have these fields in selection screen, my requirement is that when i give an input in

contract number then all mandatory has been changed to non-mandatory.

Sales Org. Mandatory TVKO-VKORG Contract Type Mandatory TVAK-AUART Customer
Mandatory KNA1-KUNNR Contract Number VBAK-VBELN

Thanks in advance.

Regards,

Naveen Yadav

10 |10000 characters needed characters left characters exceeded

This really is a FAQ. But as Horst Keller and Jelena Perfiljeva have given detailed answers, I'll just lock it now rather than reject it. Please SEARCH before posting.

0
Further commenting has been locked.
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Horst Keller
Mar 22, 2017 at 11:00 AM
1

You can work with CALL SELECTION-SCREEN in that case.

Call your selection screen after a value is entered in contract number another time and use MODIFY SCREEN during event AT SELECTION-SCREEN OUTPUT.

Oops, have to take that back, since OBLIGATORYs can only be left empty with function codes BACK, CANCEL, EXIT. Doesn't help with Enter or F8, don't get the control in ABAP.

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

Hi Horst,

Can you give me an example of this???

0

Now, let's try something like this

PARAMETERS p1.
PARAMETERS p2 OBLIGATORY.

AT SELECTION-SCREEN OUTPUT.
 LOOP AT SCREEN INTO DATA(wa).
   IF wa-required = '1'.
     IF p1 IS INITIAL.
       wa-required = '2'.
     ELSE.
       wa-required = '0'.
     ENDIF.
     MODIFY SCREEN FROM wa.
   ENDIF.
 ENDLOOP.

AT SELECTION-SCREEN ON p2.
 IF p1 IS INITIAL AND p2 IS INITIAL.
   MESSAGE 'Fill P2' TYPE 'E'.
 ENDIF.

START-OF-SELECTION.
 BREAK-POINT.
0
Jelena Perfiljeva
Mar 22, 2017 at 04:53 PM
0

Use Google, dynamic selection screens have been covered on SCN ad nauseum. See also this old blog.

All Horst said is valid but, as he mentioned, in ABAP there are no events triggered when you just enter a value in a field or navigate between the fields. So we can't expect exactly what you described to happen. But I believe you might be taking the requirement too literally and there might not be an actual need to manipulate the field attributes. You can simply handle this by checking values in AT SELECTION SCREEN and issuing an error message when the fields entered don't meet the conditions. It might not be as intuitive (since the users don't see mandatory marker on screen) but is usually OK, especially when the fields are pre-filled whenever possible.

Or use the approach similar to the referenced blog and have a radio button for different option. E.g. if the users want to run it by contract then it'd be one option and the rest - another.

Also make sure to test different scenarios (like exiting from the screen or going to the variant). I found that selection screen changes can sometimes lead to unwanted results because the events are triggered not always when you need/expect.

Share
10 |10000 characters needed characters left characters exceeded