Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Question about reading generic tables with keys

Former Member
0 Kudos

Hello

I'm wondering if it's possible to read a generic table with key statement:

FIELD-SYMBOLS:
    <lv_key>         TYPE zconf_key,

    <lt_data_bi>     TYPE INDEX TABLE,
    <lt_data_ai>     TYPE INDEX TABLE,

    <ls_data_bi>     TYPE any,
    <ls_data_ai>     TYPE any.


* create data types
  CREATE DATA lt_data_bi TYPE (ls_node-data_table_type).
  ASSIGN lt_data_bi->* TO <lt_data_bi>.
  CREATE DATA lt_data_ai TYPE (ls_node-data_table_type).
  ASSIGN lt_data_ai->* TO <lt_data_ai>.

* do check
  LOOP AT <lt_data_ai> ASSIGNING <ls_data_ai>.
    ASSIGN COMPONENT 'KEY' OF STRUCTURE <ls_data_ai> TO <lv_key>.

    READ TABLE <lt_data_bi> WITH KEY key = <lv_key>
    ASSIGNING <ls_data_bi> BINARY SEARCH.

I receive the message: "The specified type has no structure and therefore no component called KEY" in the read statement above.

Does anyone has an idea what I can do here?

Regards,

Mathias

2 REPLIES 2

former_member194669
Active Contributor
0 Kudos

> READ TABLE <lt_data_bi> WITH KEY key = <lv_key>

In your structure ls_data_bi there is no field called KEY . please check whether you have field KEY in structure

a®s

0 Kudos

Hi

ls_bi_data is a ANY structure. Since we're looking for a generic solution, we want to use ANY. We're looking for a way to check if ANY structure contains a component name KEY.

Regards,

Mathias