Skip to Content

Doubts in Data Declarations

Hi Xperts

I'm posting this thread seeking for a clear clarification on the following and the impact in using them in our program:

1. <u><b>TYPE REF TO</b></u> VS <u><b>LIKE REF TO</b></u>

2. Use of <u><b>ANY</b></u> Vs <u><b>DATA</b></u>

kindly let me know how much difference it makes when making use of these

thkx

Prabhu

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 20, 2007 at 12:29 PM

    hi,

    type ref to is used for user defined structures such as classes, objects...........

    like ref to is used for ppredefined classes that are part of sap central library and also existing in r/3 server.

    if helpful reward some points.

    with regards,

    Suresh Aluri.

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 20, 2007 at 12:24 PM

    still not much clear. for instance take this example:

    data: item type ref to matnr.

    vs

    data: item like ref to matnr.

    in this sense what difference it makes? or i'm taking a irrelevant example?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      It is difficult to understand with that example..

      matnr is the name given to both the data element and the fieldname in mara..

      for example..

      take the table tcurr goto se11 and see the table..

      KURST is a field..

      KURST_CURR is a data element..ie data type..

      so i can say

      data var1 type KURST_CURR

      data var2 like tcurr-KURSt.

      data var3 like var2.

      Hope that helps u understand..

      Regards,

      Aparna

  • avatar image
    Former Member
    Aug 20, 2007 at 12:19 PM

    Hi,

    <b>Reference Types</b>

    You can define reference types locally in your programs or globally in the ABAP Dictionary. You use the following syntax:

    TYPES <t> TYPE REF TO ...

    After TYPE, there is no reference to an existing data type. Instead, the type constructor occurs:

    The type constructor

    REF TO DATA

    declares a reference <t> to a data object. Fields with type <t> can contain references (pointers) to data objects, that is, instances of data types

    The type constructor

    REF TO <class>|<interface>

    defines a reference type <t> to the class <class> or interface <interface>. Fields with type <t> can contain references (pointers) to instances of the class <class> or of classes that implement the interface <interface>

    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb30ea358411d1829f0000e829fbfe/content.htm

    Regards

    Sudheer

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2007 at 12:20 PM

    Hi,

    See following link :

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4fbafc9e-0e01-0010-dea9-9d23d1b269fb

    Reward point if helpful.

    Regards.

    Srikanta Gope

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2007 at 12:23 PM

    when you use type.... it means the

    data variable1 type type1.

    type1 is a type defined..

    data var2 like variable1.

    this is when the obj next to like exists as a global or local variable.. it can be defined in the existing program or it can be defined in the ddic..

    Regards,

    Aparna

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 20, 2007 at 12:25 PM

    data is a keyword used in abap for any data delerations

    any is a type that can be used while defining variables wher u dont know which type they will be.. u can decide their type dynamically.. so in the begining you will define them as

    data: var3 type any.

    later u can type cast them..

    Regards,

    Aparna

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 20, 2007 at 12:54 PM

    hmmm i have again opened th post 😔 as my second part still remains unawnsered.

    2. Use of <u>ANY</u> Vs <u>DATA</u>

    Add comment
    10|10000 characters needed characters exceeded