12-22-2005 1:12 AM
hai all,
I am facing a problem in ALV. I have a field which is of type currency. Whenever the number is negative, the sign appears at the last. I need to put the negative sign in front of the number.
<b>eg, 5.00- has to be displayed as -5.00.</b>
Thanks,
kannan
12-22-2005 2:09 AM
Please see this thread. On correction.... the edit mask you be like this.
fc_temp-edit_mask = '-________________'.
not
fc_temp-edit_mask = "-________________".
Also, this will work.
fc_temp-edit_mask = 'V________________'.
This puts the sign in front, but in my test program it is not formatting the decimals places correctly for some reason. For example, if the value is 2.00- it is showing in the ALV grid as -200.
Of course this will not work for you. I'll get back if I figure it out.
Regards,
Rich Heilman
12-22-2005 2:23 AM
Thanks for the reply Rich.
But as you told the solution is not effective enough. Hope u come up with a better one.
Thanks,
KANNAN
10-13-2014 1:20 PM
Hi Selva Kumar,
Am also facing same problem like, may i know how u resolved the issue.
thanks in advance
10-13-2014 1:46 PM
Use this Function Module 'CLOI_PUT_SIGN_IN_FRONT'.
Regards,
Supratik
12-22-2005 3:00 AM
HI,
USe Function Module <b>CLOI_PUT_SIGN_IN_FRONT</b>, may be this works in your case.
Regards
Sudheer
12-22-2005 3:44 AM
If you don't mind converting the currency field to a character field, then you can use the previously mentioned funtion module. Check out this same program, pay close attention to the field catalog for "Price", you must do the field catalog like so in order to get this to work. The totaling functionality will still work if you do it like this. The field in the internal table must be of TYPE c.
report zrich_0004
no standard page heading.
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
data: begin of imara occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
<b> STPRS(15) type c,</b>
end of imara.
* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform write_report.
************************************************************************
* Get_Data
************************************************************************
form get_data.
select mara~matnr makt~maktx
into corresponding fields of table imara
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
loop at imara.
imara-stprs = '-15.23' .
<b>call function 'CLOI_PUT_SIGN_IN_FRONT'
changing
value = imara-stprs.
.</b>
modify imara.
endloop.
endform.
************************************************************************
* WRITE_REPORT
************************************************************************
form write_report.
perform build_field_catalog.
* CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
tables
t_outtab = imara.
endform.
************************************************************************
* BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
clear: fieldcat. refresh: fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Number'.
fc_tmp-fieldname = 'MATNR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '18'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material'.
fc_tmp-fieldname = 'MAKTX'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '40'.
fc_tmp-col_pos = 3.
append fc_tmp to fieldcat.
<b> clear: fc_tmp.
fc_tmp-reptext_ddic = 'Price'.
fc_tmp-fieldname = 'STPRS'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-datatype = 'CURR'.
fc_tmp-just = 'R'.
fc_tmp-outputlen = '15'.
fc_tmp-decimals_out = '2'.
fc_tmp-col_pos = 4.
fc_tmp-do_sum = 'X'.
append fc_tmp to fieldcat.</b>
endform.
REgards,
Rich Heilman
06-19-2007 3:29 PM
Hi,
While using the above solutions please ensure that the Check Box for Fixed Point Arithmetic is checked in the attributes of your program.
Rich, it maybe why your program displays such values.
Hope it helps
10-13-2014 1:54 PM
Hi Supratik,
Thanks for replay
It is not working for currency field, showing error like unexpected function module.
Thank you.
10-13-2014 2:12 PM