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

write stmt (formatting)

former_member206396
Active Participant
0 Likes
720

hai SDNs,

i am doing subraction in my report. when i am outputting the value to the list..

if the result is negative.. when i write the commnad

write 😕 result.

it is priting the '-' sign at the end. how to print it before the result.

eg.

5 - 10 = ?

it is printing : 5-

but i need : -5 how?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
605


 CLOI_PUT_SIGN_IN_FRONT

or

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
*"--------------------------------------------------------
*For transport missing function group ZBD1 .

IF DMBTR > 0.
    WRITE DMBTR TO ZMBTR  RIGHT-JUSTIFIED CURRENCY WAERS.
ELSE.
    DMBTR = ABS( DMBTR ).
    WRITE DMBTR TO ZMBTR RIGHT-JUSTIFIED  CURRENCY WAERS.
    ZMBTR+0(1) = '-'.
    CONDENSE ZMBTR NO-GAPS.
    WRITE ZMBTR TO ZMBTR RIGHT-JUSTIFIED.
ENDIF.
ENDFUNCTION.

Cheers,

Thomas.

<b>Please mark points if helpful</b>

5 REPLIES 5
Read only

Former Member
0 Likes
605

hi,

Use <b>concatenate</b> statment for the same... FM 'CLOI_PUT_SIGN_IN_FRONT' will also work

Message was edited by: Santosh Kumar P

Read only

Former Member
0 Likes
606


 CLOI_PUT_SIGN_IN_FRONT

or

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
*"--------------------------------------------------------
*For transport missing function group ZBD1 .

IF DMBTR > 0.
    WRITE DMBTR TO ZMBTR  RIGHT-JUSTIFIED CURRENCY WAERS.
ELSE.
    DMBTR = ABS( DMBTR ).
    WRITE DMBTR TO ZMBTR RIGHT-JUSTIFIED  CURRENCY WAERS.
    ZMBTR+0(1) = '-'.
    CONDENSE ZMBTR NO-GAPS.
    WRITE ZMBTR TO ZMBTR RIGHT-JUSTIFIED.
ENDIF.
ENDFUNCTION.

Cheers,

Thomas.

<b>Please mark points if helpful</b>

Read only

0 Likes
605

CALL FUNCTION <b>'CLOI_PUT_SIGN_IN_FRONT'</b>

CHANGING

value = result.

ENDIF.

write: result

Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
605

Hi,

Use this F.M <b> 'CLOI_PUT_SIGN_IN_FRONT'</b>

data: p(2) type c.

p = '2-'

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'

CHANGING

value = p.

write: i.

Cheers,

Simha.

<b>Reward if it helps...</b>

Read only

Former Member
0 Likes
605

Use ,

DATA : final(10),
       field(9).

CONCATENATE '-' field INTO final+1.

Regards,

AS