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: 

-ive sign with variable.

Former Member
0 Kudos

I have curr variable with '-ve' sign. I want it to store it in a variable without

the '-ve' sign.Please reply..Reward assured

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Dilraj,

Do as below..

if amount < 0

amount = amount * -1.

endif.

FUNCTION Z_CONVERT_NEGATIVE_SIGN.

*"----


""Local interface:

*" IMPORTING

*" VALUE(DMBTR) LIKE VBAK-NETWR

*" VALUE(WAERS) LIKE BSID-WAERS DEFAULT 'NTD'

*" EXPORTING

*" VALUE(ZMBTR) TYPE CHAR16

*"----


IF DMBTR > 0.

WRITE DMBTR TO ZMBTR RIGHT-JUSTIFIED CURRENCY WAERS.

ELSE.

DMBTR = ABS( DMBTR ).

WRITE DMBTR TO ZMBTR RIGHT-JUSTIFIED CURRENCY WAERS.

CONDENSE ZMBTR NO-GAPS.

WRITE ZMBTR TO ZMBTR RIGHT-JUSTIFIED.

ENDIF.

ENDFUNCTION.

3 REPLIES 3

Former Member
0 Kudos

try like this...


DATA : amount(10) type p decimals 2 value  '-125.25'.

amount = amount * -1.

write 😕 amount.

Message was edited by:

Perez C

Former Member
0 Kudos

Hi.

Mulitply the variable by -1.

and store.

Regards

Bala..

Former Member
0 Kudos

Hi Dilraj,

Do as below..

if amount < 0

amount = amount * -1.

endif.

FUNCTION Z_CONVERT_NEGATIVE_SIGN.

*"----


""Local interface:

*" IMPORTING

*" VALUE(DMBTR) LIKE VBAK-NETWR

*" VALUE(WAERS) LIKE BSID-WAERS DEFAULT 'NTD'

*" EXPORTING

*" VALUE(ZMBTR) TYPE CHAR16

*"----


IF DMBTR > 0.

WRITE DMBTR TO ZMBTR RIGHT-JUSTIFIED CURRENCY WAERS.

ELSE.

DMBTR = ABS( DMBTR ).

WRITE DMBTR TO ZMBTR RIGHT-JUSTIFIED CURRENCY WAERS.

CONDENSE ZMBTR NO-GAPS.

WRITE ZMBTR TO ZMBTR RIGHT-JUSTIFIED.

ENDIF.

ENDFUNCTION.