04-18-2022 11:06 AM
i Want to get the first 4 digits of the number in have please refer to the following code.
w_1 LIKE PRCD_ELEMENTS-kbetr, (20.000000000)w_2(5) TYPE c,
MOVE w_1 TO w_2.
REPLACE '.' WITH ',' INTO w_taux2.
so the output expected is 20.00
04-19-2022 7:15 PM
Hi atharva kate,
Do you need to get the value with 2 decimals only?
If that is the situation, you can do this:
- Create a variable with type p decimals 2.
- Assign the value to the new variable.
You are going to get 20.00.
- Create a new variable TYPE string.
- Assign the last value to the string var.
- Use the replace statement.
04-18-2022 11:33 AM
You just assign like this
w_2 = w_1+0(5).
result:
w_2 = 20.00
I think it will solve your problem
04-18-2022 12:04 PM
04-18-2022 11:51 AM
Please format your code like that:
DATA:
w_1 LIKE PRCD_ELEMENTS-kbetr, (20.000000000)
w_2(5) TYPE c,
MOVE w_1 TO w_2.
REPLACE '.' WITH ',' INTO w_taux2.
(Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!)
04-18-2022 11:54 AM
Note that first 3 of 4 lines of your code are OBSOLETE. You should use TYPE instead of LIKE, LENGTH should be used, MOVE is obsolete.
DATA:
w_1 TYPE PRCD_ELEMENTS-kbetr, (20.000000000)
w_2 TYPE c LENGTH 5,
w_2 = w_1.
04-18-2022 12:05 PM
04-18-2022 2:12 PM
Concerning TYPE/LIKE, when you use ABAP Objects (subroutines are obsolete), you get syntax error:
Only use "TYPE" to refer to ABAP Dictionary types, not "LIKE" or "STRUCTURE".
04-19-2022 10:11 AM
Oh, and to get data in an output format, use WRITE. Don't manipulate strings yourself.
04-19-2022 7:15 PM
Hi atharva kate,
Do you need to get the value with 2 decimals only?
If that is the situation, you can do this:
- Create a variable with type p decimals 2.
- Assign the value to the new variable.
You are going to get 20.00.
- Create a new variable TYPE string.
- Assign the last value to the string var.
- Use the replace statement.