I have an internal table which is combined by two fields:
data: begin of itab occurs 0,
tabname like dd03l-tabname,
tabkey(100) type c,
end of itab.
that is to say, when I loop the itab then I know the database table name and its tablekey value. My requirement is I want to get a single record by the itab-tabkey from the database table itab-tabname. But I don't know how to build the WHERE condition for my SQL in this case.
In my original idea, I will get the key fields from table DD03L by the table name itab-tabname, and get the data element for the this table's key field, then I use the data elements to get the field length for each key data element from table DD04L. At last I can know each key fields and it lenth, then I want to use off-set of
itab-tabkey by knowing key field's length to combine my WHERE condition. At this point I don't know how to do it.
If my idea is right, can any experts give me a solution for this dynamic SQL??
If my idea is wrong, can any experts give me a right solutions??
Now I give an example for the ITAB.
company code: 1000
Purchase Org: 1001
Sales Org: 1001