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: 

Move negative sign to front

Former Member
0 Kudos

Hi all

I have a currency field with negative value if i display that in ALV grid the negative symbol is coming after the value like 159.00-

but i want to display it as -159.00 in the ALV grid

is there is any way to do this other than CLOI_PUT_SIGN_IN_FRONT

If i use this first i need to conver currency field to char field

i did that but again i want to assign that character field to currency field when i tried this it is not taking how to assign char to currency field

Thank you.

8 REPLIES 8

gopi_narendra
Active Contributor
0 Kudos

May be you can try by passing '-________________' ( 16 Under scores in single quotes) to EDIT_MASK of field catalog for the required field.

When you fill the field catalog you can pass the edit_mast to the same field as well.

Regards

Gopi

0 Kudos

If i use fieldcat-edit_mask = '-_______________' it is effecting all the records

but i want only the value which contains negative how do i check that

Thank you

0 Kudos

Hi Pradeed, try this being a lengthy one, but should work for sure.

I just tried on my system.

PARAMETER : p_int TYPE i.
DATA : ch(15) TYPE c.

START-OF-SELECTION.
  ch = p_int.
  CONDENSE ch NO-GAPS.
  REPLACE '-' INTO ch WITH space.
  CONCATENATE '-' ch INTO ch.

  WRITE : p_int.
  WRITE : / ch.

Regards

Gopi

Former Member
0 Kudos

HI Praddep..

For display your field type might be currency type..

For display make your field Character type..

DATA F1 type char15 .

IF (your currency field ) < 0 .

(your currency field ) = (your currency field ) * -1 .

COCATENATE '-' (your currency field ) INTO F1 .

ENDIF .

Hope this helps .

Former Member
0 Kudos

Use Conversion exit.

Define your own conversion exit like.

for eg. "CONVERSION_EXIT_ZSIGN_OUTPUT".

write code as :

DATA: lv_char TYPE CHAR20.

WRITE INPUT TO lv_char.

CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'

CHANGING

value = lv_char.

OUTPUT = lv_char.

now pass this conversion exit to your field catalog like :

<z_li_fcat>-ref_fieldname = 'WRBTR'.

<z_li_fcat>-ref_tabname = 'RSEG'.

<z_li_fcat>-datatype = 'CURR'.

<z_li_fcat>-edit_mask = '==ZSCON'.

<z_li_fcat>-intlen = '16'.

<z_li_fcat>-inttype = 'CHAR'.

This will definately solve your issue as i was facing the same.

Former Member
0 Kudos

Shift circular has always worked for me.

Former Member
0 Kudos

Hi all,

maybe this is a too easy and dumb suggestion but shouldn't the display of currency fields be set in the User Defaults?

So instead of coding something just set the correct values for number display?

Former Member
0 Kudos

Before anyone else decides to answer, please look at the date of the OP.

Rob