‎2008 Feb 20 3:07 PM
HI all,
I am working with an ALV report in which i have to take the data from 5 internal tables and put this data into a single internal table and display the output.How to get the data from different tables into 1 single internal table.
‎2008 Feb 20 3:11 PM
Hi,
I had similar post just now.. it involves 3 tables. you need to apply it for 5 tables..
The post:
Step 1: Find out the comprehensive table out the 3 (ie, which contain all the records ). for example say internal table it_3.
Step 2 : loop at the table found in step 1.
ie loop at it_3.
endloop.
Step 3 : Inside the loop of step 2 read the other tables using READ TABLE stmt, and if success ( ie sy-subrc = 0 ), then copy the required fields into your final table.
Step 4 : Append the final table values into the final table.
Hope this helps..
Thanks in advance,
‎2008 Feb 20 3:11 PM
Hi,
I had similar post just now.. it involves 3 tables. you need to apply it for 5 tables..
The post:
Step 1: Find out the comprehensive table out the 3 (ie, which contain all the records ). for example say internal table it_3.
Step 2 : loop at the table found in step 1.
ie loop at it_3.
endloop.
Step 3 : Inside the loop of step 2 read the other tables using READ TABLE stmt, and if success ( ie sy-subrc = 0 ), then copy the required fields into your final table.
Step 4 : Append the final table values into the final table.
Hope this helps..
Thanks in advance,
‎2008 Feb 20 3:25 PM
HI Harikrishna,
That 3 tables oen was posted by my friend..we tried it out.but we are unable to get it.can u be little bit clear about the solution.
‎2008 Feb 21 12:20 PM
Hi,
please find the sample code attached with comments. don't bother about the nature of the tables and all just check the logic.
Here i have used only 2 tables., you need to extend for 5 tables.
first table
Data: begin of i_viqmel occurs 0,
qmnum like viqmel-qmnum,
qmart like viqmel-qmart,
strmn like viqle-ltrmn,
end of i_viqmel.
*second table
data: begin of i_viqmma occurs 0,
qmnum like viqmma-qmnum,
mncod like viqmma-mncod,
mngrp like viqmma-mngrp,
pster like viqmma-pster,
pstur like viqmma-pstur,
end of i_viqmma.
final table.
data: begin of i_final occurs 0,
qmnum like viqmel-qmnum,
qmart like viqmel-qmart,
strmn like viqle-ltrmn,
mncod like viqmma-mncod,
mngrp like viqmma-mngrp,
pster like viqmma-pster,
pstur like viqmma-pstur,
end of i_final.
*read first table
Select qmnum
qmart
strmn
ltrmn
into table i_viqmel
from viqmel
up to 10 rows
where qmart = 'Y2'.
*read second table.
Select qmnum
mncod
mngrp
pster
pstur
into i_viqmma
from viqmma
for all entries of i_viqmel
where qmnum = i_viqmel-qmnum.
loop at first table
Loop at i_viqmel.
inside loop create final table
clear i_final.
i_final-qmnum = i_viqmel-qmnum.
i_final-qmart = i_viqmel-qmart.
i_final-strmn = i_viqmel-strmn.
i_final-ltrmn = i_viqmel-ltrmn.
Second table
clear i_viqmma.
read table i_viqmma with key qmnum = i_viqmma-qmnum binary search.
if sy-subrc = 0.
i_final-mncod = i_viqmma-mncod.
i_final-mngrp = i_viqmma-mngrp.
i_final-pster = i_viqmma-pster.
i_final-pstur = i_viqmma-pstur.
endif.
try the same for remaining tables as for second table above
append i_final.
Endloop.
Hope this helps..
Harikrishna.
‎2008 Feb 20 3:12 PM
Create a seperate internal table.
Now loop sperately in each internal table and put the data in your newly created internal table.
‎2008 Feb 20 3:26 PM
1)Write an inner join for all the 5 internal table(if ur requirement meets that) and put it in the final internal table(ALV output)
Eg: select <f1><f2>...<fn> (inner join conditions) into <final internal table>..
2) select data into 5 internal tables(depends).
and then loop it
append/modify the records to final internal table..