<?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 Access to class-attribute by Interface-reference in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990907#M706405</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi OO-Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use an implementation of BADI ME_PROCESS_REQ_CUST to fill and handle user-defined fields in the MM-Purchase-Requisition, method IF_EX_ME_PROCESS_REQ_CUST~OPEN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There I  use a reference variable which refers to an interface (type ref to IF_PURCHASE_REQUISITION_ITEM) to access the item-object. My problem is that I need to have access to the class-attribute my_state. The corresponding class lcl_req_item is defined locally (LMEREQF01). So I can&amp;#146;t use  a reference variable with reference to this class (so widening cast using the interface-reference is not possible) .. Does anyone know a trick how to access the class-attribute anyway?&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------" /&gt;&lt;P&gt;Coding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  data:  l_item_list       TYPE MMPUR_REQUISITION_ITEMS,&lt;/P&gt;&lt;P&gt;           l_item             TYPE MMPUR_REQUISITION_ITEM,&lt;/P&gt;&lt;P&gt;           l_item_akt       TYPE mereq_item, &lt;/P&gt;&lt;P&gt;           l_item_ref        TYPE ref to IF_PURCHASE_REQUISITION_ITEM.  &lt;/P&gt;&lt;P&gt;                                                &lt;/P&gt;&lt;P&gt;  l_item_list = im_header-&amp;gt;get_items().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at l_item_list into l_item.&lt;/P&gt;&lt;P&gt;    l_item_akt = l_item-item-&amp;gt;get_data( ).&lt;/P&gt;&lt;P&gt;    l_item_ref = l_item-item.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------" /&gt;&lt;P&gt;(Debugging the code, I manage by doubleclicking the fieldcontent of l_item_ref (e.g &lt;SPAN __jive_macro_name="O"&gt;&lt;/SPAN&gt;) to show the content of the class-attribute my_state. This works only if the field &amp;#147;Interface&amp;#148; in the Debugger is empty because then I see the attributes of the class. If the field Interface is filled with &amp;#147;IF_PURCHASE_REQUISITION_ITEM&amp;#148;, there aren&amp;#146;t any attributes shown.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your kind help!!&lt;/P&gt;&lt;P&gt;Nicole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Nov 2007 13:47:53 GMT</pubDate>
    <dc:creator>former_member553601</dc:creator>
    <dc:date>2007-11-14T13:47:53Z</dc:date>
    <item>
      <title>Access to class-attribute by Interface-reference</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990907#M706405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi OO-Gurus,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use an implementation of BADI ME_PROCESS_REQ_CUST to fill and handle user-defined fields in the MM-Purchase-Requisition, method IF_EX_ME_PROCESS_REQ_CUST~OPEN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There I  use a reference variable which refers to an interface (type ref to IF_PURCHASE_REQUISITION_ITEM) to access the item-object. My problem is that I need to have access to the class-attribute my_state. The corresponding class lcl_req_item is defined locally (LMEREQF01). So I can&amp;#146;t use  a reference variable with reference to this class (so widening cast using the interface-reference is not possible) .. Does anyone know a trick how to access the class-attribute anyway?&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="----------------" /&gt;&lt;P&gt;Coding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  data:  l_item_list       TYPE MMPUR_REQUISITION_ITEMS,&lt;/P&gt;&lt;P&gt;           l_item             TYPE MMPUR_REQUISITION_ITEM,&lt;/P&gt;&lt;P&gt;           l_item_akt       TYPE mereq_item, &lt;/P&gt;&lt;P&gt;           l_item_ref        TYPE ref to IF_PURCHASE_REQUISITION_ITEM.  &lt;/P&gt;&lt;P&gt;                                                &lt;/P&gt;&lt;P&gt;  l_item_list = im_header-&amp;gt;get_items().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  loop at l_item_list into l_item.&lt;/P&gt;&lt;P&gt;    l_item_akt = l_item-item-&amp;gt;get_data( ).&lt;/P&gt;&lt;P&gt;    l_item_ref = l_item-item.&lt;/P&gt;&lt;P&gt;  endloop.&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;HR originaltext="-----------------------" /&gt;&lt;P&gt;(Debugging the code, I manage by doubleclicking the fieldcontent of l_item_ref (e.g &lt;SPAN __jive_macro_name="O"&gt;&lt;/SPAN&gt;) to show the content of the class-attribute my_state. This works only if the field &amp;#147;Interface&amp;#148; in the Debugger is empty because then I see the attributes of the class. If the field Interface is filled with &amp;#147;IF_PURCHASE_REQUISITION_ITEM&amp;#148;, there aren&amp;#146;t any attributes shown.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your kind help!!&lt;/P&gt;&lt;P&gt;Nicole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Nov 2007 13:47:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990907#M706405</guid>
      <dc:creator>former_member553601</dc:creator>
      <dc:date>2007-11-14T13:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Access to class-attribute by Interface-reference</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990908#M706406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Nicole&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following sample coding shows you how to solve your problem. Please do not ask me how I came across this solution.&lt;/P&gt;&lt;P&gt;However, if you are studying it carefully you may stumble across a most beautiful property of field-symbols as I did.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD if_ex_me_process_req_cust~open.

  DATA: l_item_list TYPE mmpur_requisition_items,
  l_item TYPE mmpur_requisition_item,
  l_item_akt TYPE mereq_item,
  l_item_ref TYPE REF TO if_purchase_requisition_item.



  DATA:
    ld_attr         TYPE string,
    lo_obj          TYPE REF TO object.

  FIELD-SYMBOLS:
    &amp;lt;lo_lcl&amp;gt;        TYPE ANY,
    &amp;lt;ls_item&amp;gt;       TYPE mereq_item,
    &amp;lt;ls_itemx&amp;gt;      TYPE mereq_itemx.


  l_item_list = im_header-&amp;gt;get_items( ).



  LOOP AT l_item_list INTO l_item.
    l_item_akt = l_item-item-&amp;gt;get_data( ).
    l_item_ref = l_item-item.



    lo_obj     ?= l_item-item.  " casting to root object !!!!!

    ld_attr = 'MY_STATE'.
    ASSIGN lo_obj-&amp;gt;(ld_attr) TO &amp;lt;lo_lcl&amp;gt;.

    ld_attr = 'MY_STATE-&amp;gt;ITEM'.
    ASSIGN lo_obj-&amp;gt;(ld_attr) TO &amp;lt;ls_item&amp;gt;.
