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

Blank fields in select statement list

Former Member
0 Likes
2,425

Hi,

I am appending records into one internal table from various tables. The tables might not have the same structure as the internal table.



types: begin of price_list,
       matnr type a746-matnr,
       field1 type a746-field1,
       field2 type a746-field2,
       field3 type a745-field3,
       field4 type a733-field4,
       end of price_list.

data: i_price_list type table of price_list.

select matnr field1 field2
from a746 
appending table i_price_list
where ...

select matnr field3 "I want the field3 to go in the 4th column of the internal table.
from a745
appending table i_price_list
where ....

I will not be able to give into corresponding fields due to some restrictions of the query. I want to avoid loops as they create a huge overhead. Can anyone suggest me how do I go about it

10 REPLIES 10
Read only

Former Member
0 Likes
2,069

Hello,

Try this statement.

APPEND LINES OF internal table1 TO internal table2.

Read only

0 Likes
2,069

I have 10 pricing tables, if I use 10 internal tables to collect that data and then into a final internal table, then I will have serious performance issues, as I will have to loop at every table and move the fields. I would rather like to know if I can do it directly using the select statement. In MS SQL we can give


select field1, 0, field2
from table_name

In this case the column1 and column3 have values, where as the column2 has 0.

Is something similar possible in abap?

Read only

0 Likes
2,069

U can do in this way..[no such way as u specified]

select field1 field2 into table tab where..... >here tab is new internal table.

and then

loop over tab into wa

wa_1-field1 = wa_field1. here wa_1 and tab1 are ur table and work areas...

wa_1-field2 = wa_field2.

append wa_1 to tab1.

endloop

Select into new internal table and loop over this internal table and append where required to ur table..

Edited by: Veeranji Reddy on May 7, 2009 5:56 PM

Read only

Former Member
0 Likes
2,069

Press F1 on Append Statement.

Read only

Former Member
0 Likes
2,069

Hi,

You can select in one internal table and update the destination table with LOOP-ENDLOOP.

This willease burden on database but more processing at application server.

Regards

Shital

Read only

Former Member
0 Likes
2,069

Use addition

APPENDING CORRESPONDING FIELDS OF TABLE itab

in SELECT.

Read only

Former Member
0 Likes
2,069

HI,

Try using

INTO CORRESPONDING FIELDS OF

i.e select .......... from table into corresponding fields of i_table.

Hope this will solve.

Thanks and regards

Suraj

Read only

Former Member
0 Likes
2,069

Hi,

use the following code...

types: begin of price_list,
       matnr type a746-matnr,
       field1 type a746-field1,
       field2 type a746-field2,
       field3 type a745-field3,
       field4 type a733-field4,
       end of price_list.
 
data: i_price_list type table of price_list.
 
select matnr field1 field2
from a746 
appending table i_price_list
where ...
 
select matnr field3 "I want the field3 to go in the 4th column of the internal table.
from a745
appending corresponding fields of table i_price_list
where ....

Regards,

Siddarth

Read only

Former Member
0 Likes
2,069

If possible try an Outer Join

select tableA~matnr

tableA~fieldx

tableB~fieldy

tableC~fieldz

into table i_price_list

from tableA left outer join tableB on ( tableA... = tableB...)

left outer join tableB on ( tableA... = tableC...)

where ...

Read only

0 Likes
2,069

I am planning to give a blank field of the tables. Especially mara~lvorm in the columns that I will want as blanks since this field is being filtered as blank in the where clause. The columns that might be left empty are all char type so I dont feel it will be an issue here. Thanks a lot everybody.