‎2007 Dec 09 1:32 AM
i have a simple loop query. I want to get same data from 3 different tables into a single internal table like
if tab1 data is not available then tab2 then tab3.
now when i use my internal table how do i fill data into my internal table and what will be my loop condition.
i have already written select statement.
a sample code will be of great help
‎2007 Dec 09 10:31 AM
Hi,
The above said code I think it doesn't work properly because in the select statement from table name placed after the internal table and also no need of append statement.
Use like this...(itab-Internal table name)
Select * from tab1 into table itab
where (condition).
if sy-subrc <> 0.
Select * from tab2 into table itab
where(condition).
if sy-subrc <> 0.
Select * from tab3 into table itab
where (condition).
endif.
endif.
Now you will get value in the internal table itab.Three different tables where tab1,tab2,tab3.
Thanks,
Sakthi C
*Rewards if useful--*
‎2007 Dec 09 2:27 AM
Hi,
Paste your code here which you have written, so that it will be easy for us to guide you.
Regards,
Satish
‎2007 Dec 09 5:32 AM
to get data from different table into one table use following code
select * from ztab1 into table itab where <...>.
select * from ztab2 appending table itab where <.....>.
‎2007 Dec 09 6:27 AM
paste ur code here so that problem can b understood clearly
for getting data
first select
if sy-subrc <> 0 " in case of not getting data in first select
put here 2nd select
then again
put if sy-subrc <> 0 " in case of not getting data in 2nd and first select
put third select statement
if u provide ur code then may b we can help a little more
regards
‎2007 Dec 09 9:16 AM
Hi, sample code below:
select * into ITAB from TAB1 where <conditions>.
append ITAB.
endselect.
if sy-subrc <> 0.
select * into ITAB from TAB2 where <conditions>.
append ITAB.
endselect.
if sy-subrc <> 0.
select * into ITAB from TAB3 where <conditions>.
append ITAB.
endselect.
endif.
endif.
‎2007 Dec 09 10:31 AM
Hi,
The above said code I think it doesn't work properly because in the select statement from table name placed after the internal table and also no need of append statement.
Use like this...(itab-Internal table name)
Select * from tab1 into table itab
where (condition).
if sy-subrc <> 0.
Select * from tab2 into table itab
where(condition).
if sy-subrc <> 0.
Select * from tab3 into table itab
where (condition).
endif.
endif.
Now you will get value in the internal table itab.Three different tables where tab1,tab2,tab3.
Thanks,
Sakthi C
*Rewards if useful--*
‎2007 Dec 09 6:56 PM
Thanks for your help guys.
I was able to resolve it looking at the sample code provided.
I have awarded points
Regards