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

Multiply within Select Query

Former Member
0 Likes
4,624

Hi,

I have a two tables, say ZTAB1 and ZTAB2. ZTAB1 has fields node1 and node2. ZTAB2 has fields node3.

By using simple select query we can fetch the data from the DB tables. But the complexity is that I want another field in second table say node4 and the value in it should be ( Node2 * 10 ).

I know that we can do it by looping the internal tables and performing arithmetic operations and modifying.

As the table ZTAB1 and ZTAB2 has a bulk amount of records, it would be a performance issue for the code I loop and modify. Can we achieve it within select query itself.

Like,

Select a~node1

          a~node2

           b~node3

          ( a~node2 * 10) as b~node4 into ITAB

          from ZTAB1 AS a

          INNER JOIN ZTAB2 AS b

          where <condition>.

Regards

Raghu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,394

Hi,

i think its only possible in a loop. you can also go for select + endselect and define logic inbetween -  but thats also a loop.

id suggest u do loop itab assigning <Line>.

and do the aricmectic logic in the loop.

with assigning you dont need to do the "modify"-statement as the table is modified implizit.

regards

Stefan Seeburger

5 REPLIES 5
Read only

shalaka_golde
Participant
0 Likes
2,394

Hi,

It is not possible within select statement.

Regards,

Shalaka

Read only

Former Member
0 Likes
2,395

Hi,

i think its only possible in a loop. you can also go for select + endselect and define logic inbetween -  but thats also a loop.

id suggest u do loop itab assigning <Line>.

and do the aricmectic logic in the loop.

with assigning you dont need to do the "modify"-statement as the table is modified implizit.

regards

Stefan Seeburger

Read only

Former Member
0 Likes
2,394

Hello Stefan  and Shalaka,

I have read in some blog that it can be achieved using Native SQL. If it is possible could you please guide me on that.

Regards

Raghu

Read only

Former Member
0 Likes
2,394

Hi,

refering to this link

ABAP SQL: Multiplication in Select-Statement

they say it may be possible, but you should not do nativ-SQL Coding.

Stick to abap and do a loop.

it should be fast enough...

even changing millions of entries does only take a few sec.

regards

Stefan Seeburger

Read only

0 Likes
2,394

Thanks Stefan.