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

string query

Former Member
0 Likes
462

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
438

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 .

3 REPLIES 3
Read only

Former Member
0 Likes
439

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 .

Read only

Former Member
0 Likes
438

write <your_var> into <aux_var> CURRENCY 'USD' (or any other)

regards,

Read only

Former Member
0 Likes
438

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.