<?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: Clarification in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537899#M245312</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Using the TYPES we can declare a structure in our 
program and this structure can be used for declaring Internal Tables and Work Areas of of type this structure.
The fields in the structure can be predefined data types(C, N, D, T) or form the Data Dictionary.


TYPES :  BEGIN OF str_mara,
         matnr TYPE mara-matnr,
         mtart TYPE mara-mtart,
         mbrsh TYPE mara-mbrsh,
         matkl TYPE mara-matkl,
         qnty  TYPE p DECIMALS 2,
         END OF str_mara.



Here in this structure declaration I have used TYPE
to refer to a field which already exists(i.e in Data Dictionary) that can even be done using LIKE(LIKE is something like inherit the attributes of the referenced element). I will expalin how LIKE can be used.

Consider now I declare an Internal table using the structure I have created.

DATA : it_mara1 TYPE STANDARD TABLE OF str_mara

When I declared a structure using TYPES it was just defined, now when I declare it using DATA statement, its created in the program memory and space is allocated for it.

Now it_mara has been defined previously in the same program. I can declare another Internal Table of type structure str_mara in my program using LIKE

DATA : it_mara2 LIKE it_mara1.

Thus it_mara2 has same attributes as that of it_mara1.

Now I can declare a work area using the structure or predefined Internal table(using LIKE).

DATA : wa_mara TYPE str_mara.

or 

DATA : wa_mara LIKE LINE OF it_mara1.

Dont make use of LIKE use TYPE instead.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refer &lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Aug 2006 04:47:21 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-08-16T04:47:21Z</dc:date>
    <item>
      <title>Clarification</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537897#M245310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friends,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am refering to an existing program for some modification. I am slightly confused with the following field strings.  Could u pls explain me the following (No.1 to 4) as to why it is written like that.  Also pls let me know when and where to use 'Types' and 'Data'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF TY_ITAB,&lt;/P&gt;&lt;P&gt;        GI_TXN_TYPE(4),   "Transaction Type&lt;/P&gt;&lt;P&gt;        LGOBE(16),  " Storage Location&lt;/P&gt;&lt;P&gt;        EBELN LIKE EKKO-EBELN,&lt;/P&gt;&lt;P&gt;        ERFMG(13), "Quantity&lt;/P&gt;&lt;P&gt;        FLAG(1),    "COMPLETION FLAG&lt;/P&gt;&lt;P&gt;      END OF TY_ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF TY_FILEDIR.&lt;/P&gt;&lt;P&gt;        include structure salfldir.&lt;/P&gt;&lt;P&gt;TYPES: END OF TY_FILEDIR.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.&lt;/P&gt;&lt;P&gt;data: begin of gmhead.&lt;/P&gt;&lt;P&gt;        include structure bapi2017_gm_head_01.&lt;/P&gt;&lt;P&gt;data: end of gmhead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.&lt;/P&gt;&lt;P&gt;DATA: I_TAB TYPE STANDARD TABLE OF TY_ITAB WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;      I_MAIN TYPE STANDARD TABLE OF TY_ITAB WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;      IT_FILEDIR TYPE STANDARD TABLE OF TY_FILEDIR WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIA.&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;Mark K&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Aug 2006 04:41:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537897#M245310</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-16T04:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Clarification</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537898#M245311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; 1.&lt;/P&gt;&lt;P&gt;&amp;gt; TYPES: BEGIN OF TY_ITAB,&lt;/P&gt;&lt;P&gt;&amp;gt;         GI_TXN_TYPE(4),   "Transaction Type&lt;/P&gt;&lt;P&gt;&amp;gt;         LGOBE(16),  " Storage Location&lt;/P&gt;&lt;P&gt;&amp;gt;         EBELN LIKE EKKO-EBELN,&lt;/P&gt;&lt;P&gt;&amp;gt;         ERFMG(13), "Quantity&lt;/P&gt;&lt;P&gt;&amp;gt;         FLAG(1),    "COMPLETION FLAG&lt;/P&gt;&lt;P&gt;&amp;gt;       END OF TY_ITAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;A TYPE has been declared so that further declarations of internal tables can make use of TY_ITAB&lt;/P&gt;&lt;P&gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;gt; 2.&lt;/P&gt;&lt;P&gt;&amp;gt; TYPES: BEGIN OF TY_FILEDIR.&lt;/P&gt;&lt;P&gt;&amp;gt;         include structure salfldir.&lt;/P&gt;&lt;P&gt;&amp;gt; TYPES: END OF TY_FILEDIR.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;A TYPE has been declared so that further declarations of internal tables can make use of TY_FILEDIR, In fact here as the structure is coming from (SALFLDIR), there is no need to declare this type and SALFLDIR can directly be used.&lt;/P&gt;&lt;P&gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; 3.&lt;/P&gt;&lt;P&gt;&amp;gt; data: begin of gmhead.&lt;/P&gt;&lt;P&gt;&amp;gt;         include structure bapi2017_gm_head_01.&lt;/P&gt;&lt;P&gt;&amp;gt; data: end of gmhead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;GMHEAD is a structure referring to the BAPI structure. However this can simply declared as&lt;/P&gt;&lt;P&gt;GMHEAD TYPE bapi2017_gm_head_01&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; 4.&lt;/P&gt;&lt;P&gt;&amp;gt; DATA: I_TAB TYPE STANDARD TABLE OF TY_ITAB WITH&lt;/P&gt;&lt;P&gt;&amp;gt; HEADER LINE,&lt;/P&gt;&lt;P&gt;&amp;gt; I_MAIN TYPE STANDARD TABLE OF TY_ITAB WITH&lt;/P&gt;&lt;P&gt;&amp;gt; B WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;&amp;gt; IT_FILEDIR TYPE STANDARD TABLE OF TY_FILEDIR&lt;/P&gt;&lt;P&gt;&amp;gt; ILEDIR WITH HEADER LINE.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;P&gt;Here are the internal tables that are referring to the TYPES declared above. You usually go for TYPES when you need multiple internal tables of the same type. However, with OO ABAP, it has become a standard that you have a TYPE and declare a internal table using that.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;P&gt;Note :Please mark the helpful answers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Aug 2006 04:45:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537898#M245311</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-16T04:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Clarification</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537899#M245312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;Using the TYPES we can declare a structure in our 
