Application Development 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: 

Simple code required

Former Member
0 Kudos
522

Hi

I have V1 Type QUAN Length = 10 ,Decimal = 3

And V2 as type Character 10.

The requrement is Suppose V1 contains V1 = 1234.732

then V2 must contain V2 = '0000001235' (i.e Rounded Integer with Zeros padded at start)

Suggest a simple code ..

Reward will be given for good ones.

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos
99

Hi

See This Code

You have V1 And V2...... Declare two integers v3 and v4. And v5 as c.

data:v3 type i, v4 type i,v5 v6(11).

Split V1 at '.' into v3 v4.

v5 = v4+0(1).

if v5 >= 5.

concatenate '000000' v3 into V6.

else.

"" Do according to your requirment, you didnt mention in the above code..""

endif.

Try this and revert back in case of any errors..

Reward All The Helpfull Answers....

10 REPLIES 10

Former Member
0 Kudos
99

hi tulip,

try this code, it will work

*********

data : t1 TYPE pc207-betrg,

t2(10) TYPE n.

t1 = '12345.23'.

t2 = t1.

write 😕 t2.

with Regards,

S.BArani

former_member196299
Active Contributor
0 Kudos
99

hi Tulip ,

make use of the function module for rounding up numeric values :

FIMA_NUMERICAL_VALUE_ROUND

Regards,

Ranjita

Former Member
0 Kudos
99

Hi

Read the requirement carefully..

And then come back with the Code.

Regards..

Tulip

0 Kudos
99

hey tulip,

hav u tried the code which i send...

tel me clearly that u need code for rounding off also ?

Former Member
0 Kudos
100

Hi

See This Code

You have V1 And V2...... Declare two integers v3 and v4. And v5 as c.

data:v3 type i, v4 type i,v5 v6(11).

Split V1 at '.' into v3 v4.

v5 = v4+0(1).

if v5 >= 5.

concatenate '000000' v3 into V6.

else.

"" Do according to your requirment, you didnt mention in the above code..""

endif.

Try this and revert back in case of any errors..

Reward All The Helpfull Answers....

Former Member
0 Kudos
99

I am trying below code..

DATA l_int type I.

if frac( V1 ) >= '0.5' .

V1 = ceil( V1).

else.

V1 = floor( V1 ).

endif.

l_int = trunc( V1 ).

V2 = l_int.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = V2

IMPORTING

OUTPUT = V2.

Regards

Message was edited by:

Tulip Shah

Former Member
0 Kudos
99

Hi

One Small Change in The Above Code..

Before The Concatenation just add one line,....

V3 = V3 + 1.

Former Member
0 Kudos
99

Hi Tulip

write V1 to V2 round 2 decimals 0 .

move the character variable to integer variable . it will add automatically leading zeros .

Former Member
0 Kudos
99

unsing roundoff the value will rounded ....then use SHIFT key work so that your quesry will be solved .

SHIFT text UP TO 'you' LEFT/RIGHT .

OR

CONCATENATE 'ZEERO' WOTH V1 INTO V1 .

LEFT-JUSTIFIED|CENTERED|RIGHT-JUSTIFIED

For removing decimals ...

DATA pack TYPE p VALUE '12345678'.

WRITE pack NO-GROUPING ROUND 2 DECIMALS 4.

girish

Girish

Former Member
0 Kudos
99

Its done..

Thanks for your efforts