Skip to Content
Jun 30, 2014 at 06:01 PM

Find variable name in runtime



I'll explain this question in 2 parts 😊, the general idea and it's intents

I've been trying to do some dynamic coding and I still didn't manage a way to find out a variable name at runtime.

I wanted to pass the variable into a method/subroutine and find out what is the variable name along with some other properties:

o_dynsel->add_select_option( s_matnr[] ).

Here's the idea:

While using the dynamic selection FM's (FREE_SELECTION_INIT), I wanted to map the select-options I have on screen to their corresponding fields inside the function. This can be achieved If:

  1. I know the name of the select option variable and its table-field. -> So I can map it and ensure unicity.
  2. I know it's contents -> to map from/to the dynamic selection screen/

Plus, I wanted to do this as generic as possible.

I could do this using a text with the variable name:

o_dynsel->add_select_option( i_selop = 'S_MATNR'

i_ref_field = 'MARA-MATNR' ).

But I simply don't like it that way(plus, I can always get spelling errors! )