<?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 Re: Access class attribute by class name in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510292#M1066727</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want dynamic access to a static attribute?  If these are your own Z classes, then rather than access the attributes directly, write getter and setter methods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can use (as it is in the ABAP help on dynamic call methods ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY. 
    CALL METHOD (class)=&amp;gt;(meth) 
      PARAMETER-TABLE 
        ptab 
      EXCEPTION-TABLE 
        etab. 
    CASE sy-subrc. 
      WHEN 1. 
        ... 
      ... 
    ENDCASE. 
  CATCH cx_sy_dyn_call_error INTO exc_ref. 
    exc_text = exc_ref-&amp;gt;get_text( ). 
    MESSAGE exc_text TYPE 'I'. 
ENDTRY. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;btw - next time, post in the ABAP objects forum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Oct 2008 08:17:42 GMT</pubDate>
    <dc:creator>matt</dc:creator>
    <dc:date>2008-10-01T08:17:42Z</dc:date>
    <item>
      <title>Access class attribute by class name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510291#M1066726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me in next situation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need access class static attribute by class name and attribute name. I have two initialized variables &lt;/P&gt;&lt;P&gt;DATA: class_name(30) TYPE c,&lt;/P&gt;&lt;P&gt;attr_name(30) TYPE c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In another words, I need to do attribute initializing like &lt;/P&gt;&lt;P&gt;ZCL_IM_BM_VPA10_IMPL=&amp;gt;P_VAR_ZPLV_CLM = loc_var_range-low.&lt;/P&gt;&lt;P&gt;but using char variables insead of reference to class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2008 08:14:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510291#M1066726</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-01T08:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: Access class attribute by class name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510292#M1066727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want dynamic access to a static attribute?  If these are your own Z classes, then rather than access the attributes directly, write getter and setter methods.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can use (as it is in the ABAP help on dynamic call methods ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TRY. 
    CALL METHOD (class)=&amp;gt;(meth) 
      PARAMETER-TABLE 
        ptab 
      EXCEPTION-TABLE 
        etab. 
    CASE sy-subrc. 
      WHEN 1. 
        ... 
      ... 
    ENDCASE. 
  CATCH cx_sy_dyn_call_error INTO exc_ref. 
    exc_text = exc_ref-&amp;gt;get_text( ). 
    MESSAGE exc_text TYPE 'I'. 
ENDTRY. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;btw - next time, post in the ABAP objects forum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2008 08:17:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510292#M1066727</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2008-10-01T08:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Access class attribute by class name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510293#M1066728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can use the field-symbols:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CLASS LCL_MY_CLASS DEFINITION.
  PUBLIC SECTION.
    CLASS-DATA: VAR1 TYPE C,
                VAR2 TYPE C.
ENDCLASS.

CLASS LCL_MY_CLASS IMPLEMENTATION.
ENDCLASS.


DATA: CLASS_NAME(30) TYPE C,
      CLASS_VAR(30)  TYPE C,
      CLASS_REF(100) TYPE C.

FIELD-SYMBOLS: &amp;lt;VAR&amp;gt; TYPE ANY.

CLASS_NAME = 'LCL_MY_CLASS'.
CLASS_VAR  = 'VAR1'.

CONCATENATE CLASS_NAME '=&amp;gt;' CLASS_VAR INTO CLASS_REF.
ASSIGN (CLASS_REF) TO &amp;lt;VAR&amp;gt;.
IF SY-SUBRC = 0.
  &amp;lt;VAR&amp;gt; = 'A'.
ENDIF.

WRITE: LCL_MY_CLASS=&amp;gt;VAR1.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2008 08:23:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510293#M1066728</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-01T08:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Access class attribute by class name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510294#M1066729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your answer. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But is it possible access class attributes or methods in this way if i know only name of class. This name was generated automaticaly and contained in character variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is the same as use next code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL METHOD 'AN_CLASS'=&amp;gt;''AN_METHOD'.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2008 08:25:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510294#M1066729</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-01T08:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Access class attribute by class name</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510295#M1066730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Max. Your solution is helped to me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2008 09:24:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-class-attribute-by-class-name/m-p/4510295#M1066730</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-01T09:24:05Z</dc:date>
    </item>
  </channel>
</rss>

