‎2011 Aug 05 4:55 AM
hello Gurus,
i am working on dynamic sql and somehow i am not able to understand where my sqk is going wrong. please help
here is the scenario
query is
select ( v_list ) from ( v_from ) into table <table> where <v_where> group by <gb_where>
v_list = min( marcmatnr) marcwerks
v_from = marc
v_where = marc~matnr > '1001
gb_where = marc~werks
i have checked these values in Debug which looks correct to me but it is throwing me
CX_SY_DYNAMIC_OSQL_SEMANTICS this error
i have executed this sql without dynamic query and with actual value its going fine but not with dynamic
please help!!!!
regards,
Khushy
‎2011 Aug 05 7:38 AM
Hi,
Try with the following piece of code.
TYPES : BEGIN OF ty_marc,
matnr TYPE mara-matnr,
werks TYPE marc-matnr,
END OF ty_marc.
DATA : v_list TYPE char40,
v_from TYPE char20,
v_where TYPE char20,
gb_where TYPE char20.
DATA : t_marc TYPE TABLE OF ty_marc.
FIELD-SYMBOLS : <table> TYPE ANY TABLE .
v_list = 'MIN( marc~matnr ) marc~werks'.
v_from = 'marc'.
v_where = text-001. "marc~matnr > '1001'
gb_where = 'marc~werks'.
ASSIGN t_marc TO <table>.
IF sy-subrc = 0.
SELECT (v_list)
FROM (v_from)
INTO TABLE <table>
WHERE (v_where)
GROUP BY (gb_where).
IF sy-subrc NE 0.
MESSAGE i899(v1) WITH 'Error or No data found !!'
space
space
space.
ENDIF.
ENDIF.
Thanks.
‎2011 Aug 05 6:23 AM
hello,
you can not use aggregations within dynamic sql statement.
br,
dez_
‎2011 Aug 05 7:38 AM
Hi,
Try with the following piece of code.
TYPES : BEGIN OF ty_marc,
matnr TYPE mara-matnr,
werks TYPE marc-matnr,
END OF ty_marc.
DATA : v_list TYPE char40,
v_from TYPE char20,
v_where TYPE char20,
gb_where TYPE char20.
DATA : t_marc TYPE TABLE OF ty_marc.
FIELD-SYMBOLS : <table> TYPE ANY TABLE .
v_list = 'MIN( marc~matnr ) marc~werks'.
v_from = 'marc'.
v_where = text-001. "marc~matnr > '1001'
gb_where = 'marc~werks'.
ASSIGN t_marc TO <table>.
IF sy-subrc = 0.
SELECT (v_list)
FROM (v_from)
INTO TABLE <table>
WHERE (v_where)
GROUP BY (gb_where).
IF sy-subrc NE 0.
MESSAGE i899(v1) WITH 'Error or No data found !!'
space
space
space.
ENDIF.
ENDIF.
Thanks.
‎2011 Aug 05 9:13 AM