Differance between Type & Like

Hye Friends,
Apart from the following differences what  are the other differences between these two statements.
1 type is used for data type and like is used for ddic structures.
What are the other differences??????????????
Thanks in advance.
Subodh G

Hi Subodh,
Check this info.
The Statements TYPES and DATA
Each ABAP program define its own data types using the statement.
TYPES dtype [TYPE type|LIKE dobj] ...
and declare its own variables or instance attributes of classes using the statement
DATA var [{TYPE type}|{LIKE dobj}] ...
Within the program or a class, you can also define local data types and variables within procedures. Local variables in procedures obscure identically-named variables in the main program or class.
When creating data types and data objects, there are a number of naming convention that also apply for other local program definitions, such as procedures. These are described in detail in the keyword documentation.
The Additions TYPE and LIKE
The additions TYPE type and LIKE dobj are used in various ABAP statements. The additions can have various meanings, depending on the syntax and context.
•        Definition of local types in a program
•        Declaration of data objects
•        Dynamic creation of data objects
•        Specification of the type of formal parameters in subroutines
•        Specification of the type of formal parameters in methods
•        Specification of the type of field symbols
Constructing New Data Types
The TYPE addition allows you to construct new data types in the TYPES, DATA; CONSTANTS; and STATICSstatements. In the TYPES statement, these are local data types in the program. In the other statements, they are attributes of new data objects, meaning that the newly defined data types are not free-standing. Rather, they are linked to database objects.This means that you can refer to them using the LIKEaddition, but not using TYPE.
To construct new data types, the addition TYPE can be used with the following type constructors:
•        Construction of reference types
REF TO type|dobj
•        Construction of structured data types
BEGIN OF struc_type.
END OF struc_type.
•        Construction of table types
tabkind OF linetype [WITH key]
These data types only exist during the runtime of the ABAP program.
Referring to Known Data Types or Data Objects
Using the additions TYPE or LIKE in the TYPESstatement, local data types in a program can be referred to known data types or data objects. This is mainly the case with user-defined elementary data types. If you declare variables using the additions TYPE type or LIKE dobj with statement DATA, the data type of var is already fully defined before the declaration is made.
The known types or data that are referred to must be visible at the point where the data type or variable is declared.
A known data type can be any of the following:
•        A predefined ABAP type to which you refer using the TYPE addition
•        An existing local data type in the program to which you refer using the TYPE addition
•        The data type of a local data object in the program to which you refer using the LIKE addition
•        A data type in the ABAP Dictionary to which you refer using the TYPE addition. To ensure compatibility with earlier releases, it is still possible to use the LIKE addition to refer to database tables and flat structures in the ABAP Dictionary. However, you should use the TYPE addition in new programs.
The LIKE addition takes its technical attributes from a visible data object. As a rule, you can use LIKE to refer to any object that has been declared using DATA or a similar statement, and is visible in the current context.  The data object only has to have been declared. It is irrelevant whether the data object already exists in memory when you make the LIKE reference.
•        In principle, the local data objects in the same program are visible. As with local data types, there is a difference between local data objects in procedures and global data objects. Data objects defined in a procedure obscure other objects with the same name that are declared in the global declarations of the program.
•        You can also refer to the data objects of other visible ABAP programs. These might be, for example, the visible attributes of global classes in class pools. If a global class cl_lobal has a public instance attribute or static attribute attr, you can refer to it as follows in any ABAP program:
DATA dref TYPE REF TO cl_global.
DATA:  f1 LIKE cl_global=>attr,
       f2 LIKE dref->attr.
You can access the technical properties of an instance attribute using the class name and a reference variable without first having to create an object. The properties of the attributes of a class are not instance-specific and belong to the static properties of the class.
TYPES: BEGIN OF struct,
         number_1 TYPE i,
         number_2 TYPE p DECIMALS 2,
       END OF struct.
DATA:  wa_struct TYPE struct,
       number    LIKE wa_struct-number_2,
       date      LIKE sy-datum,
       time      TYPE t,
       text      TYPE string,
       company   TYPE s_carr_id.
This example declares variables with reference to the internal type STRUCT in the program, a component of an existing data object wa_struct, the predefined data object SY-DATUM, the predefined ABAP type t and STRING, and the data element S_CARR_ID from the ABAP Dictionary.
Referring to Generic Data Types
If you refer to one of the generic predefined ABAP types of fixed length (c, n, p, x) in the TYPES or DATA statement, you must specify the undefined technical attributes.
TYPES|DATA var[(length)] TYPE type [DECIMALS dec]...
TYPES|DATA var TYPE type [LENGTH len] [DECIMALS dec]...
DATA: text1,
      text2 LENGTH 2,
      text3 TYPE c LENGTH 3,
      pack TYPE p DECIMALS 2 VALUE '1.225'.
This example creates three character variables with field lengths of one, two, and three bytes respectively, and a packed number variable with field length 8 bytes and two decimal places. If the attribute Fixed point arithmetic is set, the value of pack is 1.23.
This example shows how to declare elementary data objects with reference to predefined ABAP types.
PROGRAM demo_elementary_data_objects.
DATA text1  TYPE c LENGTH 20.
DATA text2  TYPE string.
DATA number TYPE i.
text1 = 'The number'.
number = 100.
text2 = 'is an integer.'.
WRITE: text1, number, text2.
This program produces the following output on the screen:
The number              100 is an integer.
In this example, the data objects text1, text2 and number are declared with the DATA statement. The technical attributes are determined by referring to the predefined ABAP types c, string, and I. Values from unnamed literals are assigned to the data objects. The contents of the named data objects are displayed on the list.
Specifying a Start Value
When you declare an elementary fixed-length variable, the DATAstatement automatically fills it with the type-specific initial value as listed in the table in the Predefined ABAP Types section.
However, you can also specify a starting value of a fixed-length elementary variable (also within a structure declaration) using the VALUE addition in the DATAstatement:
DATA var ... VALUE val|{IS INITIAL}.
Specifying start values:
DATA: counter TYPE p VALUE 1,
      date    TYPE d VALUE '19980601',
      flag    TYPE n VALUE IS INITIAL.
After this data declaration, the character string flag contains its type specific
Initial value ‘0’
Internal Tables
Internal tables are dynamic variable  data objects. Like all variables, you declare them using the DATA statement.
You can also declare static internal tables in procedures using the STATICSstatement, and static internal tables in classes using the CLASS-DATAstatement.
This description is restricted to the DATAstatement. However, it applies equally to the STATICS and CLASS-DATA statements.
Referring to Known Table Types
Like all other data objects, you can declare internal tables using the LIKE or TYPE addition of the DATA statement.
DATA itab TYPE type|LIKE obj [WITH HEADER LINE].
Here, the LIKE addition refers to an existing table object in the same program. The TYPE addition can refer to an internal type in the program declared using the TYPES statement, or a table type in the ABAP Dictionary.
You must ensure that you only refer to tables that are fully typed. Referring to generic table types (ANY TABLE, INDEX TABLE) or not specifying the key fully is not allowed (for exceptions, refer to Special Features of Standard Tables).
The WITH HEADER LINE addition is obsolete; you should no longer use it. Also see the keyword documentation.
The optional addition WITH HEADER LINE declares an extra data object with the same name and line type as the internal table. This data object is known as the header line of the internal table. You use it as a work area when working with the internal table (see Using the Header Line as a Work Area). When you use internal tables with header lines, you must remember that the header line and the body of the table have the same name. If you have an internal table with header line and you want to address the body of the table, you must indicate this by placing brackets after the table name (itab[]). Otherwise, ABAP interprets the name as the name of the header line and not of the body of the table. You can avoid this potential confusion by using internal tables without header lines. In particular, internal tables nested in structures or other internal tables must not have a header line, since this can lead to ambiguous expressions.
TYPES vector TYPE SORTED TABLE OF i WITH UNIQUE KEY table_line.
DATA: itab TYPE vector,
      jtab LIKE itab WITH HEADER LINE.
MOVE itab TO jtab.   <-  Syntax error!
MOVE itab TO jtab[].
The table object itab is created with reference to the table type vector. The table object jtab has the same data type as itab. jtab also has a header line. In the first MOVE statement, jtab addresses the header line. Since this has the data type I, and the table type of itab cannot be converted into an elementary type, the MOVE statement causes a syntax error. The second MOVE statement is correct, since both operands are table objects.
Declaring New Internal Tables
You can use the DATA statement to construct new internal tables as well as using the LIKE or TYPEaddition to refer to existing types or objects. The table type that you construct does not exist in its own right; instead, it is only an attribute of the table object. You can refer to it using the LIKE addition, but not using TYPE. The syntax for constructing a table object in the DATA statement is similar to that for defining a table type in the TYPESstatement.
DATA itab TYPE|LIKE tabkind OF linetype WITH key
          [INITIAL SIZE n]
          [WITH HEADER LINE].
As illustrated when you define a table type yourself, the type constructor
tabkind OF linetype WITH key
defines the table type tabkind, the line type linetype, and the key key of the internal table itab. Since the technical attributes of data objects are always fully specified, the table must be fully specified in the DATAstatement. You cannot create generic table types (ANY TABLE, INDEX TABLE), only fully-typed tables (STANDARD TABLE and TABLE, SORTED TABLE, HASHED TABLE). You must also specify the key and whether it is to be unique (for exceptions, refer to Special Features of Standard Tables).
As in the TYPES statement, you can, if you wish, allocate an initial amount of memory to the internal table using the INITIAL SIZEaddition. You can create an internal table with a header line using the WITH HEADER LINE addition. The header line is created under the same conditions as apply when you refer to an existing table type.
DATA itab TYPE HASHED TABLE OF spfli
          WITH UNIQUE KEY carrid connid.
The table object itab has the type hashed table, a line type corresponding to the flat structure SPFLI from the ABAP Dictionary, and a unique key with the key fields CARRID and CONNID. The internal table itab can be regarded as an internal template for the database table SPFLI. It is therefore particularly suitable for working with data from this database table as long as you only access it using the key.
Hope this resolves your query.
<b>Reward all the helpful answers.</b>
Regards

