<?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: loop at  field-symbol  (any table) into string ? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489746#M1420187</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you are right , hopefully this problem with the forum will be fixed soon &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Misbah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Jan 2010 16:20:05 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2010-01-08T16:20:05Z</dc:date>
    <item>
      <title>loop at  field-symbol  (any table) into string ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489739#M1420180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need little help, I have a requirement to extract table content with columns names as the header.&lt;/P&gt;&lt;P&gt;After doing some search I figured out the best way to this since table name will be only avaialbe at runtime through&lt;/P&gt;&lt;P&gt;a selection field . my problem is to loop through field-symbol and convert a structure to string value so that I can &lt;/P&gt;&lt;P&gt;write to the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  zlab_tbl_export.

DATA table_name(30) VALUE 'ZSMARTTS_HTML'.
DATA v_file(100) VALUE 'c:\sap_export.txt'.
DATA line(1000).

DATA: o_data TYPE REF TO data.
CREATE DATA o_data TYPE TABLE OF (table_name).
FIELD-SYMBOLS: &amp;lt;table&amp;gt; TYPE ANY TABLE.
ASSIGN o_data-&amp;gt;* TO &amp;lt;table&amp;gt;.
SELECT * UP TO 100 ROWS FROM (table_name) INTO TABLE &amp;lt;table&amp;gt;.

OPEN DATASET v_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; LOOP at &amp;lt;table&amp;gt; into line.   &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;  " Here the code breaks and fail
  
  TRANSFER line to v_file.  
  WRITE :/ line.           

ENDLOOP.

CLOSE DATASET v_file.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exception Message &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
----------------------------------------------------------------------------------------------------
|Error analysis                                                                                |
|    You attempted to move one data object to another.                                             |
|    This is not possible here because the conversion of a data object                             |
|    of type "v" to type "C" is not supported.                                                     |
|                                                                                |
|      List of internal ABAP types:                                                                |
|                                                                                |
|      C    Text (Character)                                                                       |
|      N    Numerical text                                                                         |
|      D    Date (YYYYMMDD)                                                                        |
|      T    Time (HHMMSS)                                                                          |
|      X    Hexadecimal                                                                            |
|      I    Integer                                                                                |
|      P    Packed number                                                                          |
|      F    Floating point number                                                                  |
|                                                                                |
|      h    Internal table                                                                         |
|      r    Object reference                                                                       |
|      l    Data reference                                                                         |
|      g    String of type C                                                                       |
|      y    String of type X                                                                       |
|      s    2-byte integer with plus/minus sign                                                    |
|      b    1-byte integer without plus/minus sign                                                 |
|      u    Structure (flat structure)                                                             |
|      v    Structure (deep structure)                                                             |
----------------------------------------------------------------------------------------------------
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 22:42:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489739#M1420180</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T22:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: loop at  field-symbol  (any table) into string ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489740#M1420181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone, I need little help, I have a requirement to extract table content with columns names as the header. After doing some search I figured out the best way to this since table name will be only avaialbe at runtime through a selection field . my problem is to loop through field-symbol and convert a structure to string value so that I can write to the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thie is the code &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  zlab_tbl_export.

DATA table_name(30) VALUE 'ZSMARTTS_HTML'.
DATA v_file(100) VALUE 'c:\sap_export.txt'.
DATA line(1000).

DATA: o_data TYPE REF TO data.
CREATE DATA o_data TYPE TABLE OF (table_name).
FIELD-SYMBOLS: &amp;lt;table&amp;gt; TYPE ANY TABLE.
ASSIGN o_data-&amp;gt;* TO &amp;lt;table&amp;gt;.
SELECT * UP TO 100 ROWS FROM (table_name) INTO TABLE &amp;lt;table&amp;gt;.

OPEN DATASET v_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP at &amp;lt;table&amp;gt; into line.   " Fail here

  TRANSFER line to v_file.  
  WRITE :/ line.            

ENDLOOP.

