Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Selecting fields from a dynamic table into dynamic internal table using dynamic where Clause

swati_mishra2
Explorer
0 Likes
804

Hi Gurus,

My method has below parameters

Importing parameters

Iv_tabname of type tabname

Is_from_rec type any

Exporting parameter

ET_details type any

Is_from_ rec has some fields matching with Iv_tabname which would be dynamic . So Now my question is how do I formulate my where clause based on is_from_rec record and then pass the result of select query to my returning parameter ET_details

Select * from (iv_tabname) into table et_details where (is_from_rec)

1 REPLY 1
Read only

DoanManhQuynh
Active Contributor
0 Likes
594

There are few ways to achive this, i have one:

*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(ITAB) TYPE  CHAR30
*"     REFERENCE(IWHERE) TYPE  CHAR255
*"  EXPORTING
*"     REFERENCE(ET_RESULT) TYPE REF TO  DATA
*"----------------------------------------------------------------------
  FIELD-SYMBOLS <table> TYPE STANDARD TABLE.

  DATA(comp_tab1) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( itab ) )->get_components( ).
  DATA(struct_type) = cl_abap_structdescr=>create( comp_tab1 ).
  DATA(table_type) = cl_abap_tabledescr=>create( struct_type ).

  CREATE DATA et_result TYPE HANDLE table_type.
  ASSIGN et_result->* TO <table>.

  SELECT * FROM (itab) INTO TABLE <table> WHERE (iwhere).