Dear DB experts,
I have to achieve the following query:
select * from dbtable into table int_table_temp for all entries in
int_table2 where dbtable-field1 = int_table2-field1.
But executing the above query I am getting the error since dbtable-field1 is of CHAR 32 and int_table2-field1 is of type RAW 16,
though they have the same data.Error saying that when you use FOR ALL ENTRIES , then data type and length have to be same for the field of WHERE clause.
Is there any alternative way to achieve the result that above query does.
Your inputs are highly appreciated.
For FOR ALL ENTRIES, you need to use and compare same datat types data for compatibility reasons. So if you are sure that the data is going to be same in both the internal tables, you can pass the data in internal table int_table2-field1to a field having CHAR 32 as datatype and then compare with the data content in dbtable-field1.
Hope its clear.
Edited by: SAP USER on Jan 15, 2010 11:42 AM
Thanks a lot for your quick reply.
I do not have same field having same datatype and length in DB and ITab.Assuming that I cannot change the DB and ITab structure, I am looking for alternative ways i,e alternative ABAP statement to get the result similar to the above query.
My idea here is to improve the performance.
By following your suggestion , I do not think I would be able to achive this.
Earlier we were looping through int_tab2 and for each of the entries in this itab, we were selecting from DB. by comparing the guids.
To avoid that i thought of coming up with the above ABAP statement.
Any other suggestions?
You need to slightly tweak the logic here.
Take another internal table and declare a field of type dbtable-field1.
TYPES: BEGIN OF t_tab3, field1 TYPE dbtable-field1, END OF t_tab3. DATA: itab3 TYPE STANDARD TABLE OF t_tab3, wa1 TYPE t_tab3. LOOP AT int_table_temp INTO wa. MOVE wa-field1 TO wa_wa1-field1. APPEND wa1 TO itab3. ENDLOOP. IF NOT itab3 IS INITIAL. "This check is Mandatory select * from dbtable into table int_table_temp for all entries in itab3 where dbtable-field1 = itab3-field1. ENDIF.
If your dbtable field has higher length, You can use the offset aswell but not the right way.
WHERE dbtable+0(length) EQ comparision field.