cancel
Showing results for 
Search instead for 
Did you mean: 

which data type is needed

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

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.

Answers (8)

Answers (8)

Former Member
0 Kudos

what exactly is this method doing ?

Regards

ertas

Former Member
0 Kudos

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 ?

former_member40425
Contributor
0 Kudos

Hi,

I do not have idea of freely programming help.

But I think first you call method set_attribute_null then You do your coding of freely progragramming help.

Its just setting attribute null nothing else.

Former Member
0 Kudos

i will test it

and turn to you back

Former Member
0 Kudos

hi I took type string (for the input field )and this is the result:

Type conflict with ASSIGN in program /1BCWDY/5PPS4JYUPDC7M1SY1DLY==CP .

Former Member
0 Kudos

which data type shoulb be used finally before using this code within wddoinit

Former Member
0 Kudos

Hi Ertas,

You can use datatype String for your numeric calculations as well..

Radhika.

former_member40425
Contributor
0 Kudos

HI,

Selecting Type of attribute depends on your requirements.

this code is basically to remove 0,0000000000000000E+00 from the input field(in output) if you are using attribute of type F

Regads

Rohit

Former Member
0 Kudos

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 ?

uday_gubbala2
Active Contributor
0 Kudos

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

former_member40425
Contributor
0 Kudos

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

Former Member
0 Kudos

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

uday_gubbala2
Active Contributor
0 Kudos

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

uday_gubbala2
Active Contributor
0 Kudos

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