‎2007 Apr 13 11:02 AM
Hi Experts,
How to get a negetive value of any number in ALV output?
if ls_alvtab-vbtyp = 'N' or ls_alvtab-vbtyp = 'H'.
if ls_alvtab-netwr lt 0.
ls_alvtab-netwr = ls_alvtab-netwr.
else.
if ls_alvtab-netwr gt 0.
ls_alvtab-netwr = ( -1 ) * ls_alvtab-netwr.
endif.
endif.
modify gt_alvtab from ls_alvtab transporting netwr.
endif.
is this logic correct?
Plz tell me.
Thanks in advance.
‎2007 Apr 13 11:04 AM
your logic is correct.. if it fails..
Try this..
if ls_alvtab-vbtyp = 'N' or ls_alvtab-vbtyp = 'H'.
if ls_alvtab-netwr lt 0.
ls_alvtab-netwr = ls_alvtab-netwr.
else.
if ls_alvtab-netwr gt 0.
ls_alvtab-netwr = 0 - ls_alvtab-netwr.
endif.
endif.
modify gt_alvtab from ls_alvtab transporting netwr.
endif.
‎2007 Apr 13 11:08 AM
Hi,
Your logic is perfect just go wiht it . coz what ever value is there in the internal table ALV just will display it.
The only thing will stop is if "no_sign" field in the fieldcatalog is set to 'X' then it won't print.
Hope this will solve your probelm.
Assign reward points if it helps.
-Gaurang
‎2007 Apr 13 11:05 AM
HI Nidhi,
YOur Logic looks ok to me.
What is the problem?
Can you also show us your Field catalog information for netwr field?
Regards,
Ravi
‎2007 Apr 13 11:11 AM
Hi,
When you define the fieldcatalog..
Give the rollname..
Example..
DATA: S_FIELDCATALOG TYPE slis_fieldcat_alv.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'WERTV6'.
APPEND s_fieldcatalog to t_fieldcatalog.
Thanks and best regards,
Vinoth
‎2007 Apr 13 11:16 AM
Points to note,
1. The maximum length that NETPR can hold is 11 and 2 decimals,if it execeeds then it gives dump
2. chk this
DATA : V_AMT TYPE NETPR.
V_AMT = '12345111.23'.
V_AMT = -1 * V_AMT.
WRITE : V_AMT.this will display negative sign at the end of amount , if you want to display it at fromt then use CLOI_PUT_SIGN_IN_FRONT , but you move the amount field to character field and pass to above FM