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

conversion

former_member582701
Contributor
0 Likes
910

Hi people,

I have:

char 13 like this: 1.613,000

char 13 like this: 8.240,000

the result must be 1613 + 8240. In other words, without decimals and points and that it allows me operate with them.

Than you

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
890

hi,

Use this sample code.


data: v_char1(13) type c value '1.613,000',
      v_char2(13) type c value '8.240,000'.

data: v_res type p decimals 0,
      v_flag1 type p decimals 0,
      v_flag2 type p decimals 0.

translate v_char1 using '. '.
translate v_char1 using ',.'.
condense v_char1 no-gaps.

translate v_char2 using '. '.
translate v_char2 using ',.'.
condense v_char2 no-gaps.

pack v_char1 to v_flag1.
pack v_char2 to v_flag2.

v_res = v_char1 + v_char2.

write v_res.

v_res contains 9853

Regards,

Sailaja.

9 REPLIES 9
Read only

ferry_lianto
Active Contributor
0 Likes
890

Hi,

Please try this.


REPLACE ALL OCCURRENCES OF ',000' IN WA_AMT1 WITH ' '.
TRANSLATE WA_AMT1 USING '. '.
CONDENSE WA_AMT1 NO-GAPS.

REPLACE ALL OCCURRENCES OF ',000' IN WA_AMT2 WITH ' '.
TRANSLATE WA_AMT2 USING '. '.
CONDENSE WA_AMT2 NO-GAPS.

WA_TOTAL = WA_AMT1 + WA_AMT2.
WRITE: / WA_TOTAL.

Regards,

Ferry Lianto

Read only

0 Likes
890

hI...

data:

w_c1(13) type c value '1.613,000',

w_c2(13) type c value '8.240,000',

W_TEMP TYPE STRING.

data:

w_SUM(10) type N,

w_n1(9) type n,

w_n2(9) type n

.

SPLIT W_C1 AT ',' INTO W_C1 W_TEMP.

SPLIT W_C2 AT ',' INTO W_C2 W_TEMP.

w_n1 = w_c1.

w_n2 = w_c2.

W_SUM = W_N1 + W_N2.

write: w_SUM NO-ZERO, / w_n1 NO-ZERO, / w_n2 NO-ZERO.

Read only

Former Member
0 Likes
890

Hi,

Add both the Qty fields and movethe result into A TYPE I field

or use the ROUND/FLOOR/CEIL maths operators to make it rounded.

reward if useful

regards,

Anji

Read only

Former Member
0 Likes
891

hi,

Use this sample code.


data: v_char1(13) type c value '1.613,000',
      v_char2(13) type c value '8.240,000'.

data: v_res type p decimals 0,
      v_flag1 type p decimals 0,
      v_flag2 type p decimals 0.

translate v_char1 using '. '.
translate v_char1 using ',.'.
condense v_char1 no-gaps.

translate v_char2 using '. '.
translate v_char2 using ',.'.
condense v_char2 no-gaps.

pack v_char1 to v_flag1.
pack v_char2 to v_flag2.

v_res = v_char1 + v_char2.

write v_res.

v_res contains 9853

Regards,

Sailaja.

Read only

former_member582701
Contributor
0 Likes
890

it will work too with 1.215.700,000 for example?

Read only

0 Likes
890

hi,

My logic works for 1.215.700,000 also.

v_res will be 1223940

Regards,

Sailaja.

Read only

Former Member
0 Likes
890

Hi..,

use these variable as..

w_result = w_val1(9) + w_val2(9). ** u will get onli the integral parts added

plz do remember to close the thread , when ur problem is solved!!

reward all helpful answers..

sai ramesh

Read only

former_member582701
Contributor
0 Likes
890

Thx all

Read only

Former Member
0 Likes
890

hi

by using CONDENCE and TRANSALATE commands you can do this.