Application Development and Automation 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: 
Read only

Dynamic read on an internal table

Former Member
0 Likes
786

Hi all,

I have the following problem : I have a method which takes a deep structure as input parameter. Each field of this structure is a table which has field 'Key' as key field. In the method, I assign each table to a field symbol, for which I find out the type dynamically. When I try to read the data in the tables using read statement and giving field 'Key' in the read instruction, I get a syntax error telling me that no field with name 'Key' exists in the table(since its type is dynamically determined). As far as I know, it is not possible to write dynamic statements in for read table TAB with key (key_field_name) = '123'. Does someone have any idea how this problem can be solved?

Kind Regards,

Sükrü

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
701

Hi

Yes it can: see help fpr statament READ.

You can write:

READ TABLE ITAB WITH KEY (KEY1) = <V1>

(KEY2) = <V2>

(KEY3) ....

Max

Hi all,

I have the following problem : I have a method which takes a deep structure as input parameter. Each field of this structure is a table which has field 'Key' as key field. In the method, I assign each table to a field symbol, for which I find out the type dynamically. When I try to read the data in the tables using read statement and giving field 'Key' in the read instruction, I get a syntax error telling me that no field with name 'Key' exists in the table(since its type is dynamically determined). As far as I know, it is not possible to write dynamic statements in for read table TAB with key (key_field_name) = '123'. Does someone have any idea how this problem can be solved?

Kind Regards,

Sükrü

6 REPLIES 6
Read only

anversha_s
Active Contributor
0 Likes
701

hi,

try this.

eg;

READ TABLE ITAB

WITH TABLE KEY key = '123'.

all the best.

anver

Read only

Former Member
0 Likes
702

Hi

Yes it can: see help fpr statament READ.

You can write:

READ TABLE ITAB WITH KEY (KEY1) = <V1>

(KEY2) = <V2>

(KEY3) ....

Max

Read only

Former Member
0 Likes
701

Hi Suekrue,

Try this..

'CATSXT_GET_DDIC_FIELDINFO' function module for getting field names of a structure.

pass ur table name get the fields and pass the fields to the read statement.

-Anu.

Read only

athavanraja
Active Contributor
0 Likes
701

you can do that.

check this code sample.

data: itab type flighttab .
data: itab_wa type sflight .
data: fnam(40) .

fnam = 'CARRID' .

select * from sflight into table itab .

read table itab into itab_wa with key (fnam) = 'PP' .

Regards

Raja

Read only

Former Member
0 Likes
701

Hi Anver,

Sorry, my question is not about the syntax of the read statement. It is about reading from an internal table of which type is known at runtime. We only know that there is a field named 'Key' which is key in all tables.

Regards,

Sükrü

Read only

Former Member
0 Likes
701

Thanks Max and Raja. It solved the problem. I have overseen this feature of the read statement.

Kind Regards,

Sükrü