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

accessing table line with deep structure from dynamic table

0 Likes
4,731

Dear sir,

How you access a deep structure from a dynamic table, I am trying to access the deep structure here.

it consists of

Please advice.

Thanks

1 ACCEPTED SOLUTION
Read only

MateuszAdamus
Active Contributor
3,797

Hello samindra

Maybe something like this will work, although there might be errors, I'm not able to check now.

DATA:
  ld_row TYPE REF TO data.

FIELD-SYMBOLS:
  <lv_field> TYPE any,
  <ld_data> TYPE REF TO data,
  <ls_row> TYPE any.

CREATE DATA ld_row LIKE LINE OF <data>.
ASSIGN ld_row->* TO <ls_row>.

READ TABLE <data> ASSIGNING <ls_row> INDEX 1.
CHECK sy-subrc = 0.

ASSIGN COMPONENT 'ALERT' OF STRUCTURE <ls_row> TO <ld_data>.
CHECK sy-subrc = 0.

ASSIGN COMPONENT 'FIELD_NAME' OF STRUCTURE <ld_data>->* TO <lv_field>.
CHECK sy-subrc = 0.
Kind regards,
Mateusz

Dear sir,

How you access a deep structure from a dynamic table, I am trying to access the deep structure here.

it consists of

Please advice.

Thanks

4 REPLIES 4
Read only

FredericGirod
Active Contributor
3,797

Provide your code

Read only

MateuszAdamus
Active Contributor
3,798

Hello samindra

Maybe something like this will work, although there might be errors, I'm not able to check now.

DATA:
  ld_row TYPE REF TO data.

FIELD-SYMBOLS:
  <lv_field> TYPE any,
  <ld_data> TYPE REF TO data,
  <ls_row> TYPE any.

CREATE DATA ld_row LIKE LINE OF <data>.
ASSIGN ld_row->* TO <ls_row>.

READ TABLE <data> ASSIGNING <ls_row> INDEX 1.
CHECK sy-subrc = 0.

ASSIGN COMPONENT 'ALERT' OF STRUCTURE <ls_row> TO <ld_data>.
CHECK sy-subrc = 0.

ASSIGN COMPONENT 'FIELD_NAME' OF STRUCTURE <ld_data>->* TO <lv_field>.
CHECK sy-subrc = 0.
Kind regards,
Mateusz
Read only

Sandra_Rossi
Active Contributor
3,797

You access the "deep structure" the same way as a "flat structure". In fact, your screenshot shows that the lines of the table are made of data references (especially it's a reference to a structure) so your question is more about how to dereference a data reference -> See Mateusz answer.

Read only

former_member213475
Participant
0 Likes
3,797

Hi,

The dereferencing is as follows. Even though it is an old post, but it will be a reference for many users.

FIELD-SYMBOLS:<fs_table> TYPE table.

ASSIGN lr_data->* TO <fs_table>.

READ TABLE <fs_table> ASSIGNING FIELD-SYMBOL(<fs_struct>) INDEX 1.

ASSIGN <fs_struct>->* to FIELD-SYMBOL(<fs_data>).

ASSIGN COMPONENT 'ENTITYID' OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_entityid>).

ASSIGN <fs_entityid>->* to FIELD-SYMBOL(<fs_value>).

Regards,

Saran.