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

Call Methods using FIELD-SYMBOLS

Former Member
0 Likes
1,897

Good afternoon, i have this problem:

First, i used a field Symbol to call an object that has been initialized in another program. Then, i want to use this field symbol to call a method of this object, but i have the following message:

"<FS> is not a reference variable".

This is the code that have the error in the last line:

DATA ls_object(30) TYPE C.

FIELD-SYMBOLS: <fs> TYPE ANY.

ls_object = '(SAPLTB4E)g_oref_ftr_appl_ctrl'.

ASSIGN (ls_object) TO <fs>.

CALL METHOD <fs>->action_pbo_before.

The assign returns a sy-subrc = 0. In the program SAPLTB4E, the variable 'g_oref_ftr_appl_ctrl' is define like this:

g_oref_ftr_appl_ctrl TYPE REF TO cl_ftr_appl_ctrl.

Thanks in advance for your help.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,126

Hi, that will work as you have coded as long as that program, SAPLTB4E, is in the call stack. But in order for it to work, you must type your FS correctly. Try this.



FIELD-SYMBOLS: <fs> TYPE REF TO cl_ftr_appl_ctrl.


Regards,

Rich Heilman

PS. Be careful with what you are doing here.

Good afternoon, i have this problem:

First, i used a field Symbol to call an object that has been initialized in another program. Then, i want to use this field symbol to call a method of this object, but i have the following message:

"<FS> is not a reference variable".

This is the code that have the error in the last line:

DATA ls_object(30) TYPE C.

FIELD-SYMBOLS: <fs> TYPE ANY.

ls_object = '(SAPLTB4E)g_oref_ftr_appl_ctrl'.

ASSIGN (ls_object) TO <fs>.

CALL METHOD <fs>->action_pbo_before.

The assign returns a sy-subrc = 0. In the program SAPLTB4E, the variable 'g_oref_ftr_appl_ctrl' is define like this:

g_oref_ftr_appl_ctrl TYPE REF TO cl_ftr_appl_ctrl.

Thanks in advance for your help.

4 REPLIES 4
Read only

former_member194669
Active Contributor
0 Likes
1,126

Why don't you try this way?


report zaRs.
data : g_oref_ftr_appl_ctrl TYPE REF TO cl_ftr_appl_ctrl.

perform set_otcdata_to_appl
                  changing
                     g_oref_ftr_appl_ctrl.

form set_otcdata_to_appl changing p_g_oref_ftr_appl_ctrl
                                    type ref to cl_ftr_appl_ctrl.
  call method p_g_oref_ftr_appl_ctrl->action_pbo_before.

endform.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,127

Hi, that will work as you have coded as long as that program, SAPLTB4E, is in the call stack. But in order for it to work, you must type your FS correctly. Try this.



FIELD-SYMBOLS: <fs> TYPE REF TO cl_ftr_appl_ctrl.


Regards,

Rich Heilman

PS. Be careful with what you are doing here.

Read only

0 Likes
1,126

> 
> FIELD-SYMBOLS: <fs> TYPE REF TO cl_ftr_appl_ctrl.
> 
> 

Thanks Rich for new info

Read only

0 Likes
1,126

Thanks for your help !!