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

FM for negative values

Former Member
0 Likes
1,387

Hi Friends,

I am getting values in negatiive like this 2,32,542- I want to put the negative sign in front of the value

-2,32,542, is there any function module for this.

Please help me.

Thanx in advance,

Venu

5 REPLIES 5
Read only

Former Member
0 Likes
1,097

Hi Venu,

check this function module..

CLOI_PUT_SIGN_IN_FRONT will move the negative sign from the left hand side of a number, to the right hand side of the number. Note that The result will be left justified (like all character fields), not right justifed as numbers normally are.

chck this example..

data: a1 type i value 56 ,

a2 type i value 60,

res type i.

res = a1 - a2.

data: res1(10).

res1 = res.

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'

CHANGING

VALUE = res1.

write res1.

===============================[OR]

<b>data : char(20).

data : val type i.

val = val - 50.

if val < 0.

write val to char.

concatenate '-' char into char .

condense char no-gaps.

endif.

write : / char.</b>

reward if useful..

Thaks,Eswar

Read only

0 Likes
1,097

Hi Eswar,

I am not getting the field is mseg-menge how to do it.

Thanx

Venu

Read only

0 Likes
1,097

Can you please elaborate and paste the code if possible.

Read only

0 Likes
1,097

Hi

loop at it_mseg.

AT END OF matnr.

  • Material No.

lw_final-matnr = lw_mseg-matnr.

  • Opening qty

lw_final-openqty = lf_open_rec_qty - lf_open_issue_qty.

  • lw_final-recpqty =

  • lw_final-issuqty =

  • Closing qty

<b>lw_final-closqty</b> = lf_close_rec_qty - lf_close_issue_qty.

  • Getting Material Description

SELECT SINGLE maktx INTO lf_maktx

FROM makt

WHERE matnr = lw_mseg-matnr

AND spras = sy-langu.

  • Materail Description

lw_final-maktx = lf_maktx.

endloop.

I want to change the value of this field.

lw_final-closqty

Please help me,

thanx in advance.

Venu

Read only

anversha_s
Active Contributor
0 Likes
1,097

hi venu,

chk this sample.

v_amount = itab-shkzg.

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'

CHANGING

VALUE = itab-shkzg.

v_amount = itab-shkzg

endif.

rgds

anver

Message was edited by: Anversha s