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: 

Dynamic ALV - Format field value

glauco
Active Contributor
0 Kudos

Hi.

I'd like to know how to format fields of a dynamic ALV grid.

Today, in this column is coming values like:

599998900.00-

1000.00-

2000.00-

I'd like to format it like (Brazil's region number format):

599.998.900,00-

1.000,00-

2.000,00-

In fieldcat logic I'm using ls_fieldcat-datatype = 'CURR'.

I tryied to use these fields in fieldcat, but as this ALV is dynamic, I haven't any table to put as reference:

  • lt_fieldcat-fieldname = 'WAERS'.

  • lt_fieldcat-ref_tabname = 'BKPF'.

thanks.

Glauco

Edited by: Glauco Kubrusly on Apr 25, 2011 11:28 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

just use a refence in the fieldcatalog...

lt_fieldcat-cfieldname = 'WAERS'. " fieldname for currency

or directly

lt_fieldcat-currency = 'BRL'. 

regards, sebastian

8 REPLIES 8

Former Member
0 Kudos

Hi,

Check the defaults in the SU01 transaction ,check defualts tab-->Decimal Notation change it to your requirement.

Automatically in the alv it will display according to decimal notation.

Prabhud@s

Former Member
0 Kudos

just use a refence in the fieldcatalog...

lt_fieldcat-cfieldname = 'WAERS'. " fieldname for currency

or directly

lt_fieldcat-currency = 'BRL'. 

regards, sebastian

0 Kudos

Hi friends.

PrabhuD@s: About your hint: SU01 is all right.

Sebastisn: Your hint didn't work. I've tryied both of them.

I haven't much experience yet in dynamic ALV and always need to give reference table until today.

Do you think there is another parameter to use ? If all them don't work, how people that use dynamic get it right ?

thanks in advance.

Gauco

0 Kudos

just try to complete fieldname and currency in your fieldcat witout any other reference....that sould work


lt_fieldcat-fieldname = 'YOURFIELDNAME'.
lt_fieldcat-currency = 'BRL'.

0 Kudos

Hi Sebastian.

All time I fill currency=BRL, text alignment become right:

lt_fieldcat-currency = 'BRL'.

When I fill only this, at least alignment become left correctly.

lt_fieldcat-fieldname = "my_column".

lt_fieldcat-datatype = 'CURR'.

BUT, never apears thousands separators. In case of Brazil, it would be "." to separate thousands and "," to separate decimals.

Any other idea ? Why this not work ?

thanks.

Glauco

0 Kudos

hi,

as u have told tht DATATYPE = 'CURR' is not working then comment it and try to use

lt_fieldcat-INTTYPE = 'P'

lt_fieldcat-INTLEN = '13'.

lt_fieldcat-DECIMALS = '2'.

hope it might solve your problem...

0 Kudos

is there any posibility that the field you are trying to format is CHAR type?

how are you creating the dynamic table?

I have this field in a dynamic table and works fine:


" field for dynamic table
 comp-name = 'ZFIELD'.
 comp-type = cl_abap_elemdescr=>get_p( p_length   = 11 p_decimals = 2 ).
  APPEND comp TO comp_tab.


  " field for catalog
  CLEAR wa_catalog.
  wa_catalog-fieldname   = 'ZFIELD'.
  wa_catalog-ref_table   = 'ZTABLE'.
  wa_catalog-cfieldname  = 'WAERS'.
  APPEND wa_catalog TO gt_catalog.

Regards, Sebastian

0 Kudos

Hi Sebastian.

It works fine now. Tank you very much.

This tip worked very well!

" field for catalog
  CLEAR wa_catalog.
  wa_catalog-fieldname   = 'ZFIELD'.
  wa_catalog-ref_table   = 'ZTABLE'.
  wa_catalog-cfieldname  = 'WAERS'.
  APPEND wa_catalog TO gt_catalog.

Glauco

Edited by: Glauco Kubrusly on Apr 25, 2011 6:18 PM

Edited by: Glauco Kubrusly on Apr 25, 2011 6:20 PM