program and this structure can be used for declaring Internal Tables and Work Areas of of type this structure.
The fields in the structure can be predefined data types(C, N, D, T) or form the Data Dictionary.


TYPES :  BEGIN OF str_mara,
         matnr TYPE mara-matnr,
         mtart TYPE mara-mtart,
         mbrsh TYPE mara-mbrsh,
         matkl TYPE mara-matkl,
         qnty  TYPE p DECIMALS 2,
         END OF str_mara.



Here in this structure declaration I have used TYPE
to refer to a field which already exists(i.e in Data Dictionary) that can even be done using LIKE(LIKE is something like inherit the attributes of the referenced element). I will expalin how LIKE can be used.

Consider now I declare an Internal table using the structure I have created.

DATA : it_mara1 TYPE STANDARD TABLE OF str_mara

When I declared a structure using TYPES it was just defined, now when I declare it using DATA statement, its created in the program memory and space is allocated for it.

Now it_mara has been defined previously in the same program. I can declare another Internal Table of type structure str_mara in my program using LIKE

DATA : it_mara2 LIKE it_mara1.

Thus it_mara2 has same attributes as that of it_mara1.

Now I can declare a work area using the structure or predefined Internal table(using LIKE).

DATA : wa_mara TYPE str_mara.

or 

DATA : wa_mara LIKE LINE OF it_mara1.

Dont make use of LIKE use TYPE instead.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refer &lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Aug 2006 04:47:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537899#M245312</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-16T04:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Clarification</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537900#M245313</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;1. using types you can declare the internal tables and work areas .in your case you declared the types with few fields .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.in this case you declared the types which is having an include structure. you can declare the work areas ns internal tables .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.declaration of itab with include structure.&lt;/P&gt;&lt;P&gt;4. declaration of itab using types declared.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Aug 2006 04:53:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537900#M245313</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-16T04:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Clarification</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537901#M245314</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;TYPES -- Using a types declaration, you can define your own data types. Further using TYPES declaration you can define a template referring which you can define various objects (Using DATA), also declarations of this type do not occupy memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA --- Using a DATA Declaration you can declare various objects like internal tables, structures and variables. These declarations occupy a initial memory and size of memory differs from object to object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg. If you want a template which can be reusable across the program, declare it using a type declaration and whenever you need a object declare it using DATA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this solves your query, if yes close the thread and reward points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Aug 2006 04:56:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/clarification/m-p/1537901#M245314</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-08-16T04:56:45Z</dc:date>
    </item>
  </channel>
</rss>

