<?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: VALUE operator in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454088#M13998</link>
    <description>&lt;P&gt;The behavior is not as documented.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;DATA dref TYPE REF TO string.
dref = NEW #( 'X' ). "No Error

DATA itab TYPE TABLE OF string.
itab = VALUE #( ( 'X' ) ). "Error

DATA tref LIKE REF TO itab.
tref = NEW #( ( 'X' ) ). "Error
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;According to documentation the second and third should behave as the first.&lt;/P&gt;
  &lt;P&gt;Let's see whether the behavior or the documentation will be adjusted.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2017 10:18:41 GMT</pubDate>
    <dc:creator>retired_member</dc:creator>
    <dc:date>2017-07-25T10:18:41Z</dc:date>
    <item>
      <title>VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454082#M13992</link>
      <description>&lt;P&gt;Need some clarity on the VALUE operator.&lt;/P&gt;
  &lt;P&gt;The following lines of code work as expected.&lt;/P&gt;
  &lt;P&gt;data it TYPE STANDARD TABLE OF i with EMPTY KEY.&lt;BR /&gt;it = value #( ( 1 ) ( 2 ) ( 3 ) ).&lt;/P&gt;
  &lt;P&gt;But with the below code, I get an error.&lt;/P&gt;
  &lt;P&gt;data lt type IF_SALV_GUI_TYPES_IDA=&amp;gt;YTS_FIELD_NAME.&lt;BR /&gt;lt = VALUE #( ( 'VBELN' ) ( 'POSNR' ) ).&lt;/P&gt;
  &lt;P&gt;Error message -&amp;gt; "'VBELN'" and the row type of "LT" are incompatible.&lt;/P&gt;
  &lt;P&gt;The type mentioned above has a domain of type CHAR 30.&lt;/P&gt;
  &lt;P&gt;Can some please shed some light.&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;Vikram.M&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 17:45:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454082#M13992</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-07-24T17:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454083#M13993</link>
      <description>&lt;P&gt;Try CONV maybe?&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;lt = VALUE #( ( CONV #( 'VBELN' ) ) ( CONV #( 'POSNR' ) ) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jul 2017 17:53:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454083#M13993</guid>
      <dc:creator>fabianlupa</dc:creator>
      <dc:date>2017-07-24T17:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454084#M13994</link>
      <description>&lt;P&gt;Thanks that seems to do the trick. But I still dont understand why a conversion is required here though.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 18:58:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454084#M13994</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2017-07-24T18:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454085#M13995</link>
      <description>&lt;P&gt;Type inference for the literals probably builds C LENGTH 5 in both cases which is not strictly compatible with CHAR 30.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 19:06:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454085#M13995</guid>
      <dc:creator>fabianlupa</dc:creator>
      <dc:date>2017-07-24T19:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454086#M13996</link>
      <description>&lt;P&gt;if a table consists of multiple named components you need to specify them by name. I suspect this will also trigger implicit conversion, whereas unnamed fields might not. A bug maybe?&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;itab = value #( ( myfield = 'foo' ) ( myfield = 'bar' ) ). &lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Another small comment: the # is an inference operator, telling the compiler to work out the data type. &lt;/P&gt;
  &lt;P&gt;If you ar declaring it right before the assignment, you may as well do both in the same line of code:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;data(itab) = value mytabletype( ( field1 = 'a' field2 = 1 )
                                ( field1 = 'b' field2 = 2 ) ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jul 2017 07:02:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454086#M13996</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-07-25T07:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454087#M13997</link>
      <description>&lt;P&gt;OK, this bothered me so I did some testing. It definitely doesn't do implicit conversion on single-field tables, but if you put it inside a structure it works with a fully-specified field.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;    TYPES t_itab TYPE SORTED TABLE OF fieldname WITH UNIQUE KEY table_line.
    DATA(test1) = VALUE t_itab( ( 'ID' ) ).                              "==&amp;gt; Not OK
    DATA(test2) = VALUE t_itab( ( 'ID                            ' ) ).  "==&amp;gt; OK&lt;BR /&gt;
    TYPES: BEGIN OF t_field,
             fieldname TYPE fieldname,
           END OF t_field.
    TYPES t_fields TYPE SORTED TABLE OF t_field WITH UNIQUE KEY fieldname.&lt;BR /&gt;
    DATA(fields1) = VALUE t_fields( ( 'ID' ) ).                             "==&amp;gt; Not OK
    DATA(fields2) = VALUE t_fields( ( 'ID                            ' ) ). "==&amp;gt; Not OK
    DATA(fields3) = VALUE t_fields( ( fieldname = 'ID' ) ).                 "==&amp;gt; OK&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;So implicit conversion only happens on fully-specified components, even though the compiler is able to figure it out in order to provide the error message &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;
  &lt;P&gt;I would be very interested if &lt;SPAN class="mention-scrubbed"&gt;horst.keller&lt;/SPAN&gt; could share some insight? I kindof expected the second failure but was a bit surprised by the first case.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 08:11:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454087#M13997</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-07-25T08:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454088#M13998</link>
      <description>&lt;P&gt;The behavior is not as documented.&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;DATA dref TYPE REF TO string.
dref = NEW #( 'X' ). "No Error

DATA itab TYPE TABLE OF string.
itab = VALUE #( ( 'X' ) ). "Error

DATA tref LIKE REF TO itab.
tref = NEW #( ( 'X' ) ). "Error
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;According to documentation the second and third should behave as the first.&lt;/P&gt;
  &lt;P&gt;Let's see whether the behavior or the documentation will be adjusted.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 10:18:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454088#M13998</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-25T10:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454089#M13999</link>
      <description>&lt;P&gt;OK, after discussing with a colleague, we tried string templates, and they work fine. Methinks something in ABAP is not consistent from a user point of view. The latest code / result set:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;    TYPES t_itab TYPE SORTED TABLE OF fieldname WITH UNIQUE KEY table_line.
    DATA itab TYPE t_itab.&lt;BR /&gt;
    itab = VALUE #( ( 'ID' ) ).                              "==&amp;gt; Not OK
    itab = VALUE #( ( `ID` ) ).                              "==&amp;gt; Not OK
    itab = VALUE #( ( |ID| ) ).                              "==&amp;gt; OK
    itab = VALUE #( ( 'ID                            ' ) ).  "==&amp;gt; OK

    TYPES: BEGIN OF t_field,
             fieldname TYPE fieldname,
           END OF t_field.
    TYPES t_fields TYPE SORTED TABLE OF t_field WITH UNIQUE KEY fieldname.
    DATA fields TYPE t_fields.

    fields = VALUE #( ( 'ID' ) ).                             "==&amp;gt; Not OK
    fields = VALUE #( ( 'ID                            ' ) ). "==&amp;gt; Not OK
    fields = VALUE #( ( |ID| ) ).                             "==&amp;gt; OK
    fields = VALUE #( ( fieldname = 'ID' ) ).                 "==&amp;gt; OK&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jul 2017 10:19:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454089#M13999</guid>
      <dc:creator>pokrakam</dc:creator>
      <dc:date>2017-07-25T10:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454090#M14000</link>
      <description>&lt;P&gt;As in my comment above.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;TYPES text TYPE c LENGTH 1.
DATA dref TYPE REF TO text.
dref = NEW #(  `X`  ). "No Error
dref = NEW #(  |X|  ). "No Error

DATA itab TYPE TABLE OF text.
itab = VALUE #( ( |X| ) ). "No Error
itab = VALUE #( ( `X` ) ). "Error
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Works different than documented.&lt;/P&gt;
  &lt;P&gt;According to documentation for elementary line types the same should hold as for elementary types with NEW. &lt;/P&gt;
  &lt;P&gt;This example shows that rather the behavior must be corrected and not the documentation.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 10:29:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454090#M14000</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-25T10:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454091#M14001</link>
      <description>&lt;P&gt;Seems that you found an error. Either in behavior or in documentation.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 10:30:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454091#M14001</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-25T10:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454092#M14002</link>
      <description>&lt;P&gt;It is all about &lt;STRONG&gt;inserting lines into internal tables&lt;/STRONG&gt;.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Here we go, &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;CLASS cls DEFINITION.
  PUBLIC SECTION.
    METHODS main.
    METHODS meth RETURNING VALUE(r) TYPE string.
ENDCLASS.
CLASS cls IMPLEMENTATION.
  METHOD main.

    TYPES c1 TYPE c LENGTH 1.
    DATA itab TYPE TABLE OF c1.

    DATA(txt) = `X`.

    DATA jtab TYPE TABLE OF string.
    TYPES:
      BEGIN OF tst,
        col TYPE string,
      END OF tst.
    DATA ktab TYPE TABLE OF tst.

    "itab = VALUE #( ( txt ) ).                                 "Error
    "INSERT txt INTO TABLE itab.                                "Error
    itab = VALUE #( ( CONV string( 'X' ) ) ).                   "No error
    INSERT CONV string( 'X' ) INTO TABLE itab.                  "No Error
    itab = VALUE #( ( substring( val = 'X' off = 1 ) ) ).       "No error
    "INSERT substring( val = 'X' off = 1 ) INTO TABLE itab.     "Error
    itab = VALUE #( ( |X| )  ).                                 "No error
    "INSERT |X| INTO TABLE itab.                                "Error
    itab = VALUE #( ( 'X' &amp;amp;&amp;amp; 'X' )  ).                          "No error
    "INSERT 'X' &amp;amp;&amp;amp; 'X' INTO TABLE itab.                         "Error
    itab = VALUE #( ( COND string(  WHEN 1 = 1 THEN `X`) )  ).  "No error
    INSERT COND string(  WHEN 1 = 1 THEN `X`) INTO TABLE itab.  "No Error
    itab = VALUE #( ( meth( ) )  ).                             "No error
    "INSERT meth( ) INTO TABLE itab.                            "Error
    itab = VALUE #( ( jtab[ 1 ] ) ).                            "No Error
    "INSERT jtab[ 1 ] INTO TABLE itab.                          "Error
    itab = VALUE #( ( ktab[ 1 ]-col ) ).                        "No Error
    "INSERT ktab[ 1 ]-col INTO TABLE itab.                      "Error

  ENDMETHOD.
  METHOD meth.
  ENDMETHOD.
ENDCLASS.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;(same results for structured line types).&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; From that, the current behavior for&lt;STRONG&gt; inserting lines in tables&lt;/STRONG&gt; can be summarized as follows: &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;UL&gt; 
   &lt;LI&gt;The VALUE operator requires compatibility for data objects (fields). Convertibility is sufficient for expressions (built-in funktions, functional methods, calculation expressions, constructor expressions, table expressions).&lt;BR /&gt; &lt;/LI&gt; 
   &lt;LI&gt;The INSERT statement always requires compatibility &lt;STRONG&gt;except&lt;/STRONG&gt; for arbitrary constructor expressions.&lt;/LI&gt; 
  &lt;/UL&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Note that the CONV operator in INSERT in the above example creates type string that is not compatible to the line type c lengh 1.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Let's say, it is ABAPesk.&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;Here we are dealing with the insertion of whole lines into internal tables.The discussion about assigning structure components with ( col = ... ) is orthogonal to this. For these assignments the normal assignment rules are followed. For inserting into internal tables we have to regard the net result of the expression in the brackets.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:05:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454092#M14002</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-27T07:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454093#M14003</link>
      <description>&lt;P&gt;Bug or a feature?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:08:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454093#M14003</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2017-07-27T07:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: VALUE operator</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454094#M14004</link>
      <description>&lt;P&gt;For the time being it is a feature.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2017 07:11:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/value-operator/m-p/454094#M14004</guid>
      <dc:creator>retired_member</dc:creator>
      <dc:date>2017-07-27T07:11:58Z</dc:date>
    </item>
  </channel>
</rss>

