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

Round up character data?

Former Member
0 Likes
404

I am a newbie in SAP.

I have a variable declared like this:

DATA y_dots(6) TYPE c.

I performed some mathematical operation on this variable and it ends up as 56.5.

So do I round up this variable so that it becomes 57 or 56?

Please help and I will reward you.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
380

Hi,

Just do like this,

define one local variable with type p then move your field (type c field) into this variable and display this.

sample code shows here how to do that,

DATA: data(5) TYPE c VALUE '12.60',

data1 type p.

data1 = data.

WRITE: data1, data.

it'll solve your problem.

seshu.

2 REPLIES 2
Read only

Former Member
0 Likes
380

Hi,

DATA N TYPE P DECIMALS 2.

DATA M TYPE P DECIMALS 2 VALUE '5.55',

DATA c_var TYPE I.

N = FRAC( M ).

IF N GE 0.5.

c_var = FLOOR( M ). WRITE: / 'FLOOR:', c_var.

ELSE.

c_var = CEIL( M ). WRITE: / 'CEIL: ', c_var.

ENDIF.

Read only

Former Member
0 Likes
381

Hi,

Just do like this,

define one local variable with type p then move your field (type c field) into this variable and display this.

sample code shows here how to do that,

DATA: data(5) TYPE c VALUE '12.60',

data1 type p.

data1 = data.

WRITE: data1, data.

it'll solve your problem.

seshu.