<?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 data ref in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-ref/m-p/2479243#M558395</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please read this code &amp;amp; answer the following questions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_data_reference.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF t_struct,
         col1 TYPE i,
         col2 TYPE i,
       END OF t_struct.
DATA: dref1 TYPE REF TO data,
      dref2 TYPE REF TO data.
FIELD-SYMBOLS: &amp;lt;fs1&amp;gt; TYPE t_struct,
               &amp;lt;fs2&amp;gt; TYPE i.
CREATE DATA dref1 TYPE t_struct.
ASSIGN dref1-&amp;gt;* TO &amp;lt;fs1&amp;gt;.
&amp;lt;fs1&amp;gt;-col1 = 1.
&amp;lt;fs1&amp;gt;-col2 = 2.
dref2 = dref1.
ASSIGN dref2-&amp;gt;* TO &amp;lt;fs2&amp;gt; CASTING.
WRITE / &amp;lt;fs2&amp;gt;.
GET REFERENCE OF &amp;lt;fs1&amp;gt;-col2 INTO dref2.
ASSIGN dref2-&amp;gt;* TO &amp;lt;fs2&amp;gt;.
WRITE / &amp;lt;fs2&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The list output is:&lt;/P&gt;&lt;P&gt;      1&lt;/P&gt;&lt;P&gt;      2&lt;/P&gt;&lt;P&gt;This example declares two data reference variables dref1 and dref2. dref1is used to create a structured dynamic data object. This is dereferenced with the field symbol &amp;lt;fs1&amp;gt;, and values are then assigned to it. dref1 is assigned to dref2. dref2then points to the structured data object. When dref2 is dereferenced, it is cast to the elementary type i of field symbol &amp;lt;fs2&amp;gt;. Its first component is assigned to the field symbol. GET REFERENCE is then used to get a reference to the second component not the structured data object in dref2. It is dereferenced without casting.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/16/0dce0a0cf711d3b9360000e8353423/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/16/0dce0a0cf711d3b9360000e8353423/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Q1] In the GET REFERENCE statement are we assigning twice, as &amp;#147;dref2&amp;#148; has already been assigned in the statement&lt;/P&gt;&lt;P&gt;&amp;#147; DREF2 = DREF1 .&amp;#148;&lt;/P&gt;&lt;P&gt;Q2]  What is CASTING?&lt;/P&gt;&lt;P&gt;Q3 ] WHAT IS DEREFERENCING?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Jun 2007 06:10:33 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-06-29T06:10:33Z</dc:date>
    <item>
      <title>data ref</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-ref/m-p/2479243#M558395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please read this code &amp;amp; answer the following questions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT demo_data_reference.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF t_struct,
         col1 TYPE i,
         col2 TYPE i,
       END OF t_struct.
DATA: dref1 TYPE REF TO data,
      dref2 TYPE REF TO data.
FIELD-SYMBOLS: &amp;lt;fs1&amp;gt; TYPE t_struct,
               &amp;lt;fs2&amp;gt; TYPE i.
CREATE DATA dref1 TYPE t_struct.
ASSIGN dref1-&amp;gt;* TO &amp;lt;fs1&amp;gt;.
&amp;lt;fs1&amp;gt;-col1 = 1.
&amp;lt;fs1&amp;gt;-col2 = 2.
dref2 = dref1.
ASSIGN dref2-&amp;gt;* TO &amp;lt;fs2&amp;gt; CASTING.
WRITE / &amp;lt;fs2&amp;gt;.
GET REFERENCE OF &amp;lt;fs1&amp;gt;-col2 INTO dref2.
ASSIGN dref2-&amp;gt;* TO &amp;lt;fs2&amp;gt;.
WRITE / &amp;lt;fs2&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The list output is:&lt;/P&gt;&lt;P&gt;      1&lt;/P&gt;&lt;P&gt;      2&lt;/P&gt;&lt;P&gt;This example declares two data reference variables dref1 and dref2. dref1is used to create a structured dynamic data object. This is dereferenced with the field symbol &amp;lt;fs1&amp;gt;, and values are then assigned to it. dref1 is assigned to dref2. dref2then points to the structured data object. When dref2 is dereferenced, it is cast to the elementary type i of field symbol &amp;lt;fs2&amp;gt;. Its first component is assigned to the field symbol. GET REFERENCE is then used to get a reference to the second component not the structured data object in dref2. It is dereferenced without casting.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/16/0dce0a0cf711d3b9360000e8353423/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/16/0dce0a0cf711d3b9360000e8353423/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Q1] In the GET REFERENCE statement are we assigning twice, as &amp;#147;dref2&amp;#148; has already been assigned in the statement&lt;/P&gt;&lt;P&gt;&amp;#147; DREF2 = DREF1 .&amp;#148;&lt;/P&gt;&lt;P&gt;Q2]  What is CASTING?&lt;/P&gt;&lt;P&gt;Q3 ] WHAT IS DEREFERENCING?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jun 2007 06:10:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-ref/m-p/2479243#M558395</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-06-29T06:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: data ref</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/data-ref/m-p/2479244#M558396</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;Q1] In the GET REFERENCE statement are we assigning twice, as &amp;#147;dref2&amp;#148; has already been assigned in the statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you are asigning the memory address of &amp;lt;fs1&amp;gt;-&amp;gt;col2. You are just replacing the memory address it was previously reffering to with a new memory addrress.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q2] What is CASTING?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the addition CASTING you are  saying that assign the TYPE of the data that is there in the dref2-&amp;gt;* to the FIELD-SYMBOL &amp;lt;fs2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Q3 ] WHAT IS DEREFERENCING? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dereferencing is getting the value from the Memory address to which we have reference it is done using -&amp;gt;* operator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jun 2007 06:20:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/data-ref/m-p/2479244#M558396</guid>
      <dc:creator>seshatalpasai_madala</dc:creator>
      <dc:date>2007-06-29T06:20:22Z</dc:date>
    </item>
  </channel>
</rss>

