Skip to Content

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

Dynamic Where Clause

Hi,

REPORT  ZDYNAMIC_WHERE.

TABLES: VBAK.
DATA: CONDITION TYPE STRING.
DATA: BEGIN OF ITAB OCCURS 0,
        VBELN LIKE VBAK-VBELN,
        POSNR LIKE VBAP-POSNR,
     END OF ITAB.
DATA: IT_OPTIONS LIKE RFC_DB_OPT OCCURS 0 WITH HEADER LINE.

SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
CONCATENATE 'VBELN'  'IN'  'S_VBELN.' INTO CONDITION SEPARATED BY SPACE.

IT_OPTIONS-TEXT = CONDITION.
APPEND IT_OPTIONS.
CLEAR IT_OPTIONS.
SELECT VBELN
       POSNR
       FROM VBAP
       INTO TABLE ITAB
       WHERE (IT_OPTIONS).

LOOP AT ITAB.

  WRITE 'hello'.

ENDLOOP.

the above code i'm unable to use select options in where clause, is there any other way to use select options in dynamic where clause.

Please suggest the possible solution if any.

Regards

vijay

Tags:
Not what you were looking for? View more on this topic or Ask a question