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

Decimal FM

Former Member
0 Likes
1,178

Hi friends,

I have two questions in scripts

1. I want to display a value without decimals

ex: 45.000 output 45

2.I want to bring the negative sign before

ex : 5.55- output -5.55

Please tell me how to do it.

Regards,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,120

Hi Venu ,

for values in teh scripts do this .

&itab-value(4.0)&

or

&itab-value(C.0)&

<b>IN UR DRIVER PROGRAM</b>

for sign use fm

CLOI_PUT_SIGN_IN_FRONT

declare one field as V_VAR(10) type c,

CLOI_PUT_SIGN_IN_FRONT

v_var now contains value -55.5

now in the display in the script

&v_var&

regards,

Vijay.

ensure that v_var is in global symbols .

Message was edited by: Vijay

9 REPLIES 9
Read only

anversha_s
Active Contributor
0 Likes
1,120

hi,

<i>Easiest way is to move it to a field with no decimals. check the example.</i>

report zXYZ_0001.

data: p1 type p decimals 2 value '11.44'.

data: p2 type p decimals 0.

p2 = p1.

write:/ p2.

p1 = '11.88'.

p2 = p1.

write:/ p2.

<i>minu sign before a value</i>

data : shkzg type c value 'E'.

data: p type p decimals 2 value 100.

data: c(18) type c.

if shkzg = 'E'.

p = p * -1.

c = p.

concatenate '-' c into c.

condense c no-gaps.

else.

c = p.

endif.

write:/ c.

*******************************

if itab-shkzg = 'H'.

v_amount = itab-shkzg.

else.

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'

CHANGING

VALUE = itab-shkzg.

v_amount = itab-shkzg

endif

Message was edited by: Anversha s

Read only

0 Likes
1,120

Hi Anwersha,

This is my subroutine I am getting values in decimals even though, pls tell me how to do it,

FORM sub2 TABLES input STRUCTURE itcsy

output STRUCTURE itcsy.

READ TABLE input WITH KEY 'VBDPR-FKIMG'.

ifkimg = input-value.

ifkimg = ifkimg * 20.

MOVE ifkimg TO ofkimg.

LOOP AT output.

IF sy-tabix = 1.

output-value = ofkimg.

MODIFY output INDEX sy-tabix.

ENDIF.

ENDLOOP.

ENDFORM. "SUB2

Regards,

Venu

Read only

0 Likes
1,120

hi venu,

try this.

i am getting it correctly.

data: p1 type p decimals 2 value '11.44'.

data: p2 type p decimals 0.

p2 = p1.

write:/ p2.

p1 = '11.88'.

p2 = p1.

write:/ p2.

rgds

anver

Read only

Former Member
0 Likes
1,120

Hi Venu,

1. I want to display a value without decimals

- WRITE AMOUNT decimals 0.

2.I want to bring the negative sign before

CLOI_PUT_SIGN_IN_FRONT

Reward points if this helps.

Manish

Read only

Former Member
0 Likes
1,121

Hi Venu ,

for values in teh scripts do this .

&itab-value(4.0)&

or

&itab-value(C.0)&

<b>IN UR DRIVER PROGRAM</b>

for sign use fm

CLOI_PUT_SIGN_IN_FRONT

declare one field as V_VAR(10) type c,

CLOI_PUT_SIGN_IN_FRONT

v_var now contains value -55.5

now in the display in the script

&v_var&

regards,

Vijay.

ensure that v_var is in global symbols .

Message was edited by: Vijay

Read only

Former Member
0 Likes
1,120

Hi venu ,

for the query dont change any data type whenever u r doing this decimal conversions ..

simply take a character variable and move ..

remember that in the scripts do not use space for alignment , strictly do it with the tab positions ..

also in debugging change the values to the maximum number

and check the alignment .

once u do this check with print out okay .

______________________________

to anversha ,

ur logic is right .

regards,

Vijay.

Read only

0 Likes
1,120

Hi Vijay,

Yes I got the output, Thanx a lot.

But if want to move a value little, byt using tab it is not possible, How to do at that time.

Regards,

Venu

Read only

Former Member
0 Likes
1,120

Hi venu

1. Display a value without decimals in SAP Scripts

&symbol(.N)&

eg. &EKPO-MENGE& -> 1,234.560

&EKPO-MENGE&(.0)& -> 1,235

2. Bring the negative sign before in SAP Scripts

&symbol(<)&

eg. &ITCDP-TDULPOS& -> 100.00-

&ITCDP-TDULPOS(<)& -> -100.00

Regards,

Sreekanth

Read only

Former Member
0 Likes
1,120

thats what i was referring to

//

But if want to move a value little, byt using tab it is not possible, How to do at that time.

//

see besides u will be having paragraph format

like

Z1 |,,,,&itab-value,, |

now go to the paragraph format of Z1

,, is one tab number

,,,, is 2 tab number

in tabs for the occurance of the tabs

,,,,,, above i used this

Number Tab position Alignment

1 3mm left

2 9mm left

3 45mm left

tabs ---

now if i want to move the value now work on number 2

slightly decrease or increase by +-2mm and check the value .

change the alignment to right or left ..

<b>u have to do it the alignment in the tabs ...</b>

just do the manipulations u will see the change

regards,

vijay

Message was edited by: Vijay