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: 

Display Negative Value in ALVGRID

Former Member
0 Kudos

Hi!

I'm using ALVGRDI and I have to siplay negative value.

My problem is that the negative sign '-' is alligned to the right:

then number -1923,7 is diplayed as | 1923,7 - |.

I wouldn't convert the number in string...

How can I solve?

6 REPLIES 6

Former Member
0 Kudos

Hi Salvatore,

Use FM CLOI_PUT_SIGN_IN_FRONT.

Do check these refernce thread for code samples also:

Hope this will help you.

Cheers

Sunny

Rewrd points, if found helpful

Former Member
0 Kudos

Salvatore,

In the field catalog, there is a field NO_SIGN. Make sure that is NOT checked for the specific column that you are looking for.

Regards,

Ravi

Note : Please mark the helpful answers.

Former Member
0 Kudos

Hi salvatore,

1. Simple ! we have to use edit mask

2. in field catalogue,

there is one field EDIT_MASK.

3. make that '-______'.

(for that particular numeric field in question)

4. to get a taste of it, just copy paste in new program

REPORT abc.

data : m type i,

n type i.

m = -20.

n = -20.

write 😕 m.

write 😕 n using edit mask '-______'.

5.**************************

ANOTHER PROGRAM WITH ALV NEGATIVE VALUE

EG. -342

JUST COPY PASTE.

REPORT abc.

TYPE-POOLS : slis.

*----


Data

DATA : BEGIN OF itab OCCURS 0,

abc TYPE i.

INCLUDE STRUCTURE t001.

DATA : END OF itab.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvwa TYPE slis_fieldcat_alv.

*----


Select

SELECT * FROM t001 INTO CORRESPONDING FIELDS OF TABLE itab.

LOOP AT itab.

itab-abc = -342.

MODIFY itab.

ENDLOOP.

*------- Field Catalogue

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

*----


IMPORTANT

<b>LOOP AT alvfc INTO alvwa.

IF alvwa-fieldname = 'ABC'.

alvwa-edit_mask = '-___'.

MODIFY alvfc FROM alvwa.

ENDIF.

ENDLOOP.</b>

*----


Display

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

it_fieldcat = alvfc

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

regards,

amit m.

Message was edited by: Amit Mittal

0 Kudos

Just a problem...

usign mask -_______ for curreny and quantity the number loose the comma: 1923,25 - Became -192325

and positive value are displyed as negative!

Whre I can found info to know how built a correct mask?

Message was edited by: Salvatore Volpe

Hi

I don't think it's easy because if you use the option EDIT MASK you have to indicate all characteristics of your format so if you have -1923,25

- for the sign

____ (length 4 char) for integers

__ (length 2 char) for decimal part

'-____,__'

Anyway use symbol V instead of -

'V____,__'

Max

former_member188685
Active Contributor
0 Kudos

Hi Volpe,

if you want that to be before then you will loose certain functionalities like totals and subtotals.

if you want the sign to be front then you need to make it char and use FM or some logic then you will get it.

but totals can't be done with that .

Regards

Vijay