cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing a table from dynamic reference ABAP object

former_member450029
Participant

Hi Experts,

I am trying to access a table from the dynamic object for which I am not able to read it. Below is the syntax I fave tried.

ASSIGN <FS_DATA>->('MT_DATA') TO FIELD-SYMBOL(<FS_IT>).

Muthu_raja
Active Participant
0 Kudos

Hi Eshwar,

It will very helpful to look into, if you paste the code and tell us where you are getting an issue. Use insert code option in the editor when pasting it.

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor
ASSIGN ('<FS_DATA>->MT_DATA') TO FIELD-SYMBOL(<FS_IT>).

Note that it will always remain impossible to overtake the visibility rules (for instance it wouldn't work if the attribute is private and you try to assign it from outside the class).

PS: the title of your question is incorrect because it's more about accessing an object attribute dynamically.

former_member450029
Participant
0 Kudos

Hi Sandra,

Thanks for your answer! That didn't work.

I need to access MT_BUS_DATA_ADJ from here.

Sandra_Rossi
Active Contributor
0 Kudos

eshwarbogaraju That "didn't work" because of the visibility rules, as I have explained. Don't you see your attribute is protected? (so you can access it only from a subclass or a friend class).

So, that's another question.

To access a protected or private attribute, you have the possibility to enhance the standard (enhancement framework) to add a custom public method which returns this attribute, then you may call your public method from any place (because it's public).

former_member450029
Participant

Thanks Sandra Rossi,

Information you have provided was useful. Anyways I have used standard class and method through which I can get those values through casting.

Answers (1)

Answers (1)

rajkumarnarasimman
Active Contributor
0 Kudos

Hi Eshwar,

Check and try the below line

ASSIGN COMPONENT 'MT_DATA' OF STRUCTURE <FS_DATA> TO FIELD-SYMBOL(<FS_IT>).

Regards

Rajkumar Narasimman

former_member450029
Participant
0 Kudos

Hi Rajkumar,

Thanks for the answer! That syntax is not working. I have attached a screenshot for Sandra Rossi's answer from where I have to read data.