on 05-24-2009 7:13 PM
Hello,
I have created a search help (freely programmed).
I have used this search help in another component. This search help is used at an input
field. It has the data type i (integer). But if I calculate with zeros and decimals I dont see
the complete result. I know this is because of the data type. But i also tried it with f .
It was not possible. in the search help i am using type numeric
Which data type can I choose.
Regards
ertas
method ONACTIONBUTTONPRESS .
DATA lo_nd_calculator TYPE REF TO if_wd_context_node.
DATA lo_el_calculator TYPE REF TO if_wd_context_element.
data lr_value type ref to data.
data l_string type c LENGTH 60.
data: val type string.
data l_binding_string type string.
lo_nd_calculator = wd_context->get_child_node( name = wd_this->wdctx_calculator ).
lo_el_calculator = lo_nd_calculator->get_element( ).
lr_value = lo_el_calculator->get_attribute_ref( WD_COMP_CONTROLLER->value_help_listener->f4_attribute_info-name ).
FIELD-SYMBOLS <wa_numeric> type numeric.
ASSIGN lr_value->* to <wa_numeric>.
val = wdevent->GET_string( 'ID' ).
CASE val.
WHEN 'BTN_1'.
IF WD_COMP_CONTROLLER->COMP EQ 'X'.
CLEAR: WD_COMP_CONTROLLER->erg, WD_COMP_CONTROLLER->merker, <wa_numeric>, l_string, WD_COMP_CONTROLLER->COMP.
ENDIF.
move <wa_numeric> to l_string.
CONCATENATE l_string `1` into l_string. CONDENSE l_string NO-GAPS.
<wa_numeric> = l_string.
................
.........
endmethod.
Edited by: Ilhan Ertas on May 24, 2009 9:00 PM
Hi Ertas,
Just pasting a few lines from [help.sap.com|http://help.sap.com/saphelp_47x200/helpdata/EN/fc/eb2fd9358411d1829f0000e829fbfe/content.htm] regarding the same:
Regards,
Uday
Packed numbers - type P
Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.
You can use type P data for such values as distances, weights, amounts of money, and so on.
Floating point numbers - type F
The value range of type F numbers is 1x10*-307 to 1x10*308 for positive and negative numbers, including 0 (zero). The accuracy range is approximately 15 decimals, depending on the floating point arithmetic of the hardware platform. Since type F data is internally converted to a binary system, rounding errors can occur. Although the ABAP processor tries to minimize these effects, you should not use type F data if high accuracy is required. Instead, use type P data.
You use type F fields when you need to cope with very large value ranges and rounding errors are not critical.
Using I and F fields for calculations is quicker than using P fields. Arithmetic operations using I and F fields are very similar to the actual machine code operations, while P fields require more support from the software. Nevertheless, you have to use type P data to meet accuracy or value range requirements.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what exactly is this method doing ?
Regards
ertas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rohit I can insert the code this not a problem.
But suppose everytime if someone uses this free programmed search help (component) and
binds it for his input field he must insert the mentioned coding in his
wddoinit. This is not very comfortable do you understand what I mean ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i will test it
and turn to you back
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi I took type string (for the input field )and this is the result:
Type conflict with ASSIGN in program /1BCWDY/5PPS4JYUPDC7M1SY1DLY==CP .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
which data type shoulb be used finally before using this code within wddoinit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
in case of float I am gettimg this in the input field.
0,0000000000000000E+00
and secondly it doesnt show the entered numbers
How do you assig double type to the context ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ertas,
Its strange but its a pretty sticky issue. I guess that you are trying to handle any decimal values that might arise during your calculator operations. I have a workaround for this. Every time you want to hold any of your operations result use a STRING variable. Say suppose you want to divide 2 numbers then after the division use a string variable for holding the result. This would hold even any decimals that are present within your result. Now if the user pressed up on a button for performing another operation just pass on the value from your STRING variable to a local variable of type P within your method & then perform the operation. But use the STRING variable to hold the result once again. Am not sure but I think that this approach should work out...
Regards,
Uday
Hi,
Use method set_attribute_null in the wddoinit method.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_att1 TYPE wd_this->element_context-attribute_name. "Name of attribute is Attribute_name
* get element via lead selection
lo_el_context = wd_context->get_element( ).
lo_el_context->set_attribute_null(
name = `ATTRBUTE_NAME`)." Give ur attribute name here
I hope it helps.
Regards,
Rohit
Uday thanks for your kindly efforts.
The reason why I have posted this question here is because I dont know how to
assign an context attribute this type
-
>
DATA number1 TYPE P DECIMALS 2
Regards
ertas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ertas,
My apologies for my earlier reply. I did try declaring an attribute of type P and it says, "Type P cannot be instantiated." I guess that you would have posted in here coz of the same reason. What is the problem that you face when trying to declare the data type as F? As how i double checked the system does allow creating an attribute of that type.
Regards,
Uday
Hi Ertas,
This is more of an ABAP issue rather than a Web Dynpro ABAP issue. Try using a packed decimal format by specifying the desired precision level.(TYPE P). It should work.
Example:
DATA number1 TYPE P DECIMALS 2
Here by DECIMALS 2 you are specifying that you want the system to show 2 digits after your decimal point.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.