<?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 How does BASE TYPE in ENUM works? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091381#M1971845</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;TYPES ty_x TYPE x LENGTH 4.
TYPES:BEGIN OF ENUM ty_enum BASE TYPE ty_x,
        val0 VALUE IS INITIAL,
        val1 VALUE 1,
        val2 VALUE 2,
        val3 VALUE 32,
      END OF ENUM ty_enum.

DATA z TYPE ty_x.
z = val1.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The type of "VAL1" cannot be converted to the type of "Z"&lt;/P&gt;
  &lt;P&gt;So how base type works?.. I want to make some bit operations with my enum without CONV.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Nov 2019 09:04:17 GMT</pubDate>
    <dc:creator>former_member210008</dc:creator>
    <dc:date>2019-11-22T09:04:17Z</dc:date>
    <item>
      <title>How does BASE TYPE in ENUM works?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091381#M1971845</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;TYPES ty_x TYPE x LENGTH 4.
TYPES:BEGIN OF ENUM ty_enum BASE TYPE ty_x,
        val0 VALUE IS INITIAL,
        val1 VALUE 1,
        val2 VALUE 2,
        val3 VALUE 32,
      END OF ENUM ty_enum.

DATA z TYPE ty_x.
z = val1.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;The type of "VAL1" cannot be converted to the type of "Z"&lt;/P&gt;
  &lt;P&gt;So how base type works?.. I want to make some bit operations with my enum without CONV.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 09:04:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091381#M1971845</guid>
      <dc:creator>former_member210008</dc:creator>
      <dc:date>2019-11-22T09:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: How does BASE TYPE in ENUM works?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091382#M1971846</link>
      <description>&lt;P&gt;Base type determines the internal representation of the enum type, but still, you need conversion between the enum and the underlying type.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES:
  BEGIN OF ENUM size,
    s, m, l, xl, xxl,
  END OF ENUM size.

DATA: size TYPE size,
      int  TYPE i.

size = CONV #( 2 ).
int  = CONV #( xl ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As per my understanding an enum type is optimal for value comparison. When used for that purpose the base type is quite irrelevant:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CLASS demo DEFINITION. 
  PUBLIC SECTION. 
    TYPES: 
      BEGIN OF ENUM size, 
        s, m, l, xl, xxl, 
      END OF ENUM size. 
    CLASS-METHODS main 
      IMPORTING size TYPE size. 
ENDCLASS. 

CLASS demo IMPLEMENTATION. 
  METHOD main. 
    CASE size. 
      WHEN s. 
        ... 
      WHEN m. 
        ... 
      WHEN l. 
        ... 
      WHEN OTHERS. 
        ... 
    ENDCASE. 
  ENDMETHOD. 
ENDCLASS. 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;A "regular" constant should suit you more if you are mainly interested in working with operations of the underlying type:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES ty_x TYPE x LENGTH 4.

CONSTANTS: BEGIN OF val,
        0 VALUE IS INITIAL,
        1 VALUE 1,
        2 VALUE 2,
        3 VALUE 32,
      END OF val.

DATA: z, y TYPE ty_x.

z = val-0.
y = val-0 + val-1.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Nov 2019 09:59:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091382#M1971846</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-22T09:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: How does BASE TYPE in ENUM works?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091383#M1971847</link>
      <description>&lt;P&gt;val1 is of type ty_enum, so you should declare DATA z TYPE ty_enum.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 13:16:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091383#M1971847</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-22T13:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: How does BASE TYPE in ENUM works?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091384#M1971848</link>
      <description>&lt;P&gt;Enumerations are well explained in the blog post &lt;A href="http://blogs.sap.com/2016/10/10/abap-news-release-7.51-enumerations"&gt;ABAP News Release 7.51 – Enumerations&lt;/A&gt;, by Horst Keller, on 2016/10/10.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 13:17:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091384#M1971848</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-22T13:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: How does BASE TYPE in ENUM works?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091385#M1971849</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Yes, it is, although I didn't see any practical example neither in the blog nor in the documentation why base type specification can be useful.&lt;/P&gt;&lt;P&gt;In my opinion if you are interested the values "behind" constants are the way to go. As a matter of fact I'd be more happy with an implicit conversion between integer and enum... But maybe I'm just attracted to C too much &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 14:02:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091385#M1971849</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-11-22T14:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: How does BASE TYPE in ENUM works?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091386#M1971850</link>
      <description>&lt;P&gt;I agree that ABAP enumerations will probably be remembered as a nice try, but won't be adopted by developers because it's too much prone to errors and too complex to handle. I'm really disappointed and I'm now back at the structured constants.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 14:33:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-does-base-type-in-enum-works/m-p/12091386#M1971850</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-11-22T14:33:44Z</dc:date>
    </item>
  </channel>
</rss>

