Application Development 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: 

opposite of collect statement

Former Member
0 Kudos

Hello,

I have a collect statement in my code. But I can´t add all my values. Sometimes I have to subtract values. Is there a statement which is doing the same ac the collect statement but which subtracts and don´t add the values?

Regards

Philipp

5 REPLIES 5

Former Member
0 Kudos

Hi Philip,

There is no mechanism for subtracting values which acts similar to COLLECT. But if you would like to do that... you can always update your values as negative ( multiply by -1, for the values you would like to subtract ) before using COLLECT.

Reward points inorder to say thanks,

Kiran

0 Kudos

Hello Kiran,

thanks for your reply.

This was also my second idea but I have a small question to this. Can I multiply a currency-field with -1?

Regards

Philipp

Former Member
0 Kudos

hi,

Some databases will let you use math in your SQL statement, so you could do something like the following:

UPDATE building SET ports_free = (ports - ports_used) WHERE name = 'Building A';

You would have to use the above SQL statement every time you changed the number of ports being used (i.e. the ports_used field in the database). Otherwise you'd have to write some PHP code that figures out how many ports are free and then update the table.

reward points if helpful

regards,

preet

Former Member
0 Kudos

Hi ,

You are saying that u cant currency values always. You have to substract some times. Means some of your amounts are debits and some are credits. If that is the case then check for the Debit/Credit Indicator . then multiply your amount value with -1 incase of credit. then apply collect on your internal table. The collect can take care.

Reward if find useful

0 Kudos

Hello,

now I have tried to multiply the corresponding values with -1 but I have still a problem.

This is my code which is in a loop:

free lsum.
lsum-wert = lout-netwr.
lsum-owert = lout-ofwrt.
lsum-waerk = lout-waerk.

if lout-auart = 'G2'.
  multiply lsum-wert by -1.
endif.
  
collect lsum into tsum.

The result of this code is that the correct values were subtract from the amount but the values were subtract two times. Is there an error in my code?

Regards

Philipp