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

-ive sign with variable.

Former Member
0 Likes
649

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
Read only

Former Member
0 Likes
619

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
Read only

Former Member
0 Likes
619

try like this...


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

amount = amount * -1.

write :/ amount.

Message was edited by:

Perez C

Read only

Former Member
0 Likes
619

Hi.

Mulitply the variable by -1.

and store.

Regards

Bala..

Read only

Former Member
0 Likes
620

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.