<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Method call in assign statement throws ERROR in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956726#M1966932</link>
    <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
  &lt;P&gt;I have encountered a weird error while trying to "ASSIGN" the result of a method call (TYPE REF TO DATA) TO a field-symbol.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;class lcl_test definition create public.
        
  public section.
  protected section.
  private section.
  methods get_data_ref
    RETURNING VALUE(r_data) TYPE REF TO data.
  
endclass. 

class lcl_test implementation.

  method get_data_ref.

    DATA lr_test_data TYPE REF TO data.
    CREATE DATA lr_test_data TYPE TABLE OF sflight WITH EMPTY KEY.
    r_data = lr_test_data.

  endmethod.

endclass.

START-OF-SELECTION.

  FIELD-SYMBOLS: &amp;lt;lta_data&amp;gt; TYPE ANY TABLE.
  
  DATA(O_test) = new lcl_test( ).
  
  ASSIGN o_test-&amp;gt;get_data_ref( )-&amp;gt;* TO &amp;lt;lta_data&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I keep getting this error "The class "O_TEST-&amp;gt;GET_DATA_REF( cannot be created as "FOR TESTING" since it is already referenced by non-test source code." which to me makes no sense in that context.&lt;/P&gt;
  &lt;P&gt;Shouldn't that be possible? I also tried it with a non generic returning value (char10).&lt;/P&gt;
  &lt;P&gt;It works in two steps. If you save the result of method "get_data_ref" in variable first and then pass that variable to the assign statement.&lt;/P&gt;
  &lt;P&gt;Kind regards,&lt;/P&gt;
  &lt;P&gt;Kai&lt;/P&gt;</description>
    <pubDate>Wed, 17 Jul 2019 12:23:01 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2019-07-17T12:23:01Z</dc:date>
    <item>
      <title>Method call in assign statement throws ERROR</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956726#M1966932</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
  &lt;P&gt;I have encountered a weird error while trying to "ASSIGN" the result of a method call (TYPE REF TO DATA) TO a field-symbol.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;class lcl_test definition create public.
        
  public section.
  protected section.
  private section.
  methods get_data_ref
    RETURNING VALUE(r_data) TYPE REF TO data.
  
endclass. 

class lcl_test implementation.

  method get_data_ref.

    DATA lr_test_data TYPE REF TO data.
    CREATE DATA lr_test_data TYPE TABLE OF sflight WITH EMPTY KEY.
    r_data = lr_test_data.

  endmethod.

endclass.

START-OF-SELECTION.

  FIELD-SYMBOLS: &amp;lt;lta_data&amp;gt; TYPE ANY TABLE.
  
  DATA(O_test) = new lcl_test( ).
  
  ASSIGN o_test-&amp;gt;get_data_ref( )-&amp;gt;* TO &amp;lt;lta_data&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I keep getting this error "The class "O_TEST-&amp;gt;GET_DATA_REF( cannot be created as "FOR TESTING" since it is already referenced by non-test source code." which to me makes no sense in that context.&lt;/P&gt;
  &lt;P&gt;Shouldn't that be possible? I also tried it with a non generic returning value (char10).&lt;/P&gt;
  &lt;P&gt;It works in two steps. If you save the result of method "get_data_ref" in variable first and then pass that variable to the assign statement.&lt;/P&gt;
  &lt;P&gt;Kind regards,&lt;/P&gt;
  &lt;P&gt;Kai&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 12:23:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956726#M1966932</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-07-17T12:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Method call in assign statement throws ERROR</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956727#M1966933</link>
      <description>&lt;P&gt;Tried it on my system and got the same result. The error message is incorrect - it should say something about not being able to dereference a method call. You should report it on support.sap.com... having first shifted &lt;STRONG&gt;get_data_ref&lt;/STRONG&gt; to the public section of course!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 13:51:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956727#M1966933</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-07-17T13:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Method call in assign statement throws ERROR</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956728#M1966934</link>
      <description>&lt;P&gt;You are accessing the private method. Syntax error might be because of that?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 14:09:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956728#M1966934</guid>
      <dc:creator>benny_baby3</dc:creator>
      <dc:date>2019-07-17T14:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Method call in assign statement throws ERROR</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956729#M1966935</link>
      <description>&lt;P&gt;I get the syntax error message in 7.52 SP 1: "No method can be specified in the current position." (whatever GET_DATA_REF is private or &lt;STRONG&gt;public&lt;/STRONG&gt;).&lt;/P&gt;&lt;P&gt;Anyway, returned values exist only for the duration of the current statement, so it's normal that it's not accepted for ASSIGN (at least in ABAP 7.52). There are a few other cases like that.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 14:35:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956729#M1966935</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-07-17T14:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: Method call in assign statement throws ERROR</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956730#M1966936</link>
      <description>&lt;P&gt;No. Because when you move the method definition to public, you still get the error. &lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 14:43:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956730#M1966936</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2019-07-17T14:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: Method call in assign statement throws ERROR</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956731#M1966937</link>
      <description>&lt;UL&gt;
&lt;LI&gt;This error occurrs on SAP NW 7.50. Also yes it was a mistake on my side that the get_data_ref is private it should be public of course.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 17 Jul 2019 15:56:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956731#M1966937</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-07-17T15:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Method call in assign statement throws ERROR</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956732#M1966938</link>
      <description>&lt;P&gt;I think it because of method chaining have the same syntax ( method( )-&amp;gt;...) so its not allowed to dereference there.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 00:44:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/method-call-in-assign-statement-throws-error/m-p/11956732#M1966938</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-07-18T00:44:28Z</dc:date>
    </item>
  </channel>
</rss>

