<?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: get bit in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-bit/m-p/3068268#M727169</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a set of m elements, you can represent any subset as a sequence of bits. If the nth element of the set is present in a subset, the n th bit is set to 1, otherwise, it is set to 0. The universal set therefore contains no zeros. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ABAP, you can represent a set of m elements using a field with type X and length of at least m/8. To include a member of the universal set in a set, use the SET BIT statement. To check which members of the universal set are included in a particular set, use the GET BIT statement. You can use bit operations for the following set operations: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Set operation  Bit operation&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;Intersection        BIT-AND&lt;/P&gt;&lt;P&gt;Union                 BIT-OR &lt;/P&gt;&lt;P&gt;Symmetrical difference  BIT-XOR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chk out the following code as an example&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: FRANKFURT(4) TYPE X,
      FRISCO(4)    TYPE X,
      INTERSECT(4) TYPE X,
      UNION(4)     TYPE X,
      BIT          TYPE I.

DATA: CARRID TYPE SPFLI-CARRID,
      CARRIER LIKE SORTED TABLE OF CARRID 
                          WITH UNIQUE KEY TABLE LINE.

DATA WA TYPE SPFLI.

SELECT CARRID FROM SCARR INTO TABLE CARRIER.

SELECT CARRID CITYFROM FROM SPFLI 
                       INTO CORRESPONDING FIELDS OF WA.

  WRITE: / WA-CARRID, WA-CITYFROM.

  READ TABLE CARRIER FROM WA-CARRID TRANSPORTING NO FIELDS.

  CASE WA-CITYFROM.
    WHEN 'FRANKFURT'.
      SET BIT SY-TABIX OF FRANKFURT.
    WHEN 'SAN FRANCISCO'.
      SET BIT SY-TABIX OF FRISCO.
  ENDCASE.

ENDSELECT.

INTERSECT = FRANKFURT BIT-AND FRISCO.
UNION     = FRANKFURT BIT-OR  FRISCO.

SKIP.

WRITE 'Airlines flying from Frankfurt and San Francisco:'.
DO 32 TIMES.
  GET BIT SY-INDEX OF INTERSECT INTO BIT.
    IF BIT = 1.
      READ TABLE CARRIER INDEX SY-INDEX INTO CARRID.
      WRITE CARRID.
    ENDIF.
ENDDO.

SKIP.

WRITE 'Airlines flying from Frankfurt or San Francisco:'.
DO 32 TIMES.
  GET BIT SY-INDEX OF UNION INTO BIT.
    IF BIT = 1.
      READ TABLE CARRIER INDEX SY-INDEX INTO CARRID.
      WRITE CARRID.
    ENDIF.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This produces the following output list:&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;AA NEW YORK&lt;/P&gt;&lt;P&gt;AA SAN FRANCISCO&lt;/P&gt;&lt;P&gt;AZ ROME&lt;/P&gt;&lt;P&gt;AZ TOKYO...............&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program uses four hexadecimal fields with length 4 - FRANKFURT, FRISCO, INTERSECT, and UNION. Each of these fields can represent a set of up to 32 elements. The basic set is the set of all airlines from database table SCARR. Each bit of the corresponding bit sequences representes one airline. To provide an index, the external index table CARRIER is created and filled with the airline codes from table SCARR. It is then possible to identify an airline using the internal index of table CARRIER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the SELECT loop for database table SPFLI, the corresponding bit for the airline is set either in the FRANKFURT field or the FRISCO field, depending on the departure city. The line number SY-TABIX is determined using a READ statement in which no fields are transported. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The intersection and union of FRANKFURT and FRISCO are constructed using the bit operations BIT-AND and BIT-OR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The bits in INTERSECT and UNION are read one by one and evaluated in two DO loops. For each position in the fields with the value 1, a READ statement retrieves the airline code from the table CARRIER. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chandra Prakash&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Nov 2007 11:16:03 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-11-27T11:16:03Z</dc:date>
    <item>
      <title>get bit</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-bit/m-p/3068267#M727168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;     how does the getbit statement works? and can anyone explain how does the convesion happen from integer to hexa string for example i have two variables&lt;/P&gt;&lt;P&gt;I is ineteger variable and A is hexa string&lt;/P&gt;&lt;P&gt; and i values is 8191. &lt;/P&gt;&lt;P&gt;A = I.&lt;/P&gt;&lt;P&gt;the value of a is becoming a = 00FF.&lt;/P&gt;&lt;P&gt;can u explain it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2007 11:08:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-bit/m-p/3068267#M727168</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-27T11:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: get bit</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-bit/m-p/3068268#M727169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a set of m elements, you can represent any subset as a sequence of bits. If the nth element of the set is present in a subset, the n th bit is set to 1, otherwise, it is set to 0. The universal set therefore contains no zeros. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In ABAP, you can represent a set of m elements using a field with type X and length of at least m/8. To include a member of the universal set in a set, use the SET BIT statement. To check which members of the universal set are included in a particular set, use the GET BIT statement. You can use bit operations for the following set operations: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Set operation  Bit operation&amp;lt;/b&amp;gt; &lt;/P&gt;&lt;P&gt;Intersection        BIT-AND&lt;/P&gt;&lt;P&gt;Union                 BIT-OR &lt;/P&gt;&lt;P&gt;Symmetrical difference  BIT-XOR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chk out the following code as an example&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: FRANKFURT(4) TYPE X,
      FRISCO(4)    TYPE X,
      INTERSECT(4) TYPE X,
      UNION(4)     TYPE X,
      BIT          TYPE I.

