‎2007 Jan 23 11:49 AM
Hi Friends,
I have some negative and positive values in the internal table I want to make all the values to be positive. Following field has all the values dfkkop-betrw.
Pls tell me how to convert only negative values to positive values.
Thanx and Regards,
Line
‎2007 Jan 23 12:04 PM
Hi Line,
if you want it to be done fast:
field-symbols: <itab> like line of itab.
loop at itab assigning <itab> where betrw < 0.
<itab>-betrw = - <itab>-betrw.
endloop.Regards,
Clemens
‎2007 Jan 23 11:51 AM
read the records from internal table if value is negative multiply with -1
check the code below,
REPORT ZEX33 .
data : begin of itab occurs 0,
vbeln like likp-vbeln,
netwr like likp-netwr,
end of itab.
itab-vbeln = '0005002035'.
itab-netwr = '5.78'.
append itab.
clear itab.
itab-vbeln = '0005002035'.
itab-netwr = '-3.25'.
append itab.
clear itab.
itab-vbeln = '0005002035'.
itab-netwr = '-8.47'.
append itab.
clear itab.
itab-vbeln = '0005002035'.
itab-netwr = '1.98'.
append itab.
clear itab.
<b>loop at itab.
if itab-netwr < 0.
itab-netwr = itab-netwr * -1.
modify itab index sy-tabix.
else.
continue.
endif.
endloop.</b>
loop at itab.
write : / itab-vbeln , itab-netwr .
endloop.
‎2007 Jan 23 11:52 AM
multiply negative values with -1 to make it positive .
loop at itab.
if itab-f1 is < 0.
itab-f1 = itab-f1 * -1.
modify itab index sy-tabix transporitng f1." use this
endif.endloop.
BTW check the boundaries of your requirement .
regards,
vijay
‎2007 Jan 23 11:52 AM
Hello,
U can do like this:
LOOP AT G_T_VBAP.
<b> IF G_T_VBAP-betrw lt -1.
MULTIPLY G_T_VBAP-betrw BY -1.
MODIFY G_T_VBAP.
ENDIF.</b>
ENDLOOP.
If useful reward.
Vasanth
‎2007 Jan 23 11:53 AM
‎2007 Jan 23 12:04 PM
Hi Line,
if you want it to be done fast:
field-symbols: <itab> like line of itab.
loop at itab assigning <itab> where betrw < 0.
<itab>-betrw = - <itab>-betrw.
endloop.Regards,
Clemens
‎2007 Jan 23 12:11 PM
hi
jst chek whether the value is less than 0.. then multiply with -1. use the field symbols so u no need to modify the table again.. it directly works on the body of the table.
field-symbols: <dfkkop> type xxxxx.
loo at dfkkop assigning <dfkkop> where betrw <= 0.
<dfkkop>-betrw = <dfkkop>-betrw * -1.
endloop.Please Close this thread.. when u r problem is solved
Reward if Helpful
Regards
Naresh Reddy K