Similar Messages

  • PO Output message types for different document types

    Hi,
    I wanted the system automatically generate the messages whenever a PO is created for different document types like NB,UB,Blanketorder, Pilot run.
    These are the steps i did...plz advice any more steps to make this work
    1. the output type I am using is NEU-purchase order
    2. I have created condition records for document types NB,UB,PR etc
    I was sucessfull in getting the messages automatically for the standard(NB) PO..but not for the other document types
    Plz advice me how I can achieve this with further configurations
    Thanks
    SKid

    If you have created conditin record for all the document type in MN04 then it should work becuase doc type has nothing to do for printing config.
    this is basically a condition record.
    check your condition record

  • Posting in gr from po for 2 materials in to 2 different movement types

    hi,
    i have 2 items in a single purchase order, how can i  post them to different movement types like 101, 103 in one goods receipt. for ex in MIGO , i enter purchase order number , it is taking all the items from PO in to one movement type like 101 .. and if i go to 2nd in  item over view and change the movement type to 103 and press enter it is coming to 101..
    pl advise me , how to do that,
    thanks in advance
    srini

    hi, thanks for quick reply, but i am entering goods receipt with referece to purchase order..  i am entering po number and movment type 101 in MIGO and pressing enter.. so all the materials in po being copied in to GR..and after that if i want to change the 2nd material to 103 it is not allowing me... it is considering all the materials belong to 101 only...
    so do i need to delete the rest of  the materials in GR and enter them individually? if i have 100 items in PO  belongs to diff mov types then do i have to enter GR 100 times? pl explain..
    thanks in advance .
    regards,
    srini komati

  • What is the different between component and component type in extract struc

    Hi All,
    What is the different between component and component type in the Extract Structure?
    I used them, but I never really know the different between them yet.
    Thanks,
    Grace

    The difference between Component and Component Type are:
    Component This is essentially the field name in the extraction structure. These can either be SAP delivered field names or custom field names (e.g. Y* or Z*).
    Component Type This defines the data definition for the field, along with associated attrributes and descriptions for anything using that Component Type, to define the corresponding Component. If you double-click on any Component Type in an extraction structure, it will show you the definitions that have been setup for that Component Type (will display as Data Element but it's essentially synonymous - Component Type refers to structures and Data Elements refer to tables).

  • Difference between Account members of 2 different plan types

    Can we find out difference between members of Account dimensions having source as 2 different plan types. One of the plan type has 2 extra dimensions also.

    You should be able to do this as long as one of the accounts is ALSO present in the plan type that the other account is stored in. So probably Acc.member2
    could be set to have a "Source plan Type" of plan 2, but also be selected to appear in plan 1 when you edit the Acc.member2 account in the Planning web application. Planning would enable the account to appear in plan 1 via an XREF on the account member definition in Essbase) .
    Then in plan 1 you would set up a third account which would calculate the difference between the 2.
    You would be able to analyse the variance only by the dimensions in plan 1 (i.e. D1, 2, 3, & 4: those dimensions common to both plan types)
    Hope this helps
    Edited by: Xansaman on Nov 25, 2010 4:26 PM

  • I'd like to know what is different between iPad air with wifi, and with cellular

    I'd like to know what the different between iPad air with wifi and with cellular

    With the wifi only one you can only get internet via wifi.
    With the cellular one you can also access the internet via cellular (with appropriate data plan)
    beyond that, and the price, they're the same

  • What is the difference between TYPE and LIKE exaclty.

    Hi,
    Type refers to data type like C or I or N etc...
    example :
    matnr type mara-matnr.
    Like refers to data object.
    can also use in programs like:
    matnr like mara-matnr.
    I am not getting the exact difference in both.

    [Try here: lmgtfy|http://en.lmgtfy.com/?q=WhatisthedifferencebetweenTYPEandLIKEin+ABAP]

  • Mapping Design  - SOAP body content needs to be different between test and production

    Hello,
    We are integrating with a 3rd party SOAP receiver who uses the same web service URLS for test and production.
    So to differentiate they exposed 2 web services which do the same thing but have different root and payload node names...along with account details.
    For example, for production our SOAP XML must follow pattern like:
    <Envelope>
    <Body>
    <appRequest>
    <userID>produser</userID><password>prodpwd</password>
    <appPayload>
    <?xml>
    blah blah this XML is the same between test and production
    </xml>
    </appPayload>
    etc
    But for their testing we must use:
    <Envelope>
    <Body>
    <appRequestTest>
    <userID>testuser</userID><password>testpwd</password>
    <appPayloadTest>
    <?xml>
    blah blah this XML is the same between test and production
    </xml>
    </appPayload>
    etc
    So I'm trying to think of a good way to handle this difference in one set of mappings that we can use in our 3 PI platforms Dev / Test / Prod
    Since these differences are in the SOAP Body does it need handled in mapping or is there a way to handle it in the Adapter Config which is naturally different between our environments (mapping we like to keep the same).
    What is a smart way to handle this scenario?
    Many thanks,
    Aaron

    I second Artem when he states that this is a bad design decission from the caller's side.
    However this is not gonna help you in the current situation, right?
    The problem you are facing is that by poor design the message does not have a root node which you may use to handle occurences. Let me explain further
    You would be good if prod message looked like so
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
      <appData>
       <appRequest>
       </appRequest>
      </appData>
    </soapenv:Body>
    </soapenv:Envelope>
    and test message looked like so
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
      <appData>
       <appRequestTest>
       </appRequestTest>
      </appData>
    </soapenv:Body>
    </soapenv:Envelope>
    --> Then you would have been able to specify occurence of <appRequest> and <appRequestTest> as 0..1
    So I think you have (besides what Artem already pointed out) 2 other options:
    1. activate "do not use SOAP envelope" on sender SOAP channel and then designing the data types like above
    2. Use HTTP instead of SOAP adapter and designing data types like above
    Hope I didn't miss something crucial :-)
    Cheers
    Jens

  • Encoding different file types to binary

    Hi, im writing an application which takes different file types and then encodes them to be sent down a noisy channel, after random effects the data must be decoded back to binary. I have done the algorthims for encoding and decoding binary but i dont know how convert the file types to binary. (files such as jpgs and mp3 and txt)

    ...i know how to do the encoding on binary ...
    ...im not sure how to do this...Maybe you could start by explaining the problem in detail to yourself such that you understand it, then come back and tell us.
    Are you concerned about a difference between a JPG file vs a text file? Text files, in the context you are describing, can be treated as binary just as easily. Use a FileInputStream to read it and you get bytes just like any other file.

  • Different reference type passed to SubVI

    Hi all,
    I use a subVi to access some properties of an XY graph (scale, offset ...) that's why I use a reference to the graph and give it to the subVI.
    Now I would like to use the same subVI in order to modify the same properties but for an intensity graph.
    Of course when I connect the intensity graph reference to the subVI, the wire gives an error related to incompatible reference type.
    Could someone tell me how I could proceed to connect different reference types to the same subVI input?
    I tried to use "to more generic class" component but I'm not able to find how to use it in this case.
    Thanks in advance for your help

    Hi Fabrice,
    You could place a Case Statement indexed by the type of graph whose properties you want to access / modify, etc.  The reason for mentioning that is the fact that you may not be able to use the same property node for both types of graphs, especuially if you access properties that are not common between the two. 
    There may be tricks that you could try, but as far as using the component "to more generic class", it would have to be located in the calling vi and not the sub-vi.  That is so the same (sub-vi) Terminal can be used.
    However, I am not sure that it would work...  I think I understand what you are trying to do...  I'm not sure if you'll be successful due to the reference types (might be worth a try)..  Nevertheless, if you simply wish to use the same sub-vi for two different graph types, then using the Case Statement will be the quickest solution to implement.
    RayR

  • What is the different between Sharepoint fast search service and Sql server fulltext search?

    HI ,
    I want to kow what is the different between Sharepoint fast search service and Sql server fulltext search?
    Or Can I abstract the Sharepoint fast search from the Sharepoint platform as a isolate component?
    Thank you.
    James

    They are very, very different beasts.
    Firstly FAST Search for SharePoint is the old name for the product and is only relevant for SharePoint 2010 not 2013. It got merged into the standard SharePoint search for the 2013 release.
    SharePoint search is aimed at providing a Bing or Google like experience for your intranet content, as well as providing some nifty features that are purely SharePoint releated along the way. That means it can crawl SharePoint content, file shares,
    outlook mailboxes, internal and external websites and probably fifty other different things if you really tried. Whilst i'm not an expert on SQL full text search I believe it's intended to provide a search feature for content held within SQL databases
    and tables.
    Can you run SharePoint purely for Search? Yes, definitely.

  • Saving cluster of different data types to a file

    Hi,
    I use LV 8.6 SDK. I need to save clusters of different data types to a file on a disk, row by row.
    To be specific: I have a program that performs various investigations on a signal collected by DAQmx. Each time the quality of the signal is not in a specified boundaries, i get an indication. It is a cluster of time stamp, string, dbl, and Boolean. The program is supposed to run for few weeks in a row so there can be a lot of these indications. I expect to have around 200 000 rows a week (Altogether, divided into several groups).  
    I thought about TDMS but I am not able to save such a cluster. And I would like to save it as tdms cause i could divide the data to different groups. I also thought about data base but that would be the first time i use db and I really do not  have time to learn that now.
    I know it is possible to change some of the data types to others, ex Boolean to 0-1, but i need a string and a time stamp there. 
    Can someone advise me which data format should I use? Which one is the best one in this situation?
    Thanks in advance
    handre

    If you do not need to access data from another application (other than Labview) you can just save it as a binary file.
    It is the best choice (for me).
    I made an example with one cluster. You can replace that with an array of clusters, of that data type.
    Attachments:
    Example_VI_BD.png ‏2 KB

  • Store values of different data types into single database field

    Hi Friends,
      I  have to store values of different data types(character, numeric, date, time,  text, etc) into a single database field(Char 80). Then read the same values and display it into ABAP Webdynpro report. 
    Appreciate any ideas, examples, suggestions.
    Thanks
    JB

    Hi,
    Try like this:
    data: txt1 type string,
          var1(1) type c,
          var2(1) type n,
          var3 like sy-datum,
          var4 like sy-uzeit.
    parameters: a type c,
                b type n,
                c like sy-datum,
                d like sy-uzeit.
    concatenate a b c d into txt1.
    write txt1.
    var1 = txt1+0(1).
    var2 = txt1+1(1).
    var3 = txt1+2(8).
    var4 = txt1+8(8).
    write: / var1,
           / var2,
           / var3,
           / var4.
    Regards,
    Bhaskar

  • We have created shared folder on multiple client machine in domain environment on different 2 OS like-XP,Vista, etc. from some day's When we facing problem when we are access from host name that shared folder is accessible but same time same computer when

    Hello All,
    we have created shared folder on multiple client machine in domain environment on different 2 OS like-XP,Vista, etc.
    from some day's When we facing problem when we are access from host name that shared folder is accessible but same time same computer when we are trying to access the share folder with IP it asking for credentials i have type again and again
    correct credential but unable to access that. If i re-share the folder then we are access it but when we are restarted the system then same problem is occurring.
    I have checked IP,DNS,Gateway and more each & everything is well.
    Pls suggest us.
    Pankaj Kumar

    Hi,
    According to your description, my understanding is that the same shared folder can be accessed by name, but can’t be accessed be IP address and asks for credentials.
    Please try to enable the option below on the device which has shared folder:
    Besides, check the Advanced Shring settings of shared folder and confrim that if there is any limitation settings.
    Best Regards,
    Eve Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • Different Material Types in different Plants

    Hi,
    I have 2 Plant under a Company Code. A material being produced in plant A has to be sent to Plant B for further processing. I would like to maintain single material master for both the plants, but different Material Types. Material has to be treated as Finished Goods in Plant A and Raw Material at Plant B. Could any one please let me know how I can MAP it in SAP.
    Regards,
    Nagaraja Achar.

    Hi,
    For the Same material Code you can not maintain two material types in two plants..
    But you can make a Z* mat type with all the relevant views of FG & ROH..
    For Plant 1 it will have all the views
    and for Plant 2 extend only the ROH relevant views...
    Thx
    Raju

Maybe you are looking for

  • Sharing movies after re-installing iMovie 5

    Gratefully found you guys the other day as crisis unfolded. Realised from reading here that problem with editing my movie was iLife '06. I'd installed it mid-project as well. Slapped wrist, lesson learned. Followed recipe to re-install 5. Went well.

  • Batch developing from Bridge

    How do I  batch develop my edited images that were open in Bridge and edited in CameraRAW? Normally I have to then open those images it PS only to save them as JPGs which feels like waste of time. Can this be done directly from Bridge? yaro

  • Iphone 3GS 16gb itunes shuts down when attemping to sync photos

    itunes ver 10.1.0.56; iphone 3gs os 4.1; after phone is connected to itunes and is recognized i can sync all other tabs except the photos tab; I can click on the photo tab and when I select the folder pictures the dialog box comes up and says itunes

  • How do I order Windows 7 Recovery Disc? Plz Help Me!!!!

    My recovery setup provided by HP didnt work..What should I do? I need to format my laptop.. HP Pavilion G4-1205TX

  • Adding a logo or image to a email signature

    What is the best file format to use as an image that will be most universal? .ai .eps .jpg .pdf .tif ??????