2006 Jun 26 1:33 PM
Hi All,
I am using a dynamic internal, populating the same in program itself and the trying to pass the same in the select clause
following 2 lines are populated in the internal table i_where.
DATA i_where TYPE STANDARD TABLE OF char100.
these lines are populated in i_where.
A~LIFNR IN <L_TABLE1>
AND A~LIFNR = vendor_tab-LIFNR.
*****************************************************
SELECT a~lifnr FROM lfa1 as a
inner join lfm1 as m
on alifnr = mlifnr
INTO TABLE i_vendor
FOR ALL ENTRIES IN vendor_tab
WHERE (i_where).
*******************************************************
but the query doesnt execute......
if I write the same query as
SELECT a~lifnr FROM lfa1 as a
inner join lfm1 as m
on alifnr = mlifnr
INTO TABLE i_vendor
FOR ALL ENTRIES IN vendor_tab
WHERE A~LIFNR IN <L_TABLE1>
AND A~LIFNR = vendor_tab-LIFNR.
I am getting the desired result....
Can anyone guide me why is this happening?
Thanks & Regards
Dnyanesh
Hi All,
I am using a dynamic internal, populating the same in program itself and the trying to pass the same in the select clause
following 2 lines are populated in the internal table i_where.
DATA i_where TYPE STANDARD TABLE OF char100.
these lines are populated in i_where.
A~LIFNR IN <L_TABLE1>
AND A~LIFNR = vendor_tab-LIFNR.
*****************************************************
SELECT a~lifnr FROM lfa1 as a
inner join lfm1 as m
on alifnr = mlifnr
INTO TABLE i_vendor
FOR ALL ENTRIES IN vendor_tab
WHERE (i_where).
*******************************************************
but the query doesnt execute......
if I write the same query as
SELECT a~lifnr FROM lfa1 as a
inner join lfm1 as m
on alifnr = mlifnr
INTO TABLE i_vendor
FOR ALL ENTRIES IN vendor_tab
WHERE A~LIFNR IN <L_TABLE1>
AND A~LIFNR = vendor_tab-LIFNR.
I am getting the desired result....
Can anyone guide me why is this happening?
Thanks & Regards
Dnyanesh
2006 Jun 26 1:36 PM
Hai
Check the following Code
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.
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
CONCATENATE 'VBELN' 'IN' 'S_VBELN.'
INTO CONDITION SEPARATED BY SPACE.
SELECT VBELN POSNR FROM VBAP INTO TABLE ITAB
WHERE (CONDITION).
LOOP AT ITAB.
WRITE 'hello'.
ENDLOOP.
Thanks & regards
Sreenivasulu P
2006 Jun 26 1:38 PM
Hi,
Instead of declaring i_where type table declare it of type char or string and then use it.
Amit
2006 Jun 26 1:38 PM
To specify a condition dynamically, use:
SELECT ... WHERE (<itab>) ...
<i>where <itab> is an internal table with line type C and maximum length 72 characters. All of the conditions listed above except for selection tables, can be written into the lines of <itab>. However, you may only use literals, and not the names of data objects. The internal table can also be left empty.</i>
so try reducing the size of ur internal table to 70 or so...
Reward points if it helps
Regards
Gunjan
Message was edited by: Gunjan Kumar
2006 Jun 26 2:20 PM
See this exapmle:
Example
Creating a dynamic comparison from user input. In the case of incorrect syntax or incorrect semantics, exceptions are generated, which are handled using the common superclass.
PARAMETERS: column(8) TYPE c,
value(30) TYPE c.
DATA spfli_wa TYPE spfli.
DATA cond_syntax TYPE string.
CONCATENATE column '= value'
INTO cond_syntax SEPARATED BY space.
TRY.
SELECT SINGLE *
FROM spfli
INTO spfli_wa
WHERE (cond_syntax).
CATCH cx_sy_dynamic_osql_error.
MESSAGE `Wrong WHERE condition!` TYPE 'I'.
ENDTRY.
I think the only mistake you have done is the declaration of the i_where as an internal table instead of a string.
Regards,
ravi
2006 Jun 26 2:33 PM
Hi,
Cross check with ST05 ; u will come know how exactly the select query getting generated.
1) put break point before select query and start debugging
2) open another session for transaction ST05
3) click activate trace
4) come back to the debugging screen press F5 to execute the select query.
5) go back to ST05 and click deactivate trace ; u will
find select query ; which being executed.
Hope it helps.
Mark Helpfull Answers
2006 Jun 26 2:37 PM
hi,
i think you can <b>not</b> use variable like <L_TABLE1>
in where clause - only constants
Andreas
2006 Jun 26 3:00 PM
We should use 'into corresponding fields of table'
in the select clause .......then it is working.
thanks for the suggestions.....
2006 Jun 26 4:01 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |