‎2009 Jul 28 8:37 AM
Hi Everyone,
I have a situation here. The code goes like this.
In the below code, ZTEST-DECI is a Decimal type with length 11 and decimal 2.
PARAMETERS: p_deci TYPE ztest-deci.
IF p_deci IS INITIAL.
WRITE 'Empty'.
ELSE.
WRITE p_deci.
ENDIF.
Now if I leave P_deci in Input screen blank then it will print "Empty", and if I give the input as 0.00 it still prints "Empty".
I do not want that to happen. I want it to print 0.00 as output if I give input as 0.00 or 0.
Note: I do not want to change the Dala Element of ZTEST-DECI or declaration of p_DECI. However, I am ready for Type Casting.
Thanks in advance,
S.Dakshna Nagaratnam.
‎2009 Jul 28 8:44 AM
Hi,
Try defining your fields as below:
data : r_deci type p decimals 2.
and change you condition as initial as it is used to check character types.
Regds,
Anil
Edited by: Anil Katoch on Jul 28, 2009 9:45 AM
‎2009 Jul 28 8:42 AM
Hi,
IF p_deci IS INITIAL. is work only for data type Character.
thanks.
‎2009 Jul 28 8:42 AM
Hi
The comand INITIAL check if the value of a variable is INITIAL VALUE, the initial value depends on the data type of the of variable:
- for char variable is BLANK,
- for a decimal variable is ZERO,
- ...................................................
so if you insert 0,00, it means u insert 0, i.e the initial value: the behavior is correct.
What do you need to do?
Max
‎2009 Jul 28 8:43 AM
Hi,
IF p_deci IS INITIAL. it works only for data type Character.
thanks.
‎2009 Jul 28 8:44 AM
Hi,
Try defining your fields as below:
data : r_deci type p decimals 2.
and change you condition as initial as it is used to check character types.
Regds,
Anil
Edited by: Anil Katoch on Jul 28, 2009 9:45 AM
‎2009 Jul 28 8:52 AM
I see what we are trying to do here...
my requirement is just that,
if I give 0 in the selection screen output should be 0.00
if I do not give anything in the selection screen it should print as Blank.
My requirement is a little complex and the issue is because of this. Hence I cannot change the declaration.
Can someone help me with a Logic using type casting or something? -> Type P and Type C in Typecasting no luck.
Thanks and Regards,
S.Dakshna Nagaratnam.
‎2009 Jul 28 9:34 AM
Not possible without changing the data type or introducing a help field, I'm afraid. Wether you enter nothing or 0 or 0.00 on the selection screen, once PAI processing starts, the value of p_deci will be '0.00' internally.
Thomas
‎2009 Jul 28 10:19 AM
Hi
Thomas is right, it can't do it: if you don't insert any value or if you insert 0: it'll be the same for the system, so u can't distinguish the two situation.
Max
‎2009 Jul 28 8:50 AM
ignore for the time..
Edited by: Amit Gujargoud on Jul 28, 2009 9:51 AM
Yup,My bet with Thomas
Cheers
Edited by: Amit Gujargoud on Jul 28, 2009 11:09 AM