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

check if the FM is dynamically called using a variable

Former Member
0 Likes
685

hi ,

i have a requirement where i have to check if the FM is dynamically called using a variable and that variable is declared locally in the report.

i am using below code where lv_stat will have each line of the report.

IF lv_stat CS 'CALL FUNCTION'.

SPLIT lv_stat AT 'CALL FUNCTION' INTO lv_first_str lv_sec_str.

shift lv_sec_str left DELETING LEADING space.

next

- i have to check if lv_sec_str is a variable

- if it is a variable then check whether its declared locally.

I am not getting logic to write this.can anyone help.

thanks

1 ACCEPTED SOLUTION
Read only

MateuszAdamus
Active Contributor
624

Hello vijayashri

The name of the function used in a static function call is enclosed in single quotes.

CALL FUNCTION 'SOME_FUNCTION'.

So, if you LV_SEC_STR variable does not start with a single quote, then I would assume that it contains a name of a variable.

The second part, check if the variable is declared locally or globally, is more complicated. You have to find the place where the variable is declared and check if it is a global or local declaration. I would first look for all occurrences of the variable in the source code. Then look for the context of the findings:

  • is it a usage or declaration of the variable
  • if it is a declaration, then is it a local or global

Kind regards,

Mateusz
1 REPLY 1
Read only

MateuszAdamus
Active Contributor
625

Hello vijayashri

The name of the function used in a static function call is enclosed in single quotes.

CALL FUNCTION 'SOME_FUNCTION'.

So, if you LV_SEC_STR variable does not start with a single quote, then I would assume that it contains a name of a variable.

The second part, check if the variable is declared locally or globally, is more complicated. You have to find the place where the variable is declared and check if it is a global or local declaration. I would first look for all occurrences of the variable in the source code. Then look for the context of the findings:

  • is it a usage or declaration of the variable
  • if it is a declaration, then is it a local or global

Kind regards,

Mateusz