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

Retrieve data from internal table dynamically

Former Member
0 Likes
990

Hi every body,

I have an internal table which is generated by a function, this table contains two fields: id_field and value_field.

when the internal table is created, it will be completed as follows:

___________________________________________

id_field

value_field

|________________|__________________________|

| PARTNER | 0020023658 |

TYPE

type 1

BPKIND

val1

BU_GROUP

val2

BPEXT

val3

|________________|__________________________|

I want to retrieve the values of each field in id_field in a structure, like this:

ls_struct-partner = '0020023658'.

ls_struct-type = 'type 1'.

ls_struct-bpkind = 'val1'.

ls_struct-bu_group = 'val2'.

ls_struct-bpext = 'val3'.

and it should dynamically, because I have more than one partner and I have lot of fields.

If you have any idea, help !

Mll Mat

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
791

Hi,

You can achive this with READ also.

With symbols you can do as follows:-

data: <fs> type any.

loop at itab into wa.

assign component wa-id_field of structure ls_struct

to <fs>.

<fs> = wa-value_field.

endloop.

Now ls_struct will contain all the values in the corresponding fields.

Regards,

Ankur Parab

5 REPLIES 5
Read only

Former Member
0 Likes
791

hey..

try with field symbols..

Regards,

KC

Read only

0 Likes
791

Hi Krishna,

How can I use Fied symbol ? I never use it

can you help me please.

Mll Mat

Read only

Former Member
0 Likes
792

Hi,

You can achive this with READ also.

With symbols you can do as follows:-

data: <fs> type any.

loop at itab into wa.

assign component wa-id_field of structure ls_struct

to <fs>.

<fs> = wa-value_field.

endloop.

Now ls_struct will contain all the values in the corresponding fields.

Regards,

Ankur Parab

Read only

former_member189420
Active Participant
0 Likes
791

>

> Hi every body,

>

> I have an internal table which is generated by a function, this table contains two fields: id_field and value_field.

> when the internal table is created, it will be completed as follows:

> ___________________________________________

> | id_field | value_field |

> |________________|__________________________|

> | PARTNER | 0020023658 |

> | TYPE | type 1 |

> | BPKIND | val1 |

> | BU_GROUP | val2 |

> | BPEXT | val3 |

> |________________|__________________________|

>

> I want to retrieve the values of each field in id_field in a structure, like this:

>

> ls_struct-partner = '0020023658'.

> ls_struct-type = 'type 1'.

> ls_struct-bpkind = 'val1'.

> ls_struct-bu_group = 'val2'.

> ls_struct-bpext = 'val3'.

>

Check the following code:

data: itab_struct type standard table of struct,
        ls_struct type struct.

Let itab_fm be the internal table that will be populated after executing the FM and wa_fm be the work area of the same.

Let struct be the structure of the ls_struct that you have mentioned containing id_field and value_field as elements.

Loop at itab_fm into wa_fm.

      ls_struct-(wa_fm-id_field) = wa_fm-value_field.

endloop.

append ls_struct to itab_struct.

Hope this helps. This is without field-symbols for your ease.

Thanks & Regards,

Anand Patil

Read only

0 Likes
791

Hi,

Thank you for reply.

- Thank you very very much Ankur Parab for your reply, it works well.

- Thank you Anand Patil for your reply but it dosn't work, "ls_struct-(wa_fm-id_field)" is

unknown

Mll Mat