‎2010 Feb 19 8:37 AM
Good noon everyone.
In my previous post I have asked about the problem in displaying 0 in modulepool screen. I overcame it by declaring it as character type, but the problem here is that it is giving wrong result while calculations. It is giving * as the output.
Any ideas which datatype to use so that 0 is displayed in the screen and calculations are possible.
Dev.
‎2010 Feb 19 9:01 AM
Hi,
As you have already declared you field as character type, you can do one thing.
Declare anothe variable of type p and copy that screen value which you declared as type c into that and use that for your calculations. And declare your output field also of type p only.
Thanks,
Sri.
‎2010 Feb 19 8:47 AM
Hi,
the + indicates, that your output field is too short. If you defined your field as c, without any length, the default length is 1. So you would be able to display and calculate all 1 digit values. Declare your field like this
data: output(15) type c
or like this
Data: output type char15
then your display field can display up to 15 digits (including all -,.)
Regards
Jörg
‎2010 Feb 19 9:01 AM
Hi,
As you have already declared you field as character type, you can do one thing.
Declare anothe variable of type p and copy that screen value which you declared as type c into that and use that for your calculations. And declare your output field also of type p only.
Thanks,
Sri.
‎2010 Feb 19 10:02 AM
Thanks very much Sri.
It worked.
But isn't there any data type that can display 0 and can also be used for calculation?
Dev.
‎2010 Feb 19 9:23 AM
Hi DKBR,
You will need to do a small data conversion for this. Just create a fixed point numeric variable like:
DATA: p_num(8) type p decimals 2. "Or whatever parameters are suitable
and then pass the character field value to this variable:
p_num = character_variable.
Just put in a check before this statement to verify whether all the characters in your character-type variable are actually numerals. This you can do as follows:
data: string_num(10) type c value '0123456789'.
if character_variable CO string_num. "Contains Only
<proceed>
else.
<throw error>
endif.
Hope this helps! Please revert if you need anything else.
Cheers,
Shailesh.
Always provide feedback for helpful answers
‎2010 Feb 19 10:06 AM
Hi dkbr1992,
I did not see your previous thread, no link given.
just means that the result does not fit in the field. If you declare a character(1) and try to put the result of, say 4+7=11 here, it will display as * because 11 has two characters and the variable has only one.
Regards,.
Clemens
‎2010 Feb 19 10:56 AM
Hi,
if you are performing calculations on 'char' fields it will show unexpected results or some times may leads to dump.
do one thing, before displaying the variable(on which you need zeros) move that value(having no zeros-numeric value)
into a variable of type 'NUMC'.
it will works.
then no need to perform on 'char' fields.
move the value to any other type after performing all the calculations. if you move before and perform operations on that new variable you will unexpected values only.
Hope clear right.
Thanks & regards,
Sasi Kanth.