"    ASSIGN l_item_ref-&amp;gt;(ld_attr) TO &amp;lt;ls_item&amp;gt;.  " does not work...
*
    ld_attr = 'MY_STATE-&amp;gt;ITEMX'.
    ASSIGN lo_obj-&amp;gt;(ld_attr) TO &amp;lt;ls_itemx&amp;gt;.

  ENDLOOP.



  " NOTE: data definition of local class lcl_req_item_state (fg MEREQ)
**    DATA:  item           TYPE mereq_item,
**           itemx          TYPE mereq_itemx,
**           header         TYPE REF TO lcl_req_header,
**           ref_item       TYPE REF TO lcl_req_item,
**           acct_container TYPE REF TO lcl_acct_container,
**           source         TYPE REF TO cl_source_of_supply_mm,
**           release_state  TYPE REF TO cl_release_state_mm,
**           text_manager   TYPE REF TO lcl_text_manager,
**           bom            TYPE REF TO lcl_bom,
**           funds_mgt_active TYPE mmpur_bool VALUE mmpur_no,
**           aktyp          TYPE aktyp,
**           no_auth        TYPE mmpur_bool VALUE mmpur_no,
**           release_op     type mmpur_bool value mmpur_no,
**           persistent     TYPE mmpur_bool VALUE mmpur_no,
**           checked        TYPE mmpur_bool VALUE mmpur_no,
**           manual_configuration TYPE mmpur_bool,
**           input_buffer_changed TYPE mmpur_bool VALUE mmpur_no,
**           changed        TYPE mmpur_bool,
**           broken_rules   TYPE lty_mask,
**           referenced_rules TYPE lty_mask,
**           chp_changes    TYPE mmchp_chp_list,
**           dcm_manager    TYPE REF TO if_revision_manager_dcm,
**           "DCM Retrofit
**           rel_state_after_release TYPE REF TO cl_release_state_mm,
**           "DCM Retrofit
**           chdoc_container TYPE REF TO lcl_chdoc_container,
**           "DCM Retrofit
**           service_changed TYPE mmpur_bool,
**           "DCM Retrofit
**           determinants   TYPE lty_item_determinants.



