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

dynamic condition

Former Member
0 Likes
803

hi,

im working on a scenario like below:

i have a function module-RFC which has a table type parameter containing fields, values and type i.e. parameter or selection option

ex: S, s_matnr, matnr, I, EQ, (LOW), (HIGH)--- selectoptions

      P, p_date, data (VALUE)  --- parameter

i have to build a select query like below

select * from (MARA) into table (<dyn_table>) where matnr in s_matnr and date = p_date.

the parameters that i pass to the FM will differ.

it may have only 2 parameters as above or 5 or 7 or n.

how can i build where condition?

i am able to build range of tables using below code:


TYPES:BEGIN OF ty_dyntab,

   name TYPE string,      "Int. table name

   data TYPE REF TO data, "Int. table data

END OF ty_dyntab.


do lv_lines times.

     write sy-index to lv_index no-ZERO.

   CONCATENATE 'lt_table' lv_index into gs_dyntab-name.

   read table i_selopt into wa_selopt index sy-index.

     create DATA gs_dyntab-data type STANDARD TABLE OF (wa_selopt-field).

     append gs_dyntab to gt_dyntab.

   enddo.

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
0 Likes
581

You can put everything in variables :

SELECT (fields) FROM (table) ... WHERE (cond)

Read only

RaymondGiuseppi
Active Contributor
0 Likes
581

Look at FM like CONVERT_SELECT_INTO_WHERE or similar FM to convert your select-options/TVARVC records to a where clause.

Regards,

Raymond