Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

INITIAL or NOT INITIAL

Former Member
0 Likes
5,402

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,181

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

8 REPLIES 8
Read only

Former Member
0 Likes
2,181

Hi,

IF p_deci IS INITIAL. is work only for data type Character.

thanks.

Read only

Former Member
0 Likes
2,181

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

Read only

Former Member
0 Likes
2,181

Hi,

IF p_deci IS INITIAL. it works only for data type Character.

thanks.

Read only

Former Member
0 Likes
2,182

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

Read only

0 Likes
2,181

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.

Read only

0 Likes
2,181

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

Read only

0 Likes
2,181

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

Read only

Former Member
0 Likes
2,181

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