2006 Sep 15 3:16 PM
Hi All,
I have a Huge Internal Table with several columns and would like to get Just two columns from it to another internal table that has just two columns.
Something like this:
Table A;
Fld1 Fld2 Fld3 Fld4
1 11 21 31
2 12 22 32
3 13 23 33
4 14 24 34
5 15 25 35
6 16 26 36
And the resulting second table after the move.
Table B;
Fld1 Fld2
1 11
2 12
3 13
4 14
5 15
6 16
But as the Table A is huge with about a 100,000 records; Looping through takes up a lot of resources. And
TableA[] = TableB[] doesn't work for me as the Flds have a different structure in the two tables.
Is there any other way to get around this.?
Thanks in advance..!
Jr
2006 Sep 15 3:18 PM
Hi
The answer is NO. Cant achieve that without looping at the huge table.
But, looping on that internal table and populating the second table will not have any issues if records are more...
Regards,
Raj
2006 Sep 15 3:18 PM
Hi
The answer is NO. Cant achieve that without looping at the huge table.
But, looping on that internal table and populating the second table will not have any issues if records are more...
Regards,
Raj
2006 Sep 15 3:19 PM
Would you be able to populate the second internal table simultaneously with populating the first?
2006 Sep 15 3:18 PM
I guess you have to loop it .there is no other way.
Anyway, you must have already looped some other table when you have built the first table. Populate the second table as well in the same step.
regards,
ravi
2006 Sep 15 3:20 PM
I have the first one from a select statement and that statement also takes up considerable amount of time to get executed.
Thanks though..!
Jr.
2006 Sep 15 3:23 PM
hi,
Paste the code here .. i.e, select statement which is used to get the data on to your first internal table ..
let us modify that so that it takes less time to get the data in to that one
Regards,
Santosh
Message was edited by: Santosh Kumar P
2006 Sep 15 3:23 PM
Hi
Can't you load both tables in the select statament?
If you're using INTO TABLE option you can't do it, but if you use SELECT/ENDSELCT you can. How are you doing the SELECT statament?
Max
2006 Sep 15 3:26 PM
hi,
i have tried it like this,
data : begin of it_ekko occurs 0,
ebeln type ebeln,
bstyp type bstyp,
bsart type bsart,
statu type statu,
end of it_ekko.
data : begin of t_ekko occurs 0,
ebeln type ebeln,
end of t_ekko.
start-of-selection.
SELECT EBELN
BSTYP
BSART
STATU
FROM EKKO
INTO TABLE IT_EKKO
WHERE EBELN IN S_EBELN.
t_ekko[] = it_ekko[].
it assign the ebeln to t_ekko.
it is working fine. if you are having different field then how can you assign different fields.
Regards,
Richa
2006 Sep 15 3:19 PM
Hi
I don't believe you can do it without looping the table
Max
2006 Sep 15 3:31 PM
try this .... not sure
<b>
APPEND LINES OF ITAB1 to ITAB2.
</b>
but as the structures are differnt it may not waor , anywayz give it a try
2006 Sep 15 3:36 PM
Hi jr,
1. It can be done.
2. Provided the following simple things are fulfilled.
a) Table A should have also have
FIELD1, FIELD2 (of internal table B)
As the FIRST TWO FIELDS (Starting from Left)
3. Then
tableb[] = tablea[]
will work PERFECTLY FINE.
4. To get a taste of it, just copy paste
5.
report abc.
data : t001 like t001 occurs 0 with header line.
data : begin of itab occurs 0,
mandt like t001-mandt,
bukrs like t001-bukrs,
end of itab.
*-------
select * from t001
into table t001.
itab[] = t001[].
break-point.
regards,
amit m.
2006 Sep 15 3:39 PM
Hi
Some guys are right and I was wrong.
I tried this code and worked fine:
DATA: BEGIN OF ITAB1 OCCURS 0,
FIELD1(4) TYPE N,
FIELD2(4) TYPE N,
FIELD3(4) TYPE N,
FIELD4(4) TYPE N,
END OF ITAB1.
DATA: BEGIN OF ITAB2 OCCURS 0,
FIELD1(4) TYPE N,
FIELD2(4) TYPE N,
END OF ITAB2.
DO 1000 TIMES.
MOVE SY-INDEX TO ITAB1-FIELD1.
ITAB1-FIELD2 = ITAB1-FIELD3 = ITAB1-FIELD4 = ITAB1-FIELD1.
APPEND ITAB1.
ENDDO.
ITAB2[] = ITAB1[].
LOOP AT ITAB2.
WRITE: / ITAB2.
ENDLOOP.
Max
2006 Sep 15 3:49 PM
HI
Try out this code. Its working fine.
Data : begin of it_vbak occurs 0,
vbeln like vbak-vbeln,
ernam like vbak-ernam,
end of it_vbak.
Data : begin of it_final occurs 0,
vbeln like vbak-vbeln,
end of it_final.
select vbeln ernam from vbak into table it_vbak.
it_final[] = it_vbak[].
loop at it_final.
write:/ it_final-vbeln.
endloop.
Regards
Haritha
2006 Sep 15 3:58 PM
Thanks Everyone..!
Really Helpful advice..!
My fields are of different lengths.
data: begin of t_eqst_stpo occurs 0,
idnrk type stpo-idnrk, "Component Material
anlnr type iloa-anlnr, "Asset Number
bukrs type iloa-bukrs, "Company Code
............................
prdha type mara-prdha, "Product Hierarchy
stprs type mbew-stprs, "Standard price
peinh type mbew-peinh, "Unit Price
end of t_eqst_stpo.
data: begin of t_anla_dummy occurs 0,
anlnr type anla-anln1,
idnrk type anla-invnr,
end of t_anla_dummy.
So t_anla_dummy[] = t_eqst_stpo[].
doesn't quite work.
Looping through the t_eqst_stpo table more comfortable than i thought. It doesn't hog up the system. But i expect the volume to grow in future and then it would be a problem again.
Thanks again for all the help..!
Jr.
2006 Sep 15 4:06 PM
Loop is not all that bad a statement.
Statements like loop-in-loop..select-in-loop are.
NO problem even if the volume is large.
Regards,
ravi
2006 Oct 17 10:04 AM
Hi Ravi,
Yes i agree looping is a way but i want to know any other method apart from looping like some direct one line statements like ITAB1 IN ITAB2 etc.. which should give me the common values of both the internal table . and here both the internal table have same structure also
Rgds
Mohit
2006 Sep 15 3:56 PM
Hi,
If in both the internal tables if the common columns are placed leftmost of their structure you can directly use the body operator..THis will work fine..
TABLEB[] = TABLEA[].
Thanks,
Naren
2006 Oct 17 9:39 AM
Hi ,
I have some what same scenario where i have two internal tables of exactly the same structure and i want to get only the common data of the two internal table.
apart from looping is thier any other way.
2022 Aug 26 11:28 AM
2022 Aug 26 2:16 PM
lt_tab2 = CORRESPONDING #( lt_tab1 ). " columns from the tables need to match, irrespective of position