‎2007 Oct 25 6:35 AM
I have an internal table with four fields..Using query i filled the internal table with 5 records..like
field1 field2 field3 field4
12 14 12
32 43 43
7 4 5
4 55 4
8 85 91
But field4 is not filled..I want to take tht value from other table based on the field1 value as a key value for both the tables..So how can update tht particular one field..
So tht all the records will have four fields filled
‎2007 Oct 25 6:38 AM
Hi Mahesh,
You can't achieve this using SELECT.
You need to get data in some other internal table and then use LOOP ..READ to move the data and MODIFY to modify the record in internal table.
Regards,
Atish
‎2007 Oct 25 6:38 AM
Hi Mahesh,
You can't achieve this using SELECT.
You need to get data in some other internal table and then use LOOP ..READ to move the data and MODIFY to modify the record in internal table.
Regards,
Atish
‎2007 Oct 25 6:39 AM
‎2007 Oct 25 6:41 AM
loop at itab.
select field4 from <table name> into itab-field4 where table_name-field1 = itab-field1.
modify itab transporting field4.
endloop.
plz reward points if ids helps
‎2007 Oct 25 6:41 AM
Check this sample code and do it accordingly
SELECT field1 field2 field3
FROM table1
INTO TABLE it_tab1.
SELECT field1 field4 field5
FROM table2
INTO TABLE it_tab2.
SORT it_tab1 BY field1.
SORT it_tab2 BY field1.
LOOP AT it_tab2.
READ TABLE it_tab1 WITH KEY field1 = it_tab2-field1.
IF sy-subrc = 0.
MOVE it_tab1-field1 TO it_final.
MOVE it_tab1-field2 TO it_final.
MOVE it_tab1-field3 TO it_final.
MOVE it_tab2-field4 TO it_final.
MOVE it_tab2-field5 TO it_final.
APPEND it_final.
ENDIF.
CLEAR : it_tab1, it_tab1, it_final.
ENDLOOP.Regards
Gopi
‎2007 Oct 25 6:42 AM
Hi Mahesh,
SELECT f2 f3 f4
INTO itab
FOR ALL ENTRIES iN itab1
WHERE f2 = itab1-f2
and f3 = itab1-f3.
LOOP AT itab1.
READ TABLE itab WITH KEY f2 = itab1-f2
f3 = itab1-f3.
MOVE itab-f4 to itab1-f3.
MODIFY itab1.
ENDLOOP.
Just do slight corrections
Regards,
Atish
‎2007 Oct 25 6:41 AM
Assume itab has field1, field2, field3, field4
ihead has field3, field4, field5
we want to moved data from ihead-field4 to itab-field4 based on common value Field3
sort ihead by field3.
loop at itab.
read table ihead with key field3 = itab-field3 binary search.
itab-field4 = ihead-field4.
modify itab.
endloop.
‎2007 Oct 25 6:42 AM
HI,
do like this.
loop at itab.
select single <field4> into itab-field4 from <table> where field1 = itab-field1.
modify itab.
endloop.
rgds,
bharat.
‎2007 Oct 25 6:43 AM
Hi,
Loop on internal table. then read second internal table using read table with key
and binary search. checke sy-subrc , if it is zero then pass that value to field4 and
modify the internal table with index.
Regards,
Prashant