<?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: Populating internal tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-tables/m-p/4641220#M1092551</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   The approach you have follwed will not give result , When you declared a structure type using types statement it is only a data type not an variable or actual object. When you are refering some thing with like in data command the refering object must be an variable or object not data type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Coming to your sample prog the following code will you correct result, note gt_sflight is a table type required in structure type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_sflight,
         CARRID type S_CARR_ID,
         CONNID type S_CONN_ID,
       END OF ty_sflight.

DATA: gt_sflight type TABLE OF ty_sflight,
      wt_sflight type ty_sflight.

SELECT CARRID CONNID
  INTO (wt_sflight-CARRID,wt_sflight-Connid ) FROM sflight UP TO 50 ROWS.

 append wt_sflight to gt_sflight.
 clear wt_sflight.
ENDSELECT.

loop at gt_sflight into wt_sflight.

write:/ wt_sflight-carrid,
        wt_sflight-connid.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Oct 2008 04:44:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-10-17T04:44:27Z</dc:date>
    <item>
      <title>Populating internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-tables/m-p/4641219#M1092550</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;Given the following internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_sflight,
         sflight LIKE sflight,
         perocc(4) TYPE p DECIMALS 2,
       END OF ty_sflight.

DATA: gt_sflight TYPE TABLE OF ty_sflight.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First of all, what's the difference between using TYPE and LIKE, eg in sflight LIKE sflight. Both seem to work the same when I tried debugging.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly, how do I populate the internal table? I tried the following but got an error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT sflight~carrid sflight~connid
  INTO (gt_sflight-sflight-carrid, gt_sflight-sflight-connid) FROM sflight UP TO 50 ROWS.
ENDSELECT.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2008 03:31:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-tables/m-p/4641219#M1092550</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-17T03:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-tables/m-p/4641220#M1092551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   The approach you have follwed will not give result , When you declared a structure type using types statement it is only a data type not an variable or actual object. When you are refering some thing with like in data command the refering object must be an variable or object not data type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Coming to your sample prog the following code will you correct result, note gt_sflight is a table type required in structure type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty_sflight,
         CARRID type S_CARR_ID,
         CONNID type S_CONN_ID,
       END OF ty_sflight.

DATA: gt_sflight type TABLE OF ty_sflight,
      wt_sflight type ty_sflight.

SELECT CARRID CONNID
  INTO (wt_sflight-CARRID,wt_sflight-Connid ) FROM sflight UP TO 50 ROWS.

 append wt_sflight to gt_sflight.
 clear wt_sflight.
ENDSELECT.

loop at gt_sflight into wt_sflight.

