‎2022 Jun 14 8:33 PM
Hi guys,
I want to compare two columns from an internal table (Specification number and Material Number) to the same two columns in a database table (ESTMJ). The specification number and material number assignment in the internal table should be the same as the specification number and material number assignment in the database table. I am pretty new to ABAP. How do i go about this comparison?
Should I pull the data from the db table and then compare it with the internal table? or can i directly compare the two columns of both tables?
Thanks in advance 🙂
Best regards
Ejas.
‎2022 Jun 14 9:37 PM
Version 1:
Your internal table is ITAB1.
//declare a 2nd internal table
table I_ESTMJ_2 like ESTMJ.
//load this 2nd internal table
select * from ESTMJ into table i_ESTMJ_2.
//compare
loop at ITAB1.
read table i_ESTMJ_2 where/with {material number assignment, aka, whatever you specifically looking for}
if sy-subrc <> 0.
/*do whatever you wanted if records don't match or don't exist*/
endif.
endloop.
Version 2, delete what's extra:
loop at ITAB1.
delete i_ESTMJ_2 where {I_STMJ_2 material number assignment} ne {ITAB1-material number assignment}.
endloop.
‎2022 Jun 14 9:37 PM
Version 1:
Your internal table is ITAB1.
//declare a 2nd internal table
table I_ESTMJ_2 like ESTMJ.
//load this 2nd internal table
select * from ESTMJ into table i_ESTMJ_2.
//compare
loop at ITAB1.
read table i_ESTMJ_2 where/with {material number assignment, aka, whatever you specifically looking for}
if sy-subrc <> 0.
/*do whatever you wanted if records don't match or don't exist*/
endif.
endloop.
Version 2, delete what's extra:
loop at ITAB1.
delete i_ESTMJ_2 where {I_STMJ_2 material number assignment} ne {ITAB1-material number assignment}.
endloop.
‎2022 Jun 14 9:59 PM
Thanks a lot Mikhail. Much appreciated 🙂
‎2022 Jun 15 9:36 AM
You can: Select Inner join two data table.