ABAP dynamic WHERE clause In LOOP AT statement

I need to do a loop on my internal table according to the where clause, but according to the mode of my program, the where clause field must be changed at runtime.

I know it is possible in a SELECT statement, but when I do it in a loop, I have an error.

This is my code:

CASE gv_cdvue.
  WHEN 'L'.
    lv_condi = 'dcmdr GE gv_daybf   OR dcmdr LE gv_daybf   '.
  WHEN 'C'.
    lv_condi = 'dcldr GE gv_daybf   OR dcldr LE gv_daybf   '.
  WHEN 'E'.
  WHEN OTHERS.


ENDCASE.


  LOOP AT gt_plcad INTO ls_plcad  WHERE (lv_condi).
    ....
  ENDLOOP.

      

My mistake:

Statement concluding with "...(LV_CONDI)" ended unexpectedly.

      

+3


source to share


1 answer


You are getting an error due to your SAP incompatibility. Dynamic when the condition in the loop adds version 7.0 EhP2. You must exceed 7.0 Ehp2, then only you can write a dynamic condition.



Hope this answer helps you.

+3


source







All Articles