write:/ wt_sflight-carrid,
        wt_sflight-connid.

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2008 04:44:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-tables/m-p/4641220#M1092551</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-17T04:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-tables/m-p/4641221#M1092552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;here are the differences &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.)TYPE will only get the technical specification related to the data element (like data type and data length)&lt;/P&gt;&lt;P&gt;    LIKE decalaration will get all the detailsa including semantic and technical detals related to the field or       data     element.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.)It is good Programming practivce to use TYPE instead of LIKE (where ever possible). It is memory efficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.) &lt;/P&gt;&lt;P&gt;The fundamental differance between the type and like is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One is used as data type ( TYPE) the other one as &lt;/P&gt;&lt;P&gt;data object ( DATA )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data type will not hold memory where as the data object will occupy the memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best practise is to define the data type and use the data object when exactly required&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.)Type - Reference to a Data type / SE11 Field-Fieldname.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Like - Obselete statement its like saying i want just like this , so inherit all the property of that variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5.)Please refer to the following link&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/search/highlightContent.jsp" target="test_blank"&gt;http://help.sap.com/search/highlightContent.jsp&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;6.) In the following two declarations, there is a difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1)&lt;/P&gt;&lt;P&gt;types:&lt;/P&gt;&lt;P&gt;var1 type mara-matnr. ( type always refer to the SE11)&lt;/P&gt;&lt;P&gt;I mean the Mara should be created in SE11 tcode.&lt;/P&gt;&lt;P&gt;data :&lt;/P&gt;&lt;P&gt;var2 type var1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*************************************&lt;/P&gt;&lt;P&gt;2) &lt;/P&gt;&lt;P&gt;types : &lt;/P&gt;&lt;P&gt;var3 like mara-matnr. ( here it is not necessary that it should be an object created in SE11 )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : &lt;/P&gt;&lt;P&gt;var4 type var3. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for eg:&lt;/P&gt;&lt;P&gt;data: g_matnr type mara-matnr.&lt;/P&gt;&lt;P&gt;types: var3 like g_matnr. - no error&lt;/P&gt;&lt;P&gt;types: var2 type g_matnr. - error will come.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as g_matnr is not declared in Se11.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;POpulating internal tables :-&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.)Append data line by line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Syntax&lt;/P&gt;&lt;P&gt;		  APPEND [&amp;lt;wa&amp;gt; TO / INITIAL LINE TO] &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	-  Appends new line to internal table &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;	-  &amp;lt;wa&amp;gt; is source area which is appended.&lt;/P&gt;&lt;P&gt;	-  INITIAL LINE TO adds a line initialized with the correct value for its           type to the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Note: sy-tabix contains the index of the appended line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.)Using COLLECT statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Syntax&lt;/P&gt;&lt;P&gt;		  COLLECT [&amp;lt;wa&amp;gt; INTO] &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Note:&lt;/P&gt;&lt;P&gt;Use COLLECT statement for tables having unique standard keys.&lt;/P&gt;&lt;P&gt;Incase of tables with header line omit INTO option.&lt;/P&gt;&lt;P&gt;If an entry with same standard key exists new line is not appended but adds the numeric fields to existing contents.&lt;/P&gt;&lt;P&gt;Else collect acts in a similar way as append.&lt;/P&gt;&lt;P&gt;Sy-tabix contains the index of the processed line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.)Using INSERT statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Syntax&lt;/P&gt;&lt;P&gt;		  INSERT [&amp;lt;wa&amp;gt; INTO / INITIAL LINE INTO] &amp;lt;itab&amp;gt; [index &amp;lt;idx&amp;gt;].&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Note:&lt;/P&gt;&lt;P&gt;New entry has index &amp;lt;idx&amp;gt; and following line has index &amp;lt;idx&amp;gt;+1.&lt;/P&gt;&lt;P&gt;If less than &amp;lt;idx&amp;gt;-1 entries then cannot insert line and sy-subrc = 4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.)To append part or all of an internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Syntax&lt;/P&gt;&lt;P&gt;              APPEND LINES OF &amp;lt;itab1&amp;gt; [FROM &amp;lt;n1&amp;gt;] [TO &amp;lt;n2&amp;gt;] TO &amp;lt;itab2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Note:&lt;/P&gt;&lt;P&gt;Without the FROM and TO options, this statement appends the entire table &amp;lt;itab1&amp;gt; to &amp;lt;itab2&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5.)To copy entire contents of one table into another in one execution&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;	Syntax&lt;/P&gt;&lt;P&gt;		MOVE  &amp;lt;itab1&amp;gt; To &amp;lt;itab2&amp;gt;.&lt;/P&gt;&lt;P&gt;			OR&lt;/P&gt;&lt;P&gt;		&amp;lt;itab1&amp;gt; = &amp;lt;itab2&amp;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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope u understand....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanxs and regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sachin sharma&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;njoy day!!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: sachin sharma on Oct 17, 2008 7:00 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2008 04:55:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-tables/m-p/4641221#M1092552</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-17T04:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Populating internal tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-tables/m-p/4641222#M1092553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jonathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Welcome to SDN.&lt;/STRONG&gt; This is a very simple question. Please search in SDN with the search patterns as 'TYPE' or 'LIKE' you will have number of threads. Or else you can go through a wonderful  [help|http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/frameset.htm] which is provided by SAP on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Swapna.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2008 05:05:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/populating-internal-tables/m-p/4641222#M1092553</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-17T05:05:01Z</dc:date>
    </item>
  </channel>
</rss>

