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

Split Packed variable value

Former Member
0 Likes
1,545

hi,

i have a variable whose value is 4.73 which is of type packed

and my requirement is to split this value into 2 parts

say variable 1 should 4 and variable 2 should hold 0.73.

can anyone tell me is there any function module to split 4.73 into 4 and 0.73 ?

plz suggest ... ur help will be appreciated

Edited by: Ajantha Ratnakumar on Jul 1, 2008 4:09 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,275

No need of Fun.module..

DATA : TEMP TYPE P DECIMALS 3.

I = TRUNC( TEMP ). " integer part

D = FRAC( TEMP ). " decimal part

8 REPLIES 8
Read only

GauthamV
Active Contributor
0 Likes
1,275

hi,

u can use arthematic operations.

CEIL

Smallest integer value that is not less than x

FLOOR

Largest integer value that is not greater than x

TRUNC

Interger part of x

FRAC

Decimal part of x

Read only

Former Member
0 Likes
1,276

No need of Fun.module..

DATA : TEMP TYPE P DECIMALS 3.

I = TRUNC( TEMP ). " integer part

D = FRAC( TEMP ). " decimal part

Read only

0 Likes
1,275

hi,

can u tell me are there any other function of that sort available ?

like trunc and frac ?

Read only

0 Likes
1,275

Hi,

press F1 on TRUNC or FRAC and you get more Informations.

Regards, Dieter

Read only

Former Member
0 Likes
1,275

Try this ...

data : v_char(10).

v_char = '4.73 '. <-- pass your value ..

split v_char at '.' into v_1 v_2.

Read only

Former Member
0 Likes
1,275

data: test type p decimals 2 value '4.73',

test3(15),

test1 type c,

test2(3) .

test3 = test.

test1 = test3+10(1).

test2 = test3+12(2).

write:/ test1, test2 .

Read only

Former Member
0 Likes
1,275

Hi,

i'm not quite sure if you mean this:

DATA: p1 type p decimals 2.

DATA: p2 type p decimals 2.

*

p1 = 471 / 100.

*

write: / p1, p2.

*

p2 = p1 mod 1.

p1 = p1 - p2.

*

write: / p1, p2.

Try it.

Regards, Dieter

Read only

Former Member
0 Likes
1,275

Hi,

data: a(5),

c(5) value '4.73',

d(5),

b(5).

write:/ 'c', c.

Split c at '.' into a d.

write:/ 'a', a.

write:/ 'd', d.

concatenate '0' '.' d into b.

write:/ 'b', b.

Regards

VIjay