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

decimals changed!!!

former_member224405
Participant
0 Likes
745

hi folks,

i am stuck in one doubt i have a piece of code which i execute for creating a po in sap where the quantity is 50 and price is 800 after gettin into sap its getting stored as

price PerOP U Matl GrouP

80,000.00 100 EA 007 3

where as in need to get it stored as 800.0000 with four digits after decimals can u guide wat changes i need to do....

LOOP AT po_items.

CLEAR: before_decimal, after_decimal, len_after_decimal, power.

  • only check when price field is not empty

IF NOT ( po_items-net_price IS INITIAL and po_items-item_cat = 'D').

MOVE po_items-net_price TO price.

  • split the netpr into before decimal and after decimal

SPLIT price AT delimiter INTO before_decimal

after_decimal.

len_after_decimal = STRLEN( after_decimal ).

  • adjust netpr, peinh field only if netpr field has

  • more than decimal allowed found

IF len_after_decimal > decimal_allowed AND decimal_allowed > 0.

power = len_after_decimal - decimal_allowed.

po_items-price_unit = 10 ** power.

po_items-net_price = po_items-net_price * po_items-price_unit.

MODIFY po_items.

ENDIF.

ENDIF.

MOVE-CORRESPONDING po_items TO l_poitems.

APPEND l_poitems.

ENDLOOP.

Thanks,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
714

check the value of NETPR before passing to FM and check if NETPR accepts 4 decimals or not. I guess the value is getting multiplied by 100 and giving the result.

5 REPLIES 5
Read only

Former Member
0 Likes
715

check the value of NETPR before passing to FM and check if NETPR accepts 4 decimals or not. I guess the value is getting multiplied by 100 and giving the result.

Read only

Former Member
0 Likes
713

hi,

In EKpo ,NETPR is of type Curr decimals 2.

So,it will store the value with only decimals in the screen field of Po

Read only

0 Likes
713

wat should i do to make it store as 4 digits after decimal any hard code ....

Read only

0 Likes
713

Hi,

If u want that field to store with 4 decimals in your program, then

take packed variable with decimals 4 and move netpr to this.

data w_p type p decimals 4.

w_p = netpr.

Read only

Former Member
0 Likes
713

Hi

Code

power = len_after_decimal - decimal_allowed.

po_items-price_unit = 10 ** power.

is having problem. It multiplies your vaue with 10 power.

Regards

Aditya