CLOSE DATASET v_file.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and this is the exception:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Error analysis                                                                                
You attempted to move one data object to another.                                             
    This is not possible here because the conversion of a data object                             
    of type v to type C is not supported.                                                     
      
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Misbah on Jan 7, 2010 11:50 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 22:46:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489740#M1420181</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T22:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: loop at  field-symbol  (any table) into string ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489741#M1420182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Misbah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A DATASET oprnFOR OUTPUT IN TEXT MODE can be filled with character-like data only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yo can never use a string as a work area of an internal table except for a table of strings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
field-symbols:
  &amp;lt;rec&amp;gt; type any,
  &amp;lt;fld&amp;gt; type any.
  &amp;lt;out&amp;gt; type any.
data:
  lv_rec type string,
  lr_data type ref to data,
  lv_len type sy-linsz.

LOOP at &amp;lt;table&amp;gt;  assigning &amp;lt;rec&amp;gt;.
  do.
    assign component sy-index of structure &amp;lt;rec&amp;gt; to &amp;lt;fld&amp;gt;.
    if sy-subrc &amp;lt;&amp;gt; 0.
      exit."do
    endif.
    describe field &amp;lt;fld&amp;gt; output-length lv_len.
    create data lr_data type c length lv_len.
    assign lr_data-&amp;gt;* to &amp;lt;out&amp;gt;.
    write &amp;lt;fld&amp;gt; to &amp;lt;out&amp;gt;.
    concatenate  lv_rec &amp;lt;out&amp;gt; into lv_rec.
  enddo.
 
  TRANSFER lv_rec to v_file.  
  WRITE :/  lv_rec.            
 ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&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>Thu, 07 Jan 2010 23:33:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489741#M1420182</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2010-01-07T23:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: loop at  field-symbol  (any table) into string ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489742#M1420183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Clemens,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I modified my code based on the code you posted, but unfortunately the program just write empty lines (number of lines = number of records) .. can you please help me further to fix this ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Misbah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 23:43:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489742#M1420183</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T23:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: loop at  field-symbol  (any table) into string ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489743#M1420184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Misbah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check in debugger what the contents of the selected table data is, what is the content of all field-symbols in all step and what is finally transferred.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't help you from here. And I'll go to bed right now.&lt;/P&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>Thu, 07 Jan 2010 23:51:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489743#M1420184</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2010-01-07T23:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: loop at  field-symbol  (any table) into string ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489744#M1420185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is working now ..&lt;/P&gt;&lt;P&gt;I just changed this line &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;if sy-subrc  0.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;if sy-subrc NE  0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for you help Clemens.&lt;/P&gt;&lt;P&gt;for some reason when you apply the code tag , the &amp;lt;&amp;gt; disappear !&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Misbah&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Misbah on Jan 8, 2010 12:53 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Misbah on Jan 8, 2010 12:54 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jan 2010 23:53:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489744#M1420185</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-07T23:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: loop at  field-symbol  (any table) into string ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489745#M1420186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Misbah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;oh, yes, sorry. I always encourage people to use the preview tab and control the posting and I did not, at least not accurately. The characters &amp;lt; and &amp;gt; together are interpreted as a html tag and thus ignored. This is maybe one of the advantages of ABAP that you can write NE for this &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I know that you can use html tags like &amp;amp; lt  ; (without spaces between) to display NE in &lt;/P&gt;&lt;P&gt;my  preferred way as &amp;amp;lt;&amp;amp;gt; here in the forum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully someone adds this to the FAQs.&lt;/P&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>Fri, 08 Jan 2010 10:56:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489745#M1420186</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2010-01-08T10:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: loop at  field-symbol  (any table) into string ?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489746#M1420187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you are right , hopefully this problem with the forum will be fixed soon &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Misbah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2010 16:20:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-at-field-symbol-any-table-into-string/m-p/6489746#M1420187</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-01-08T16:20:05Z</dc:date>
    </item>
  </channel>
</rss>

