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

changing internal table in select

Former Member
0 Likes
1,528

hi,

i have a internal table with 3 columns. first two columns are filled with values. i need to extract the value for 3rd column from a database table, which has key filelds same as first two colunms of the internal table. instead of getting values from the DB table into another internal table and then looping with original internal table to change the 3rd column value, is there any shortcut where i can update the 3rd column directly in the select statement?

thanks

5 REPLIES 5
Read only

Former Member
0 Likes
1,167

Assuming that you are filling the first 2 columns from database,I am suggesting this option:While filling the first 2 columns in the internal table from database, you can use Join in the select and fetch the data for the third column also from another table.

Vishwa.

Read only

Former Member
0 Likes
1,167

Hi,

Since the key filelds are same as first two colunms of the internal table , you can write a select .. for all entries

For this you need to just declare another internal table ....

select field1 field2 field3 into table itab2 from <table>

for all entries in itab1

where field1 = itab1-field1 and

field2 = itab1-field2.

Regards,

Srini.

Read only

Former Member
0 Likes
1,167

Hi Sudhakar

According to you, you have 3 fields out of which 2 fields are already filled with data.

Now you want to select data from DB directly into your 3rd field without losing data in first 2 fields.

for that you can use appending statement while selecting value from DB into the 3rd field.

but for that you have to use another internal table, because your table fields are partially filled.

suppose you have WA1 for itab1 and WA2 for itab2.

Itab1 has data and itab2 contains only 1 field which is the 3rd field of itab1.

try this.

select matnr from mara into table itab2.

loop at itab2 into wa2,

wa1-matnr = wa2-matnr .

appending itab1 from wa1.

clear: wa1, wa2.

endloop.

I hope this will work for you.

thanks

Lalit Gupta

Read only

ThomasZloch
Active Contributor
0 Likes
1,167

Since release 6.10 you can use the same internal table after FOR ALL ENTRIES and INTO TABLE, your question sounds like it could be a use case for this option, please let us know the result.

Thomas

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,167

May be join statement representing the field name using alias will do


select mara~matnr as matnr1
           marc~matnr as matnr2
           from mara inner join marc ........
           into table it ......