‎2008 Jul 29 5:26 PM
guys..
i have a number stored in a string.
I need to separate the last two characters and print it as a decimal..are there any keywords for shifting the string?
Eg : amt = '455677'
Output : 4556.77
‎2008 Jul 29 5:27 PM
send it to the field of packed decimals 2 ..
data: amount type string ,
amt type i ,
amt1 type p decimals 2 .
amount = '455677' .
amt = amount .
amt1 = amt / 100 .
write:/ amt1 .
‎2008 Jul 29 5:27 PM
send it to the field of packed decimals 2 ..
data: amount type string ,
amt type i ,
amt1 type p decimals 2 .
amount = '455677' .
amt = amount .
amt1 = amt / 100 .
write:/ amt1 .
‎2008 Jul 29 5:30 PM
write <your_var> into <aux_var> CURRENCY 'USD' (or any other)
regards,
‎2008 Jul 29 5:35 PM
hi,
do this way ..
DATA : v_string(10) VALUE '1234567',
v_in(10),
v_new1(10),
v_new2(10),
v_new3(10),
v_new4(10),
v_out(10).
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = v_string
lang = ' '
IMPORTING
RSTRING = v_in
* EXCEPTIONS
* TOO_SMALL = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
v_new1 = v_in+0(2).
v_new2 = v_in+2(8).
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = v_new1
lang = ' '
IMPORTING
RSTRING = v_new3
* EXCEPTIONS
* TOO_SMALL = 1
* OTHERS = 2
.
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = v_new2
lang = ' '
IMPORTING
RSTRING = v_new4
* EXCEPTIONS
* TOO_SMALL = 1
* OTHERS = 2
.
concatenate v_new4 v_new3 into v_out separated by '.'.
write : v_out.