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

format conversion

Former Member
0 Likes
560

hi

i have to convert a character value '23.4' into exchange rate format i.e, '00023.4000'

which is also to be stored in char format.

please suggest.

thanks in advance

4 REPLIES 4
Read only

George_Lioumis
Active Participant
0 Likes
530

Hi,

this should be ok.

data: char1(4) type c value '23.4',

char2(10) type c,

char3(10) type c,

dec1(12) type p DECIMALS 3,

int1(5) type c,

dec2(3) type c.

move char1 to dec1.

char2 = dec1.

split char2 at '.' into int1 dec2.

UNPACK int1 to int1.

CONCATENATE int1 '.' dec2 into char3.

CHAR3 has your final format.

Please reward if helpful.

Regards,

George

Read only

0 Likes
530

Hi...adding to the above post.....4 decimals are needed...so please modify code in following places.....

data: char1(4) type c value '23.4',

char2(10) type c,

char3(10) type c,

<b>dec1(12) type p DECIMALS 4,</b>

int1(5) type c,

<b>dec2(4) type c.</b>

move char1 to dec1.

char2 = dec1.

split char2 at '.' into int1 dec2.

UNPACK int1 to int1.

CONCATENATE int1 '.' dec2 into char3.

write 😕 char3.

Regards

Vasu

Read only

0 Likes
530

Oh, yes.. ! sorry for the mistake 😛

Regards,

George

Read only

Former Member
0 Likes
530

Thanks to all. the problem is solved now ..

I found that as fixed length was specified so Overlay operation on variable can also be used .