ENDMETHOD.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&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>Wed, 14 Nov 2007 23:30:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990908#M706406</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-11-14T23:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Access to class-attribute by Interface-reference</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990909#M706407</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;Accessing Attributes and method&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instance methods are called using CALL METHOD &amp;lt;reference&amp;gt;-&amp;gt;&amp;lt;instance_method&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Static methods (also referred to as class methods) are called using CALL METHOD &amp;lt;classname&amp;gt;=&amp;gt;&amp;lt;class_method&amp;gt;.&lt;/P&gt;&lt;P&gt;If you are calling a static method from within the class, you can omit the class name. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You access static attributes using &amp;lt;classname&amp;gt;=&amp;gt;&amp;lt;class_attribute&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You access instance attributes using &amp;lt;instance&amp;gt;-&amp;gt;&amp;lt;instance_attribute&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=&amp;gt; and -&amp;gt; are the component selectors&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2007 05:29:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990909#M706407</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-15T05:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Access to class-attribute by Interface-reference</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990910#M706408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you sooooooo much for this solution. It works perfect, you saved my life &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If I could I would reward 1000 points!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks und ein herzliches grüezi in die Schweiz!&lt;/P&gt;&lt;P&gt;Nicole&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Nov 2007 08:07:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990910#M706408</guid>
      <dc:creator>former_member553601</dc:creator>
      <dc:date>2007-11-16T08:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: Access to class-attribute by Interface-reference</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990911#M706409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Nicole&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am glad that I could have helped you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that this solution reveals a general principle (if not, Klaus Ziegler will revise me...):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;&amp;lt;b&amp;gt;All public class attributes correspond to a public memory area which can be accessed using field-symbols.&amp;lt;/b&amp;gt;&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be interesting to investigate why it did not work using the L_ITEM_REF variable. However, it was too late in the evening to spend more time in the SDN...&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>Fri, 16 Nov 2007 08:19:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990911#M706409</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-11-16T08:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Access to class-attribute by Interface-reference</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990912#M706410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Nicole&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you require some more tricks using field-symbols have a look at the links provided in the snippet&lt;/P&gt;&lt;P&gt;&amp;lt;a href="https://wiki.sdn.sap.com/wiki/display/ABAP/Accessing&lt;EM&gt;the&lt;/EM&gt;Inacessible&lt;EM&gt;-&lt;/EM&gt;Local&lt;EM&gt;Classes&lt;/EM&gt;within&lt;EM&gt;Global&lt;/EM&gt;Classes"&amp;gt;Accessing the Inacessible - Local Classes within Global Classes&amp;lt;/a&amp;gt;&lt;/P&gt;&lt;P&gt;&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>Thu, 13 Dec 2007 21:28:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990912#M706410</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-12-13T21:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Access to class-attribute by Interface-reference</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990913#M706411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe and Nicoli,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having one question about this and so re-opening the thread.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having almost same requirement and your solution is working fine for me in case when I am changing existing PR but I am facing one issure regarding this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I create the PR using ME51N, it calls the same BAdi ME_PROCESS_REQ_CUST , my code is like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_attr  = 'MY_STATE-&amp;gt;RELEASE_STATE-&amp;gt;MY_INDICATOR'.&lt;/P&gt;&lt;P&gt;assign lo_obj-&amp;gt;(lv_attr) to &amp;lt;lo_ref&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now in case of PR creation MY_STATE-&amp;gt;RELEASE_STATE is initial and thus there is no attribute MY_INDICATOR, thus  next line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  assign lo_obj-&amp;gt;(lv_attr) to &amp;lt;lo_ref&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;giving me short dump GETWA_NOT_ASSIGNED as field symbol cannt be assigned .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In addition to this I would like to add one more thing that I am getting short dump&lt;/P&gt;&lt;P&gt;when I am re-assigning &amp;lt;lo_ref&amp;gt; to ay variable like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l_release = &amp;lt;lo_ref&amp;gt; and here I am getting error as &amp;lt;lo_ref&amp;gt; is not pointing to any thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any idea to do this? I have already tried TRY-CATCH but its not working and I cannt check lo_obj-&amp;gt;(lv_attr) to initial as it is syntax error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your thoughts are really appreciated.&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;Cheers&lt;/P&gt;&lt;P&gt;Jai&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Jai S on Mar 7, 2008 6:23 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Jai S on Mar 7, 2008 6:24 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2008 17:10:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990913#M706411</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-07T17:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Access to class-attribute by Interface-reference</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990914#M706412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Issue has been resolved, I could have checked subrc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks any ways&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Jai&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2008 17:48:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/access-to-class-attribute-by-interface-reference/m-p/2990914#M706412</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-07T17:48:37Z</dc:date>
    </item>
  </channel>
</rss>

