<?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: Assign...Casting for integers problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279065#M1387962</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ged,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should have a look to hexadecimal values in debug :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SMALLFIELD2 -&amp;gt; 0031002000200020
&amp;lt;FA&amp;gt;        -&amp;gt; 00310020&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and '0031' is ASCII code for '1' and '0020' for space (' '). Assignement just cut hexadecimal values in place and as integer (see help on built-in types : integer -&amp;gt; 4 bytes) is as long as 2 chars, you obtain the above value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To obtain the result, it only remains to convert hexadecimal value in decimal value to obtain 3211296...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Samuel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Oct 2009 13:27:52 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-10-26T13:27:52Z</dc:date>
    <item>
      <title>Assign...Casting for integers problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279062#M1387959</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;Can anyone explain why the following program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT  ZTEST_CASTING.&lt;/P&gt;&lt;P&gt;types mytype2 type i.&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;      smallfield type c LENGTH 5,&lt;/P&gt;&lt;P&gt;      smallfield2 type c LENGTH 4 VALUE '1'.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fa&amp;gt; type ANY.&lt;/P&gt;&lt;P&gt;ASSIGN smallfield2 to &amp;lt;fa&amp;gt; CASTING type mytype2.&lt;/P&gt;&lt;P&gt;write: / smallfield2, &amp;lt;fa&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gives the result:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1     3,211,296 ???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why can't I cast my field symbol to an integer?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2009 11:03:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279062#M1387959</guid>
      <dc:creator>ged_hurst</dc:creator>
      <dc:date>2009-10-26T11:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: Assign...Casting for integers problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279063#M1387960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use it like this now it may help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;types mytype2 type i.&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;smallfield type c LENGTH 5,&lt;/P&gt;&lt;P&gt;smallfield2 type c LENGTH 4 VALUE '1'.&lt;/P&gt;&lt;P&gt;FIELD-SYMBOLS: &amp;lt;fa&amp;gt; type c.&lt;/P&gt;&lt;P&gt;ASSIGN smallfield2 to &amp;lt;fa&amp;gt; casting .&lt;/P&gt;&lt;P&gt;write: / smallfield2, &amp;lt;fa&amp;gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2009 11:21:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279063#M1387960</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-26T11:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Assign...Casting for integers problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279064#M1387961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Imran. However, I would like the result cast into an integer target field. Why can I not cast an numeric character into an integer field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2009 12:42:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279064#M1387961</guid>
      <dc:creator>ged_hurst</dc:creator>
      <dc:date>2009-10-26T12:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Assign...Casting for integers problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279065#M1387962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ged,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should have a look to hexadecimal values in debug :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SMALLFIELD2 -&amp;gt; 0031002000200020
&amp;lt;FA&amp;gt;        -&amp;gt; 00310020&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and '0031' is ASCII code for '1' and '0020' for space (' '). Assignement just cut hexadecimal values in place and as integer (see help on built-in types : integer -&amp;gt; 4 bytes) is as long as 2 chars, you obtain the above value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To obtain the result, it only remains to convert hexadecimal value in decimal value to obtain 3211296...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Samuel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2009 13:27:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279065#M1387962</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-26T13:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Assign...Casting for integers problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279066#M1387963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Samuel, that's a helpful answer, but I guess the problem that I have is why doesn't SAP do this conversion for me? After all, I can MOVE '1' TO integer_field and get 1 in integer_field. &lt;/P&gt;&lt;P&gt;I have found this statement in SAP help, but I don't understand the restrictions:&lt;/P&gt;&lt;P&gt;'Provided the field symbol is either fully typed or has one of the generic built-in ABAP types u2013 c, n, p, or x u2013 you can use the following ASSIGN statement...'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2009 14:07:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279066#M1387963</guid>
      <dc:creator>ged_hurst</dc:creator>
      <dc:date>2009-10-26T14:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Assign...Casting for integers problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279067#M1387964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes I understand what you mean... But ASSIGN is not the right tool to make conversions : you have MOVE or WRITE in order to do conversions...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And as indicated in SAP help, ASSIGN work on &lt;STRONG&gt;memory area&lt;/STRONG&gt; and not on objects... There is no more types except the one that you give to this command in CASTING TYPE...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Samuel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2009 16:52:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279067#M1387964</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-26T16:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Assign...Casting for integers problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279068#M1387965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ged,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAP online help says:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"If you use addition CASTING in casting_spec, the memory area is treated as if it had the type specified by CASTING."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For Move, it says "..convert the content of source into the data type of destination according to one of the conversion rules. "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This means if you want an integer result, you have to MOVE, i.e. in your case create a dynamic data object:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT ZTEST_CASTING.
  TYPES:
    mytype2 type i.
  DATA:
    smallfield  type c LENGTH 5,
    smallfield2 type c LENGTH 4 VALUE '1',
    lr_data     type ref to data
  FIELD-SYMBOLS: 
    &amp;lt;fa&amp;gt;        type ANY.
CREATE DATA lr_data TYPE mytype2.
ASSIGN lr_data-&amp;gt;* TO &amp;lt;any&amp;gt;.
&amp;lt;any&amp;gt; = smallfield2
*ASSIGN smallfield2 to &amp;lt;fa&amp;gt; CASTING type mytype2.
write: / smallfield2, &amp;lt;fa&amp;gt;.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Oct 2009 18:14:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279068#M1387965</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2009-10-26T18:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Assign...Casting for integers problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279069#M1387966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Clemens and Samuel, thanks for your help - between you, you have answered my question and solved my problem.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2009 08:33:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/assign-casting-for-integers-problem/m-p/6279069#M1387966</guid>
      <dc:creator>ged_hurst</dc:creator>
      <dc:date>2009-11-05T08:33:05Z</dc:date>
    </item>
  </channel>
</rss>

