2010 Sep 22 10:41 AM
Hi,
I am designing an screen (Module pool ) where requirement is such that all fields are mandatory ( All fields are decimal datatype) but if user inputs 0 ( Zero ) it shold be allowed ie, 0 should be considedred as input.
Since 0 (Zero) is default value it is not considering it as input and giving error for mandaroty field input.
Please suggest the way out.
Regards
Bikas
2010 Sep 22 12:35 PM
Hi,
Try if possible if there are any other way to ascertain that the field requires value. It could be entry in another field. Then you can write in PBO, enter the value.
Sujay
2010 Sep 22 11:04 AM
Hi,
In your case all fields mandatory.
But there will be some key fields which you are declared as mandatory because of that
the entries should not be the same and it gives error.
Check the key fields.
Thanks&Regards
2010 Sep 22 11:07 AM
hi,
Have you tried:
field your_field module check_field_input. "put in your flow-logic
MODULE check_field_input INPUT.
if your_field is initial.
message e000(fisl_gen) with 'enter value'.
endif.
ENDMODULE.
Regards,
2010 Sep 22 11:11 AM
I tried that when I enter 0 then it is initial only and will give message 'enter value'.
I require a way where it should consider 0 as input .
Regards
Bikas
2010 Sep 22 11:22 AM
Hi
Try this.
if X is initial.
if X > -1 and X < 1.
WRITE 'welcome'.
ENDIF.
endif.
2010 Sep 22 5:33 PM
Problem may clear when you change your field to output only, SAP will display 0. So, i think you change your field data type to char, after that check user enter number with right format.
I think there is no way to enter zero for number data type on screen.
GOod luck,
2010 Sep 23 4:28 AM
Thien M. Pham is right.
Change the data type of the variable to character.
After the user inputs a value. Convert the value to the variable with the correct data type and display necessary messages if the data types don't match.
Here is an example in simple ABAP program just to give you an idea:
Data: mandatory_field type p decimals 2.
Parameter: p_input(13).
at selection-screen.
use HRCM_STRING_TO_AMOUNT_CONVERT function module to convert string to decimal or use other FMs to any number type.
if sy-subrc <> 0.
Message ' Enter correct format of values'.
endif.
2010 Sep 22 11:31 AM
sorry but i dont really see the sense in this.
0 is the initial value of decimal data types. So why << removed (this is supposed to be a professional forum >>do you want to make the fields mandatory if you then allow initial values. Outcome would be same as if the field was NOT mandatory.
You could as well use a dataelement of non decimal type which you then put into a field of decimal type.
This field would then have a initial value of space and so you could recognize the input of 0.
Edited by: Rob Burbank on Sep 22, 2010 9:30 AM
2010 Sep 22 11:47 AM
Hi Florian,
The buisness logic is that there are 5 meters for which every day there will be input, all input fileds are mandarory
but some day it may happen due to some otutage 1 or 2 meter can have reading 0 that should also be allowed to input
but just becouse of this exception I can not make the fields non mandatory.
I can take Character which will not have 0 as initial but I need dicimal inputs also so I am just finding out if there is anyway out using decimal itself.
Regards
2010 Sep 22 11:54 AM
Hello Bikas,
I agree with Florian & after your explanation regarding "meters" i'm pretty much convinced you shouldn't make the input fields mandatory.
Classic example for this would be that of temperature readings. Where zero-degrees is a valid reading, so if you make the temperature field as packed decimal fields & make them obligatory you're in a soup !!
Hope you get the point.
BR,
Suhas
2010 Sep 22 12:35 PM
Hi,
Try if possible if there are any other way to ascertain that the field requires value. It could be entry in another field. Then you can write in PBO, enter the value.
Sujay
2010 Sep 22 2:52 PM
You can make a filed as type char.
Give default Value as '0.0' or '0.00' (As per the desimals you want) in PBO.
But you need to be carefull, you will have to validate this field in PAI in certain ways like
1) this field should accept only numeric values
2)this feild should been allowed only decimals you have set.
3) This field should not accept any special characters other than '.' .
I think this is the only way if you really wanted to do o/w logically this field should not be mandatory.