DATA: CARRID TYPE SPFLI-CARRID,
      CARRIER LIKE SORTED TABLE OF CARRID 
                          WITH UNIQUE KEY TABLE LINE.

DATA WA TYPE SPFLI.

SELECT CARRID FROM SCARR INTO TABLE CARRIER.

SELECT CARRID CITYFROM FROM SPFLI 
                       INTO CORRESPONDING FIELDS OF WA.

  WRITE: / WA-CARRID, WA-CITYFROM.

  READ TABLE CARRIER FROM WA-CARRID TRANSPORTING NO FIELDS.

  CASE WA-CITYFROM.
    WHEN 'FRANKFURT'.
      SET BIT SY-TABIX OF FRANKFURT.
    WHEN 'SAN FRANCISCO'.
      SET BIT SY-TABIX OF FRISCO.
  ENDCASE.

ENDSELECT.

INTERSECT = FRANKFURT BIT-AND FRISCO.
UNION     = FRANKFURT BIT-OR  FRISCO.

SKIP.

WRITE 'Airlines flying from Frankfurt and San Francisco:'.
DO 32 TIMES.
  GET BIT SY-INDEX OF INTERSECT INTO BIT.
    IF BIT = 1.
      READ TABLE CARRIER INDEX SY-INDEX INTO CARRID.
      WRITE CARRID.
    ENDIF.
ENDDO.

SKIP.

WRITE 'Airlines flying from Frankfurt or San Francisco:'.
DO 32 TIMES.
  GET BIT SY-INDEX OF UNION INTO BIT.
    IF BIT = 1.
      READ TABLE CARRIER INDEX SY-INDEX INTO CARRID.
      WRITE CARRID.
    ENDIF.
ENDDO.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This produces the following output list:&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;AA NEW YORK&lt;/P&gt;&lt;P&gt;AA SAN FRANCISCO&lt;/P&gt;&lt;P&gt;AZ ROME&lt;/P&gt;&lt;P&gt;AZ TOKYO...............&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program uses four hexadecimal fields with length 4 - FRANKFURT, FRISCO, INTERSECT, and UNION. Each of these fields can represent a set of up to 32 elements. The basic set is the set of all airlines from database table SCARR. Each bit of the corresponding bit sequences representes one airline. To provide an index, the external index table CARRIER is created and filled with the airline codes from table SCARR. It is then possible to identify an airline using the internal index of table CARRIER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the SELECT loop for database table SPFLI, the corresponding bit for the airline is set either in the FRANKFURT field or the FRISCO field, depending on the departure city. The line number SY-TABIX is determined using a READ statement in which no fields are transported. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The intersection and union of FRANKFURT and FRISCO are constructed using the bit operations BIT-AND and BIT-OR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The bits in INTERSECT and UNION are read one by one and evaluated in two DO loops. For each position in the fields with the value 1, a READ statement retrieves the airline code from the table CARRIER. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Chandra Prakash&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2007 11:16:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-bit/m-p/3068268#M727169</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-27T11:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: get bit</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-bit/m-p/3068269#M727170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anusuya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To read an individual bit, use the statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET BIT &amp;lt;n&amp;gt; OF &amp;lt;f&amp;gt; INTO &amp;lt;b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statement reads the bit at position &amp;lt;n&amp;gt; of field &amp;lt;f&amp;gt; into field &amp;lt;b&amp;gt;. The system must be able to interpret field &amp;lt;n&amp;gt; as a positive integer. The field &amp;lt;f&amp;gt; must have data type X. If the bit is read, SY-SUBRC is set to 0. If &amp;lt;n&amp;gt; is greater than the length of &amp;lt;f&amp;gt;, SY-SUBRC is unequal to zero and &amp;lt;b&amp;gt; is set to zero. If &amp;lt;n&amp;gt; contains an invalid value, a runtime error occurs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2007 11:16:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-bit/m-p/3068269#M727170</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-27T11:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: get bit</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/get-bit/m-p/3068270#M727171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anusuya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is very simple. Actually u need to divide this integer i value by 16 and get the remainder : example 8191 mod 16 = 15(which is F, means A - 10, B- 11, C - 12, D- 13, E-14, F -15). 8191/16 = 511.  &lt;/P&gt;&lt;P&gt;Again u need to divide this 511 by 16 : now remainder is 15 so it is F. division is 31.&lt;/P&gt;&lt;P&gt; Again divide this 31 by 16 : Now again remainder is 15 so it is F. Div is 1. &lt;/P&gt;&lt;P&gt; Again divide this 1 by 16 : Now remainder is 1 . Div is 0. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So at last take this by low to high. Now ur answer is 01FFF&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward me if it is useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Kaarthick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Nov 2007 11:24:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/get-bit/m-p/3068270#M727171</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-27T11:24:08Z</dc:date>
    </item>
  </channel>
</rss>

