Skip to Content

How can I make a dynamic Read Table?

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.-

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 24, 2012 at 04: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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 23, 2012 at 07:42 PM

    DATA KEY1(10) DEFAULT ‘FIELD’

    READ TABLE ALL_CUSTOMERS WITH KEY (KEY1) = VALUE1.


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2012 at 07: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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.