2007 Dec 21 3:10 PM
Hi all ABAP Gurus,
I have a field that is declared as mandatory and I cant change it to optional.
It is mandatory for a flag.
But the field should be optional when I enter the flag as 'X'.
Hi all ABAP Gurus,
I have a field that is declared as mandatory and I cant change it to optional.
It is mandatory for a flag.
But the field should be optional when I enter the flag as 'X'.
2007 Dec 21 3:12 PM
2007 Dec 21 3:49 PM
2007 Dec 21 3:51 PM
2007 Dec 21 3:52 PM
I guess the only way to do this is by writing a validation in the event
AT SELECTION SCREEN on Checkbox.
If checkbox = 'X'.
if Field is initial.
throw an error message.
endif.
endif.
Hope it helps.
Lokesh
2007 Dec 21 3:58 PM
flag is not a checkbox, it is a field.
i tried with the
loop at screen.
but this doesnt change the field as it still is mandatory.
2007 Dec 21 3:59 PM
Do not declare field as mandatory and check as I suggested before.
2007 Dec 21 3:57 PM
You cannot switch from mandatory to optional in a selection screen using AT SELECTION-SCREEN OUTPUT event. You will have to check that yourself in the AT SELECTION-SCREEN event. Check if that field is entered (or not entered) when a certain condition is met and do not allow the user to proceed any further. To achieve this you will have to declare SSCRFIELDS in your TABLES statement and then in your AT SELECTION-SCREEN event do the following.
CASE SSCRFIELDS-UCOMM.
WHEN 'ONLI' OR 'PRIN' OR 'SJOB'.
CLEAR SSCRFIELDS-UCOMM.
IF flag = 'X' AND field IS INITIAL.
MESSAGE E001(00) WITH 'Value for field is required when flag = x'.
ENDIF.
WHEN OTHERS.
ENDCASE.
2007 Dec 21 4:04 PM
there is no change.
It still says "Make an entry in all required fields".
2007 Dec 21 4:05 PM
2007 Dec 21 4:11 PM
Hi Ramana,
I dont think there is a direct way of making that field not mandatory.
I have a work around for this.
In event AT SELECTION SCREEN on <Flag>
Enter some junk/default value into FieldA "which you want to not mandatory.
Also make the field disabled, by looping at screen and set invisible parameter = 1.
In Event Start of Selection.
In the very first statement check the Flag = 'X' and FieldA = default value, clear the fieldA.
Hope it helps...
Lokesh
Edited by: Lokesh Aggarwal on Dec 21, 2007 4:12 PM
2007 Dec 21 4:15 PM
If it is your program, why can't you declare this parameter as optional and check for mandatory entry upon the condition being satisfied?
2007 Dec 21 4:24 PM
its not my program, I cant change the existing code.
the mandatory field is in the existing code.
but I can add to it.
I have to write for the flag.
2007 Dec 21 4:24 PM
2007 Dec 21 4:32 PM
There is no way you can do that without making it optional parameter. The runtime environment does the necessary checks for mandatory entries before even it gives control to you. So unless you remove the mandatory requirement, you will not be able to control its behaviour. Just curious, if it is a custom program, why is it that you cannot make it optional? If there is a genuine requirement to make mandatory only if the flag is 'X', then it is also implicitly understood that you will make changes that are needed.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |