cancel
Showing results for 
Search instead for 
Did you mean: 

Need ABAP help to access field value of the table, where as required field name is stored in another column

Former Member
0 Kudos

My scenario looks like this

My source table is as follows:

Key Field

Data Field

Key Figure1

Key Figure2

Key Figure3

Key Figure4

1

Key Figure2

1

5

3

2

2

Key Figure1

8

3

17

6

3

Key Figure4

65

76

67

43

4

Key Figure2

56

97

887

21

I need records in Target table as follows:

Key Field

Key Figure

1

5

2

8

3

43

4

97

i.e. to get the key figure value for target record we need to identify which key figure need to be accessed from source table. The second field(i.e. Data field) in the source table provides this information. This "Data Field" stores the Key Figure field names/lables in it.

For example, for the first record i.e. with key field value '1', the key figure need to be accessed is Key Figure2, for the first record Key Figure2 value is 5, so it has to be stored as Key Figure value in this record

I have the solution to achieve this using CASE statement, in the example I have shown 4 key figures but it is not static , the number of key figures are not known in advance.. it may increase …so case statement will not do in this case..

Please provide me the dynamic ABAP code to achieve this.

Regards,

Hari Prasad Balija

Accepted Solutions (0)

Answers (1)

Answers (1)

anshu_lilhori
Active Contributor
0 Kudos

Plz do not post same threads on multiple forums.