06-19-2007 8:20 AM
Hi, I've a small problem. I want grid to display a currency-type column. When I use WRITE statement, values display like <b>XXX.XX</b> but when I put itab to grid, it shows values like <b>XXX</b> (so for example 123 instead of 123.00). How to determine the comma in grid field?
Greetings. P.
06-19-2007 12:39 PM
Hi,
. just copy paste
2. it will display correct currency format in alv,
based upon different currencies in the internal table.
3.
REPORT abc.
TYPE-POOLS : slis.
*----
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : BEGIN OF itab OCCURS 0,
f1 LIKE p0008-bet01,
waers LIKE tcurc-waers,
END OF itab.
*----
START-OF-SELECTION.
itab-f1 = '-4.15'.
itab-waers = 'KRW'.
APPEND itab.
itab-f1 = '4.68'.
itab-waers = 'GBP'.
APPEND itab.
itab-f1 = '500000'.
itab-waers = 'USD'.
APPEND itab.
itab-f1 = '500000'.
itab-waers = 'INR'.
APPEND itab.
itab-f1 = '500000'.
itab-waers = 'GBP'.
APPEND itab.
*----
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = alvfc
TABLES
t_outtab = itab
EXCEPTIONS
OTHERS = 2.
<b>Reward points</b>
Regards
06-19-2007 12:35 PM
Helo,
I see the write help and copy this example:
SALES = 93860.
WRITE SALES CURRENCY 'DEM' ROUND 2 DECIMALS 2. " 9,38 HDM
WRITE SALES CURRENCY 'ITL' ROUND 2 DECIMALS 2. " 938,60 HLira
06-19-2007 12:39 PM
Hi,
. just copy paste
2. it will display correct currency format in alv,
based upon different currencies in the internal table.
3.
REPORT abc.
TYPE-POOLS : slis.
*----
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : BEGIN OF itab OCCURS 0,
f1 LIKE p0008-bet01,
waers LIKE tcurc-waers,
END OF itab.
*----
START-OF-SELECTION.
itab-f1 = '-4.15'.
itab-waers = 'KRW'.
APPEND itab.
itab-f1 = '4.68'.
itab-waers = 'GBP'.
APPEND itab.
itab-f1 = '500000'.
itab-waers = 'USD'.
APPEND itab.
itab-f1 = '500000'.
itab-waers = 'INR'.
APPEND itab.
itab-f1 = '500000'.
itab-waers = 'GBP'.
APPEND itab.
*----
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = alvfc
TABLES
t_outtab = itab
EXCEPTIONS
OTHERS = 2.
<b>Reward points</b>
Regards
06-19-2007 12:40 PM
add this in fieldcatalog for that field
wa_fieldcat-datatype = 'CURR'.
wa_fieldcat-decimals_out = '3'.
06-19-2007 3:36 PM
But what should I do if I have about 10 fields in my ws_fieldcat and only 3 of them are currency fields I want to format? I put a bit of code below.
*---------------------------------------------------------------------
* Form fill_field_cat
*---------------------------------------------------------------------
* text
*---------------------------------------------------------------------
* --> p1 text
* <-- p2 text
*---------------------------------------------------------------------
FORM fill_field_cat.
PERFORM append_wsfield
USING 'MBLNR' '' 0 1 0 'Faktura' 10 'X' 'C210' ''.
PERFORM append_wsfield
USING 'CPUDT' '' 0 1 0 'Data dokumentu' 10 'X' 'C210' ''.
PERFORM append_wsfield
USING 'WERKS' '' 0 1 0 'Filia' 10 'X' 'C210' ''.
PERFORM append_wsfield
USING 'NAME1' '' 0 1 0 'Odbiorca' 10 'X' 'C210' ''.
PERFORM append_wsfield
USING 'STCD1' '' 0 1 0 'NIP' 10 'X' 'C210' ''.
PERFORM append_wsfield
USING 'DMBTR' '' 0 1 0 'Brutto' 10 'X' 'C210' ''. " <-
PERFORM append_wsfield
USING 'DMBTRNOTAX' '' 0 1 0 'VAT' 10 'X' 'C210' ''. " <-
PERFORM append_wsfield
USING 'DMBTRTAX' '' 0 1 0 'Netto' 10 'X' 'C210' ''. " <-
PERFORM append_wsfield
USING 'WAERS' '' 0 1 0 'Walu' 10 'X' 'C210' ''.
ENDFORM. " fill_field_cat
*---------------------------------------------------------------------
* FORM append_wsfield
*---------------------------------------------------------------------
* ........
*---------------------------------------------------------------------
* --> FIELDNAME
* --> INTTYPE
* --> DECIMALS
* --> COL_POS
* --> DECIMALS_O
* --> COLTEXT
* --> OUTPUTLEN
*---------------------------------------------------------------------
FORM append_wsfield USING fieldname inttype decimals col_pos
decimals_o coltext outputlen fix
emphasize sum.
ws_field-fieldname = fieldname.
ws_field-inttype = inttype.
ws_field-decimals = decimals.
ws_field-col_pos = col_pos.
ws_field-decimals_o = decimals_o.
ws_field-coltext = coltext.
ws_field-outputlen = outputlen.
ws_field-seltext = coltext.
ws_field-emphasize = emphasize.
ws_field-fix_column = fix.
ws_field-do_sum = sum.
APPEND ws_field TO ws_fieldcat .
ENDFORM.
06-19-2007 3:42 PM
try this
*----
Form fill_field_cat
*----
text
*----
--> p1 text
<-- p2 text
*----
FORM fill_field_cat.
PERFORM append_wsfield
USING 'MBLNR' '' 0 1 0 'Faktura' 10 'X' 'C210' '' <b>'' ''.</b>
PERFORM append_wsfield
USING 'CPUDT' '' 0 1 0 'Data dokumentu' 10 'X' 'C210' '' <b>'' ''.</b>
PERFORM append_wsfield
USING 'WERKS' '' 0 1 0 'Filia' 10 'X' 'C210' '' <b>'' ''.</b>
PERFORM append_wsfield
USING 'NAME1' '' 0 1 0 'Odbiorca' 10 'X' 'C210' '' <b>'' ''.</b>
PERFORM append_wsfield
USING 'STCD1' '' 0 1 0 'NIP' 10 'X' 'C210' '' <b>'' ''.</b>
PERFORM append_wsfield
USING 'DMBTR' '' 0 1 0 'Brutto' 10 'X' 'C210' '' <b>'CURR' '3'.</b> " <-
PERFORM append_wsfield
USING 'DMBTRNOTAX' '' 0 1 0 'VAT' 10 'X' 'C210' '' <b>'CURR' '3'.</b> " <-
PERFORM append_wsfield
USING 'DMBTRTAX' '' 0 1 0 'Netto' 10 'X' 'C210' '' <b>'CURR' '3'. </b> " <-
PERFORM append_wsfield
USING 'WAERS' '' 0 1 0 'Walu' 10 'X' 'C210' '' <b>'' ''.</b>
ENDFORM. " fill_field_cat
*----
FORM append_wsfield
*----
........
*----
--> FIELDNAME
--> INTTYPE
--> DECIMALS
--> COL_POS
--> DECIMALS_O
--> COLTEXT
--> OUTPUTLEN
*----
FORM append_wsfield USING fieldname inttype decimals col_pos
decimals_o coltext outputlen fix
emphasize sum <b>datatype decimals</b>.
ws_field-fieldname = fieldname.
ws_field-inttype = inttype.
ws_field-decimals = decimals.
ws_field-col_pos = col_pos.
ws_field-decimals_o = decimals_o.
ws_field-coltext = coltext.
ws_field-outputlen = outputlen.
ws_field-seltext = coltext.
ws_field-emphasize = emphasize.
ws_field-fix_column = fix.
ws_field-do_sum = sum.
<b> ws_field-datatype = datatype.
ws_field-decimals_out = decimals.</b>
APPEND ws_field TO ws_fieldcat .
ENDFORM.
06-19-2007 3:42 PM
Hi
Define the internale with the field type P.
Like
types: begin of itab,
amount type p decimals 2,
end of itab.
Regards
Ravi
06-19-2007 8:16 PM
hi,
Certain values of output fields may refer to currencies (such as Euro).
<b>wa_fieldcat-CURRENCY = '<name-of-currency>'</b> "Explicitly specifying a currency (such as DEM , USD ). The ALV displays the values for the column specified in FIELDNAME according to the conventions for this currency.
<b>wa_fieldcat-CURRENCY = '<name-of-currency>'
wa_fieldcat-DECIMALS_O = ' ' value range for this field is INITIAL,
NATURAL NUMBER " here specifies number of
decimal places for output</b>
add these two fields to filed catalog .
regards,
Ashokreddy
06-20-2007 9:52 AM
It was sufficient to change
PERFORM append_wsfield
USING 'DMBTR' '' 0 1 0 'Brutto' 10 'X' 'C210' ''.
into
PERFORM append_wsfield
USING 'DMBTR' '' 0 1 2 'Brutto' 10 'X' 'C210' ''.
Thanks for posts! Greetings. P.