07-23-2012 8:14 PM
Hi all,
I need to create a dynamic Read Table.
Thing is like this:
My key needs to be dynamic, not just the values but the fields too.
Has to be something like this:
READ TABLE l_i_table ASSIGNING <table>
WITH KEY field_1 = value_1
field_2 = value_2
....
field_n = value_n.
The fields to be used in the key (field_1, field_2 ... field_n) are read from a dictionary table.
Any idea?
Thanks in advance.
Nico.-
07-24-2012 5:09 AM
Hi,
If you know the maximum no of keys, then you can use the approach listed above.
If you dont, check my reply in this post.
http://scn.sap.com/thread/3169985
Thanks,
Shambu
07-23-2012 8:42 PM
DATA KEY1(10) DEFAULT ‘FIELD’
READ TABLE ALL_CUSTOMERS WITH KEY (KEY1) = VALUE1.
07-23-2012 8:49 PM
Thanks Carlos
But remember I can have n fields, how can I add fields to the key?
07-23-2012 8:48 PM
READ TABLE itab WITH KEY k1 = f1 ... kn = fn result.
The search key consists of arbitrary table fields k1 ... kn. If you do not know the name of a component until runtime, you can specify it dynamically as the content of a field n1 ... nn using (n1) = f1 (n2) = f2 . If n1 ... nn is empty when the statement is executed, the search field is ignore
07-24-2012 5:09 AM
Hi,
If you know the maximum no of keys, then you can use the approach listed above.
If you dont, check my reply in this post.
http://scn.sap.com/thread/3169985
Thanks,
Shambu
07-24-2012 2:01 PM
Thanks Shambu
I was doing it by using 10 variables in the key guessing there will not be more than 10 fields, but your apporach to make the whole statement dynamic is great. I will use that,
Thanks.
Nico.-