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

Operation in Select Statement

Former Member
0 Likes
5,772

Hi,

In an ABAP select statement, how to do operations on two columns of a dictionary transparent table(say division or multiplication on two column values) ?

Reward points will be awarded .

TIA

Regards,

Anindita

7 REPLIES 7
Read only

Former Member
0 Likes
2,345

HI,

I don't think this can be achieved using OPEN SQL.

Regards,

Atish

Read only

Former Member
0 Likes
2,345

I am not sure whether on a SELECT statement operations like subtraction, division or multiplication on DB columns can be performed.

You may have to select the columns into an internal table and then loop thru the internal table to perform the necessary division or multiplication operations.

Hope this helps.

Thanks,

Balaji

Read only

Former Member
0 Likes
2,345

Hi,

There are some aggregate functions which can be used for columns in the database.

Those are: SUM, MAX, MIN, AVG and COUNT.

This above functions can be used accorddingly in the select queries like:

select vbeln posnr sum (netwr)

into gi_vbap

from vbap

where vbeln = ............

There is no operations fpor mulitply/divide.

Hope this helps.

Regards,

JLN

Read only

Former Member
0 Likes
2,345

Hi Anindita

Can you please explain in detail what exactly you want to do so that i can help better.

Regards

Lakshmikanth

Read only

Pramanan
Active Participant
0 Likes
2,345

Hi kumar,

Use this sample code..

Loop at internaltable

compute internaltable-total = internaltable-value1 + internaltable-value2.

modify internaltable.

endloop.

Regards,

Ramanan

Read only

Former Member
0 Likes
2,345

hi,

see the below link

i hope it will useful for u .

http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm

SELECT AVG(salary) FROM employees

SELECT COUNT(*) FROM employees

SELECT COUNT(DISTINCT employee_name) FROM employees

SELECT employee_name, salary + benefit

FROM employees

WHERE salary < 0.8 *

( SELECT MAX( salary ) FROM employees )

Arithmetic Expressions. For all employees that have a salary not exceeding 80% of the salary of the maximum salary of all employees, this query returns the name of the employee and the sum of its salary and its benefit.

reward if its useful

Edited by: p541399 on Feb 28, 2008 5:49 PM

Read only

Former Member
0 Likes
2,345

Hi,

Try doing ur operations outside select. Store it in a variable and use it in select. This will enhance ur performance.

Regards,

Ramya