04-05-2010 11:23 AM
Hello SDNers,
I am having a dynamic internal table & want to use FOR ALL ENTRIES(FAE) using this dyn. table.
This works fine for me:
IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
SELECT field1 field2
FROM TABLE ztable
INTO TABLE itab "Itab is a static table
FOR ALL ENTRIES IN <lt_tmp>
WHERE (lv_dynwhere). "lv_dynwhere -> dynamic where clause
ENDIF.
SAP documentation says:
"The logical expression sql_cond of the WHERE condition can be comprised of several logical expressions using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one comparison with a column of the internal table itab that can be specified statically or dynamically. "
How do we specify the column of the internal table dynamically ? Can we do something like this:
IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
SELECT field1 field2
FROM TABLE
INTO TABLE itab "Itab is a static table
FOR ALL ENTRIES IN <lt_tmp>
WHERE key_field1 = (dynamic token for column1 of <lt_tmp>)
key_field2 = (dynamic token for column2 of <lt_tmp>)
ENDIF.
ENDIF.
Let me know if i am not clear about my requirement.
BR,
Suhas
04-05-2010 7:36 PM
Hi Suhas,
I don't really see why you specifically need to write
WHERE key_field1 = (dynamic token for column1 of <lt_tmp>) AND
key_field2 = (dynamic token for column2 of <lt_tmp>)
when you can build and use any dynamic where clause (including addressing the fields of the internal table used in FAE) via
WHERE (lv_dynwhere)
I think the second syntax is what the quoted help text is referring to.
Thomas
04-05-2010 11:59 AM
04-05-2010 12:03 PM
I have already read this message. Thanks anyways.
Any ideas guys ?
Edited by: Suhas Saha on Apr 5, 2010 7:51 PM
04-05-2010 3:28 PM
04-05-2010 5:43 PM
Sorry for not mentioning it. I am on ECC 5.0 @ work & SAP NW 7.01 @ home
BR,
Suhas
04-05-2010 5:54 PM
The help file also says:
> The logical expression sql_cond of the WHERE condition can comprise various logical expressions by using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one Comparison with a column of the internal table itab, which can be specified either statistically or dynamically (Release 6.40 and higher).
Note the "Release 6.40 and higher".
Rob
04-05-2010 6:00 PM
Hi Suhas,
There is two solutions.
1. If you declare field symbol with static structure then you can do normally. like
IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
SELECT field1 field2
FROM TABLE ztable
INTO TABLE itab "Itab is a static table
FOR ALL ENTRIES IN <lt_tmp>
WHERE field1 = <it_temp>-fld1.
ENDIF.
2. If the declare is dynamic(i.e type any table)You can generate one subroutine pool at runtime with the dynamic where clause. Then there will no syntax error.
Thanks,
Subhankar
04-05-2010 7:36 PM
Hi Suhas,
I don't really see why you specifically need to write
WHERE key_field1 = (dynamic token for column1 of <lt_tmp>) AND
key_field2 = (dynamic token for column2 of <lt_tmp>)
when you can build and use any dynamic where clause (including addressing the fields of the internal table used in FAE) via
WHERE (lv_dynwhere)
I think the second syntax is what the quoted help text is referring to.
Thomas
04-06-2010 7:22 AM
Hello Thomas,
What i meant was something like this:
WHERE key_field1 = ('<LT_TMP-COL1>') AND
key_field2 = ('<LT_TMP-COL2>')
I am confused by what SAP means with "dynamic representation of internal table columns" in FAE ?
@Rob: I was referring to SAPNW 7.0 documentation & the phrase (release 6.40 & higher) is missing. Anyways fyi i am on ECC5.0 ABAP release 6.40.
@Subhankar: This is what Marcin had proposed in .
Thanks,
Suhas
Edited by: Suhas Saha on Apr 6, 2010 11:53 AM
04-19-2010 10:46 AM
For future reference.
In ECC5.0 only way to achieve this would be create a dynamic WHERE clause with the internal table fields as mentioned in the post.
I don't think dynamic tokens are supported.