‎2005 Jul 27 12:12 PM
I have a small problem filling my internal table.I have some 10 fields in my internal table.I am filling some 5 fields in the internal table using a join and i have to fill the other 5 fields seperately ie modify the internal table after the first select query...So without looping can we do it in any easy way...
‎2005 Jul 27 12:14 PM
example:
data: begin of itab occurs 0,
field1(10),
field2(10),
end of itab.
itab-field1 = 'hello'.
modify itab transporting field1 where ....
‎2005 Jul 27 12:17 PM
select ... into (<fields>) from ...
<fill the other 5 fileds>
endselect.
You will have one loop between select and endselect.
‎2005 Jul 27 12:21 PM
Hi Mavreck,
I think its not possible to modify an internal table's multiple rows without looping.
Regards,
Narinder Singh
‎2005 Jul 27 12:23 PM
hi Narinder ,
did you check the <b>transporting</b> option in modify?
<b>You can modify multiple rows without looping</b>
‎2005 Jul 27 12:40 PM
Hi Joseph,
Thanks for correcting, But using transporting what i understand is that all records can only be modified with same values only. What if user want to modify each record
with different valus, he has to use loop???
Regards,
Narinder Singh
‎2005 Jul 27 12:41 PM
hi Narinder,
<b>You right! sorry</b>, i didn't thought about this possibility.
‎2005 Jul 27 1:36 PM
If i use modify itab transporting field bt select... endselect....Its going 4 short dump...
‎2005 Jul 27 1:39 PM
Hi,
Actually modify ... and select ... endselect are 2 different options to solve your problem. It depends on the values that you want to modify with.
‎2005 Jul 27 1:42 PM
if you use modify of an itab within the select endselect, you need to tell the modify stt , that which line should be updated . something like modify .. index 5 .(to modify the 5th record) or
modify .... where <logical expression>.
Regards
Raja
‎2005 Jul 27 1:56 PM
I think your best bet is to do a loop. Why would you want to hit the database more than once if you don't have to. What I mean is, doing a SELECT ENDSELECT will cause you to hit the database n times where n is the number of records that you are selecting. Why not do an array fetch, then loop at the the itab and get the rest of your fields then modify your itab. You know, LOOPS are not such a bad thing.
data: begin of itab occurs 0,
f1 type c,
f2 type c,
f3 type c,
f4 type c,
f5 type c,
f6 type c,
f7 type c,
f8 type c,
f9 type c,
f10 type c,
end of itab.
select * into corresponding fields of table itab
from Some_Table
where field = p_field.
loop at itab.
select Single * from some_table
into xsome_table
where fld1 = itab-fld1.
itab-fld6 = xsome_table-fld6.
" More code here
Modify itab.
endloop.Regards,
Rich Heilman
‎2005 Jul 27 12:26 PM
Hi,
If you are going to modify the same values[say field2 = 'ABC'] for all the records,then without loop you can do that.
Otherwise,if you need to modify it differently for each record,then
select...Endselect is the best approach.
‎2005 Jul 28 6:51 AM
i think for that you need to use inner join.
i am giving you a sample inner join statement.
with this statement we can retrieve data from
3 tables and we can populate in a single table...
SELECT A~EBELN
A~LIFNR
A~AEDAT
B~EBELP
B~MATNR
B~NETPR
C~ETENR
C~MENGE
C~WEMNG
FROM ( EKKO AS A INNER JOIN EKPO AS B
ON AEBELN = BEBELN )
INNER JOIN EKET AS C
ON AEBELN = CEBELN
AND BEBELP = CEBELP
INTO TABLE ITAB
WHERE A~EBELN IN PNO.
i hope it will help you.
bye...
regards,
prasad
‎2005 Jul 28 7:11 AM
Hey,
Ths only way is to use MOVE CORRESPONDING FIELDS in the select query. And the loop that internal table.
Since if u use SELECT...END SELECT...performance will be bad. Since unnecessary access to database will take place "N" times.
Regs,
Venkat