‎2008 Aug 07 7:55 AM
Hi All,
my issue is ....
i have 3 internal tables, and 2 final tables.
i have a field which is same in all three internal tables and in the first final table i have appended all the data from all the three internal tables, it doesn't matter if it is having any duplicate entries in the final table ,
now , i want to tranfer all records from one final table (above final table) to the second final table , but the condition is, only that particular records will be transfered which exists in all the three internal tables ...
Thanks in advance
Regards,
Preetesh
‎2008 Aug 07 8:06 AM
Hi Preetesh,
You can do the following;
loop at itab_final_1.
read itab1
if not found set flag = 'X'.
continue
read itab2
if not found set flag = 'X'.
continue.
read itab3
if not found set flag = 'X'.
continue.
if flag is empty then append itb_final_1 to itab_final_2.
endloop.
rgds
Manish
‎2008 Aug 07 8:01 AM
Loop at final table .
read all the first internal tables with common field .
if sy-subrc = 0 .
read all the second internal tables with common field .
if sy-subrc = 0.
read all the third internal tables with common field .
if sy-subrc = 0.
append in second final table .
else.
no append .
endif.
endif.
endif.
This would solve the problem .
‎2008 Aug 07 8:02 AM
Hello,
ALgorithm should be something like this:
LOOP AT IT_FIN1.
READ IT1 WITH KEY KEY = IT_FIN1-KEY.
IF SY-SUBRC = 0.
READ IT2 WITH KEY KEY = IT_FIN1-KEY.
IF SY-SUBRC = 0.
READ IT3 WITH KEY KEY = IT_FIN1-KEY.
IF SY-SUBRC = 0.
APPEND IT_FIN2.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
Hope this helps.
BR,
Suhas
‎2008 Aug 07 8:02 AM
Try this:
For example we have a field say FLD1 which common in 3 tables (i_temp1,i_temp2,i_temp3) ans in 1 final table (i_final1) .Now att records from these 3 temp tables are populated in i_final1 table.
loop at i_final1.
read i_temp1 with key fld1 = i_final1-fld1.
if sy-subrc = 0.
read i_temp2 with key fld1 = i_final1-fld1.
if sy-subrc = 0.
read i_temp3 with key fld1 = i_final1-fld1.
if sy-subrc = 0.
Populate records from i_final1 to i_final2
append i_final2.
endif.
endif.
endif.
‎2008 Aug 07 8:05 AM
use loop on final table and read rest all two tables if sy-subrc = 0 than append else nothing to do.
Amit.
‎2008 Aug 07 8:05 AM
HI,
First get all the data into first final internal table upto here u dont have any problem righ then wht u do is
loop at first_final_itab.
read table first_itab with (give the fields that u require )
if sy-subrc eq 0.
read table second_itab with (give the fields that u require )
if sy-subrc eq 0.
read table third_itab with (give the fields that u require )
if sy-subrc eq 0.
append fs_first_final_itab to second_final_itab.
endif.
endif.
endif.
endloop.
regards,
Sunil Kumar Mutyala.
‎2008 Aug 07 8:06 AM
Hi Preetesh,
You can do the following;
loop at itab_final_1.
read itab1
if not found set flag = 'X'.
continue
read itab2
if not found set flag = 'X'.
continue.
read itab3
if not found set flag = 'X'.
continue.
if flag is empty then append itb_final_1 to itab_final_2.
endloop.
rgds
Manish
‎2008 Aug 07 8:10 AM
hi.
when you go for 'for all entries' to club the tables than it selects only those data which are present in all the tables.
if u want to transfer data from final table1 to final table 2 than check out this logic:
loop at final_table1 into wa_final1.
read table itba1 into wa1 with key field1 = wa_final1.
if sy-subrc = '0'.
read table itba2 into wa2 with key field1 = wa_final1.
if sy-subrc = '0'.
read table itba3 into wa3 with key field1 = wa_final1.
if sy-subrc = '0'.
wa_final2-field1 = wa_final1-field1.
append wa_final2 to final_table2.
else.
continue.
else.
continue.
else.
continue
endif.
endif.
endif.
endloop.
hope this will help u.
‎2008 Aug 07 8:11 AM
Plz follow below logic.
Data iflag type i.
Data kflag type i.
Data jflag type i.
Loop at it_1st_final.
iflag = 0.
Read table itab1 with key <keyField> = it_1st_final-<key_field>.
if sy-subrc = 0.
iflag = 1.
endif.
jflag = 0.
Read table itab2 with key <keyField> = it_1st_final-<key_field>.
if sy-subrc = 0.
jflag = 1.
endif.
kflag = 0.
Read table itab3 with key <keyField> = it_1st_final-<key_field>.
if sy-subrc = 0.
kflag = 1.
endif.
if iflag = 1 and
jflag = 1 and
kflag = 1 and
Move it_1nd_final to it-2nd_final..
append it_2nd_final.
clear it_2nd-final.
endif.
endloop.
rgds
rajesh
Edited by: RAJESH KUMAR on Aug 7, 2008 12:42 PM
‎2008 Aug 07 9:04 AM
thanks for the response...,
but if we are using READ TABLE ITAB INTO WA WITH KEY (FIELD) it will read only one record,
and the problem is that it will check for the first record each time from the internal table,
and suppose that the same record in the internal table is in third row, then it will not pick that one.....
‎2008 Aug 07 9:24 AM
Hi,
have a look,
loop at first internal table.
read second int table with key <condition>
if you want, delete adjacent duplecates from int table comparing all fields.
assign second int table fields to first int table.
append first int table to final table
read table third int table with key < condition>.
if you want, delete adjacent duplecates from int table comparing all fields.
assign third int table fields to first int table.
append first int table to final table.
endloop.