Application Development and Automation 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: 
Read only

Negetive value

Former Member
0 Likes
579

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.

5 REPLIES 5
Read only

Former Member
0 Likes
556

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.

Read only

0 Likes
556

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

Read only

Former Member
0 Likes
556

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

Read only

Former Member
0 Likes
556

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

Read only

Former Member
0 Likes
556

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