Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Dynamic select statement

Hi All,

Is there a way that I send the table name (Ex: ZPR_PHASE, ZPR_PROGRAM...) into a method or function and I get all the entries of the table.

A general method to get all the values.

Thanks and regards,

Bindiya

Former Member
Former Member replied

Hi,

You can use the following:

data: t_result type ref to data,
      cl_table type ref to cl_abap_tabledescr.
field-symbols: <ft_result> type standard table.

cl_table ?= cl_abap_tabledescr=>describe_by_name( lv_tabname ).
create data t_result type handle cl_table.
assign t_result->* to <ft_result>.

SELECT (lv_fieldname) FROM (lv_tabname) INTO CORRESPONDING FIELDS OF TABLE <ft_result>.

Regards,

Tanguy

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question