Skip to Content
Former Member
Oct 24, 2011 at 03:27 PM

Working with table type any with mapping according to keys


Hi All ,

I have table type any with data and I need to fill structure type any according to respective key and verify that the field is have mapping .

i.e. I have a table <lt_itab> and I need to find the specific entry on it according to the key and the mapping .

I guess that the best way is to give example.

<lt_itab> - Is type any and can have lot of entries

lt_key - Is specified table with field_name and value

lt_map - Table with field_name which have mapping (have unique field name in every entry of the table )from f1..fn -

I need to fill fields in <ls_output> just if they appear in lt_map

<ls_output> - Is structure type any that in the end should have all the data from <ls_itab> according to the mapping and the keys of the table

<lt_itab> - table 

f1  f2  f3  f4  f5 f6 
1   2    3  4   5  6  
5   5    4  3   8  4  
6   9    2  5   3  5
1   3    3  4   2  1

lt_key  - table 

field_name   value
f1            1
f2            3

lt_map  - table


<ls_output> - structure 

field  value 
f1  -   1 
f2  -   2
f3  "Not in mapping so it's empty
f4  "Not in mapping so it's empty
f5  -   2
f6  -   1

<ls_output> have the field values of the last entry of <lt_itab> according to the key of f1 and f2 and according to the mapping f3 and f4 are empty

since they are not appaer in lt_map