2015 Dec 16 6:22 AM
Hi All,
I have one parameter on my selection screen, and other is global variable of the type Z-table field which is having a numeric value and the parameter is of type char but can have only numeric values, therefore I applied a numeric check for that and applied condense statement so that it compares it with the numeric field correctly.
Declaration:
Data : gv_value type ZZVALUEL (it is the numeric field)
Parameters : p_days(5) type c
The problem is when I am executing the statement :
if p_days LT gv_value .
Message 'the value should be greater or equal to <gv_value>' .
endif.
gv_value is 720 in the table
entering p_days = 999
error is not coming , but when entering 1000 or above it displays the error even though it is the greater value than gv_value.
2015 Dec 16 2:44 PM
Hi Tanya,
The use of Type C which is of length 5 is the real problem.
If you use Type C for variable p_days the it will internally convert 720 as 00999 where as your gt_value is 720 always as it is Numeric.
This can never be compared and your condition fails always.
Use Type N or take another variable
p_days2 type N.
P_days2 = p_days.
If p_days2 LT gt_value.
Message 'XXXXXXXXXXXXXXXXXXXXXXXXX'.
Endif.
This will help you.
Regards,
Veera
2015 Dec 16 12:46 PM
For me the solution is pretty obvious, but offcourse I don't know the restrictions you might have.
But if you want to compare two fields, why do you not declare them the same way ?
Parameters : p_days type ZZVALUEL.
And if that is not possible maybe you can declare another field where you move the parameter to before compare
data: lv_days type ZZVALUEL.
Parameters: p_days(5) type c
* do your checks for numeric and then
lv_days = p_days.
And now compare lv_days with the global variable in stead of p_days.
2015 Dec 16 2:44 PM
Hi Tanya,
The use of Type C which is of length 5 is the real problem.
If you use Type C for variable p_days the it will internally convert 720 as 00999 where as your gt_value is 720 always as it is Numeric.
This can never be compared and your condition fails always.
Use Type N or take another variable
p_days2 type N.
P_days2 = p_days.
If p_days2 LT gt_value.
Message 'XXXXXXXXXXXXXXXXXXXXXXXXX'.
Endif.
This will help you.
Regards,
Veera