<?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 Dynamic Method Call in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-method-call/m-p/1622410#M278386</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a procedure that frees GUI controls.  I have a lot of controls, and rather than have many procedures, I'd like to have 1 procedure that I call, passing an object reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It doesn't appear that through dynamic method call, I can do this with an instance method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone suggest a way to do this, without having a procedure for each control?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&amp;lt;b&amp;gt;* I want to pass g_r_editor as a parameter&amp;lt;/b&amp;gt;
IF NOT g_r_editor IS INITIAL.
    CALL METHOD g_r_editor-&amp;gt;free
      EXCEPTIONS
        cntl_error        = 1
        cntl_system_error = 2
        OTHERS            = 3.
    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = text-011
          txt2  = space
          txt1  = text-005.
    ENDIF.
    FREE g_r_editor.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Dynamic Method Call doc&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm"&amp;gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Oct 2006 12:10:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-10-03T12:10:44Z</dc:date>
    <item>
      <title>Dynamic Method Call</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-method-call/m-p/1622410#M278386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a procedure that frees GUI controls.  I have a lot of controls, and rather than have many procedures, I'd like to have 1 procedure that I call, passing an object reference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It doesn't appear that through dynamic method call, I can do this with an instance method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone suggest a way to do this, without having a procedure for each control?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&amp;lt;b&amp;gt;* I want to pass g_r_editor as a parameter&amp;lt;/b&amp;gt;
IF NOT g_r_editor IS INITIAL.
    CALL METHOD g_r_editor-&amp;gt;free
      EXCEPTIONS
        cntl_error        = 1
        cntl_system_error = 2
        OTHERS            = 3.
    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = text-011
          txt2  = space
          txt1  = text-005.
    ENDIF.
    FREE g_r_editor.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Dynamic Method Call doc&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm"&amp;gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Oct 2006 12:10:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-method-call/m-p/1622410#M278386</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-03T12:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Method Call</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-method-call/m-p/1622411#M278387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Bjorn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would suggest the following approach:&lt;/P&gt;&lt;P&gt;(1) Collect all your GUI control instances in an itab whose line type is TYPE REF TO cl_gui_control.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(2) Define your "free" method:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT mt_gui_controls INTO lo_gui_control.
* See if gui control was text editor
  TRY.
    lo_textedit ?= lo_gui_control.
  CATCH cx_sy_move_cast_error INTO lo_error.
  ENDTRY.

  IF ( lo_error IS NOT BOUND ).
    lo_textedit-&amp;gt;free.
*   ... your coding
    CONTINUE.
  ENDIF.


* See if gui control was tree
  TRY.
    lo_tree ?= lo_gui_control.
  CATCH cx_sy_move_cast_error INTO lo_error.
  ENDTRY.
* ...
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The FREE methods are redefined in the subclasses. However, you could try to call lo_gui_control-&amp;gt;free directly because I am not sure if the coding of the superclass or subclass is called (I cannot test this at the moment).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Oct 2006 13:20:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-method-call/m-p/1622411#M278387</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2006-10-03T13:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Method Call</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-method-call/m-p/1622412#M278388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks.  I ended up doing something similar.  Since all the objects are subclasses, I don't think I need to worry about casting errors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
...
  l_r_control = g_r_editor.
  PERFORM free_controls
    USING
      l_r_control.
...

FORM free_controls
  USING
     p_r_control TYPE REF TO cl_gui_control.

  IF NOT p_r_control IS INITIAL.
    CALL METHOD p_r_control-&amp;gt;free
      EXCEPTIONS
        cntl_error        = 1
        cntl_system_error = 2
        OTHERS            = 3.
    IF sy-subrc NE 0.
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = text-011
          txt2  = space
          txt1  = text-002.
    ENDIF.
  ENDIF.
ENDFORM.                    "free_controls
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Oct 2006 13:23:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/dynamic-method-call/m-p/1622412#M278388</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-03T13:23:23Z</dc:date>
    </item>
  </channel>
</rss>

