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: 

Multiply within Select Query

former_member191296
Participant
0 Kudos

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

former_member220028
Active Contributor
0 Kudos

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

shalaka_golde
Participant
0 Kudos

Hi,

It is not possible within select statement.

Regards,

Shalaka

former_member220028
Active Contributor
0 Kudos

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

former_member191296
Participant
0 Kudos

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

former_member220028
Active Contributor
0 Kudos

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

0 Kudos

Thanks Stefan.