06-08-2010 8:23 AM
HI al,
I have a problem with my dynamic select statement here.
DATA lt_custom_rpt TYPE STANDARD TABLE OF yxapy_custom_rpt.
DATA a_name TYPE char40.
DATA lv_cond type char40.
CONSTANTS lv_mark TYPE c VALUE 'X'.
a_name = 'reporting'.
CONCATENATE a_name '=' lv_mark INTO lv_cond SEPARATED BY space.
SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_custom_rpt
FROM yxapy_custom_rpt
WHERE (lv_cond).
I run it from my webdynpro page and it retun error "A conditio specified at runtime has an unexected format".
However, when I revert it to the static code below, it runs fine.
SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_custom_rpt
FROM yxapy_custom_rpt
WHERE reporting = 'X'.
Anyone have any idea on how to change it to dynamic condition?
06-08-2010 8:34 AM
Hi,
In dynamic selects you have to put constants into apostrophes:
CONCATENATE a_name '= ''' INTO lv_cond SEPARATED BY space.
CONCATENATE lv_cond lv_mark '''' INTO lv_cond.
Regards, Gerd Rother
06-08-2010 8:34 AM
Hi,
In dynamic selects you have to put constants into apostrophes:
CONCATENATE a_name '= ''' INTO lv_cond SEPARATED BY space.
CONCATENATE lv_cond lv_mark '''' INTO lv_cond.
Regards, Gerd Rother
06-08-2010 9:08 AM
Hi Siong
Right now in your code : the where condition you are building is reporting = X and not reporting = 'X'.
Declare
CONSTANTS lv_mark(3) TYPE c VALUE '''X'''.
instead of
CONSTANTS lv_mark TYPE c VALUE 'X'.
Regards
Deepa