I have the name of a table DATA lv_tablename TYPE tabname VALUE 'xxxxx'
, and a generic FIELD-SYMBOLS: <lt_table> TYPE ANY TABLE.
which contains entries selected from that corresponding table.
I've defined my line structure FIELD-SYMBOLS: <ls_line> TYPE ANY.
which i'd use for reading from the table.
Is there a way to create a READ statement on <lt_table>
fully specifying the key fields?
I am aware of the statement / addition READ TABLE xxxx WITH KEY (lv_field_name) = 'asdf'.
, but this however wouldn't work (afaik) for a dynamic number of key fields, and I wouldn't like to create a large number of READ TABLE
statements with an increasing number of key field specifications.
Can this be done?
Actually i found this to work
By using this syntax one can just specify as many key fields as required. If some fields will be empty, then these will just get ignored, even if values are specified for these empty fields.
One must pay attention that using this exact syntax (static definitions), 2 fields with the exact same name (even blank names) will not be allowed.
As shown with the variables
lv_string1
andlv_string2
, at run-time this is no problem.And lastly, one can specify the fields in any order (i don't know what performance benefits or penalties one might get while using this syntax)
There seems to be the possibility ( like a dynamic select statement whith binding and lt_dynwhere ).
Please refer to this post, there was someone, who also asked for the requirement:
http://scn.sap.com/thread/1789520