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

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

Similar Messages

  • Doubt regarding data declaration in update routine!

    Hi,
    i had added one field in cube, update rotuine for which is in due.
    in the update routine logic i have to assign this field to another field if some condition satisfies!
    the logic is --
    if Hstatus=c
    close_date=stdatum.
    close_date is the field i had created and added in info cube definition.
    now, how to declare these fileds in routine as it is asking me to declare the fields
    can any body suggest me how to declare those fields!
    Thanks,
    Ravi

    Hi,
    In cube, for updating every keyfigure, all the characteristics will be taken into account. So, in cube if you choose a keyfigure in characteristic tab you can find all the characteristics. Likewise you can find for all the keyfigures.
    So, Transfer routine for all kefigures will transfer the same routine of the characteristic for all the keyfigure. (that means if you choose different keyfigure and if you choose a the same characteristic you can find the same routine, no need to create separate ) If you choose no, it wont transer the same routine to all the keyfigures for the characteristic. You can define the separate routine for the characteristic for every keyfigure.
    in ODS this is not the case. There only Keyfields only will be common for all the datafields.
    rgrds,
    v.sen.
    Message was edited by:
            Senthilkumar Viswanathan

  • What is the use of # in data declaration

    hi experts,
    i am working in one of the old programs, where in data declaration they have used -
    data: matnr like mara-matnr,##
             mfrpn like mara-mfrpn,##
    and when i work in front end editor (4.7c), these data come in red colour. i know when i comment any line with (*), that line comes in red colour.
    i want to know why these lines comes in red colour.
    is it any pseudo comment of older version or what.
    plz rectify my doubt.
    Thanks.
    Sri.

    Hi Sakthi,
    means a character that cannot be displayed. Probably thes are control characters from you old system, e.g. linefeed, tab, carriage return or the like.
    The lines are displayed in red because the editor does not know how to handle. So # is ignored. You can delete the characters to have a better look or you can do the same as the editor does: Ignore them. There is definitely to syntactcal meaning at all.
    Regards,
    Clemens

  • Doubt in data element creation

    Hi,
        I have doubt in data element creation ie, there is 2 options elementary type
    (domain and built-in-type) and reference type (name of the reference type &
    ref to predefined type). if there is built in type here then what is the use of
    built-in-type in initial screen of the table and also explain me about the use of
    reference type.
    with regards,
    nanjunda sharma

    Hi!
    With the use of the built-in type, you have to set always in every different data element the exact type.
    With the use of the domains (pre-defined types) you just have to enter the domain name into the data element. If you have to modify the type, you can maintain it in the domain (only once) but the built in types have to modifyed in every data element (which means more work).
    Domains have a little more options also, than the built in types.
    Regards
    Tamá

  • Issue in WS based on FM with data declared as TABLES

    Dear all,
    I created enterprise WS with endpoint as function module. The FM has a date declared as TABLES. I see the table data under Output section of External and Internal view in SE80. Also the data is being exposed (check box set). However if I consume the WS either via ABAP consumer proxy or externally outside the SAP system (from JAVA app) the data which is declared as TABLES is not visible in RESPONSE from the WS.
    Is this behavior feature? Shall I always declare (in case of custom FM) all the data as EXPORTING?
    If so what about the SAP standard FMs? In this case do I need to always create custom Z* FM as wrapper?
    thanks
    m./

    Please re-post if this is still an issue to the Business Objects Forum or purchase a case and have a dedicated support engineer work with you directly

  • Doubt in data transfer

    can anybody tell
    wat type of interface or which method  can be used to move datas or table from flat file structure
    the requriement is first we have to generate a flatfile structure from sap r/3 and we have to trasfer the datas to one particular server.
    wat method we can use
    eg:material master
    sales order

    Hi,
      try the following code n let me know if it meets ur requirement.
    *"Table declarations...................................................
    tables: kna1.
    *"Selection screen elements............................................
    select-options: s_kunnr for kna1-kunnr.             " Customer Number 1
    Type declaration of the structure to hold Customer master           *
    data:
      begin of fs_kna1,
        kunnr type kna1-kunnr,             " Customer Number 1
        adrnr type kna1-adrnr,             " Address
        anred type kna1-anred,             " Title
        erdat type kna1-erdat,             " Date on which Record Was reated
        ernam type kna1-ernam,             " Name of Person who Created
      end of fs_kna1.
    Internal table to hold Customer master                              *
    data:
      t_kna1 like standard table
               of fs_kna1.
    Type declaration of the structure to hold file data                 *
    data:
      begin of fs_table,
        str type string,
      end of fs_table.
    Internal table to hold file data                                    *
    data:
      t_table like standard table
                of fs_table.
    field-symbols: <fs>.
    *" Data declarations...................................................
    Work variables                                                      *
    data:
      w_char(50) type c.
    select kunnr                           " Customer Number 1
           adrnr                           " Address
           anred                           " Title
           erdat                           " Date on which Record Was reated
           ernam                           " Name of Person who Created
      from kna1
      into table t_kna1
    where kunnr in s_kunnr.
    if sy-subrc eq 0.
      loop at t_kna1 into fs_kna1.
        do.
          assign component sy-index of structure fs_kna1 to <fs>.
          if sy-subrc ne 0.
            exit.
          else.
            move <fs> to w_char.
            if sy-index eq 1.
              fs_table-str = <fs>.
            else.
              concatenate fs_table-str ',' w_char into fs_table-str.
            endif.                         " IF SY-INDEX...
          endif.                           " IF SY-SUBRC...
        enddo.                             " DO...
        append fs_table to t_table.
      endloop.                             " LOOP AT T_KNA1...
    endif.                                 " IF SY-SUBRC...
    call function 'GUI_DOWNLOAD'
      exporting
      BIN_FILESIZE                    =
        filename                        = 'C:\Assign\kna1'
      FILETYPE                        = 'ASC'
      APPEND                          = ' '
      WRITE_FIELD_SEPARATOR           = ' '
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
    IMPORTING
      FILELENGTH                      =
      tables
        data_tab                        = t_table
      FIELDNAMES                      =
    exceptions
       file_write_error                = 1
       no_batch                        = 2
       gui_refuse_filetransfer         = 3
       invalid_type                    = 4
       no_authority                    = 5
       unknown_error                   = 6
       header_not_allowed              = 7
       separator_not_allowed           = 8
       filesize_not_allowed            = 9
       header_too_long                 = 10
       dp_error_create                 = 11
       dp_error_send                   = 12
       dp_error_write                  = 13
       unknown_dp_error                = 14
       access_denied                   = 15
       dp_out_of_memory                = 16
       disk_full                       = 17
       dp_timeout                      = 18
       file_not_found                  = 19
       dataprovider_exception          = 20
       control_flush_error             = 21
       others                          = 22
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    reward if helpful.
    regards,
    kiran kumar k

  • Data declaration error in adobe form

    hi,
    i m just remake a smartform into adobeform.but while doing so it's giving me error regarding data declaration.
    I had declare some of internal table as type of defiened type but at code initialzation it giving it's not a internal table.
    global data
    it_abc type ty_abc,
    types :
    types: begin of ty_abc,
               ab(8) type c,
               bc(4) type c,
              end of abc.
    when i m creating a internal table in code initialization it's giving me that already declared.
    code initialization.
    data : it_abc type table of ty_abc.
    Plz help me out.
    Regards
    Ricky

    Hi Maheshwari,
    After the declaration of the TYPES Structure, you need to declare the Internal Table. As follows
    TYPES
    types: begin of ty_abc,
              ab(8) type c,
              bc(4) type c,
              end of abc,
              tt_abc type standard table of ty_abc initial size 0.
    And in Global Declaration you use the newly created Internal Table (which is created using the Types Statement). And in Code Initialization you can use the Global Declaration internal table.
    Regards
    Pradeep Goli

  • Dynamic data declaration refering to local data defined in another program

    Here is the situation:
    The standard program SAPICP__ , SAPICF__ and several other of same series have a form routine REPOSITORY_DEVCLASS_ADD. this subroutine in all SAPI* programs has parameter REPOSITORY of type REPOSITORY (declared as internal table with header lines) and type REPOSITORY is declared with different component in each program.
    Now the problem is that i need to call subroutine REPOSITORY_DEVCLASS_ADD dynamically from my program and so i want to dynamically declare the table REPOSITORY in my program to pass to this subroutine and as program is not yet loaded into memory i have no way to achieve this.
    Can some one help in achieve this?
    Edited by: Gaurav B. on Jan 30, 2012 4:02 PM

    Hello Fred,
    That's a big task, even if it looks "easy". My first idea is, your request can not be covered by dynamic programming. a) every node has a different structure (I guess), b) the code itself has to be adjusted to the nodes in use as well. I.e. when a dynamic data declaration would be possible, the coding has to adhere the used number of nodes.
    My recommendation:
    - declare as many standard tables (nodes) as possible
    - the code for  each node has to be implemented
    - define the number of used nodes by a parameter or an interface
    Have success,
    Heinz

  • Help reqd - Data declaration

    Hi,
    I have a problem here. I am analyzing an existing program. This is an active prg in Production.
    In that I see usage of an internal table called 'itab1'. On double clicking on it (to find it's data declaration) it takes no-where. It asks if I would like to create it.
    In an include program (which in embedded in this main program), I find some declaration as follows:
      data: itab&1 like &2 occurs 0 with header line.
    Can you help me understand this? I need to change the data declaration for this 'itab1' for an upgrade.
    Regards,
    Sanju.

    Macros are defined using the following statement:
    DEFINE conversion.
      if &1 is not initial.
        &2 = c_X.
      else.
        &2 = space.
      endif.
    END-OF-DEFINITION.
    You apply it like described bellow:
      conversion var_1 var_return.
    My guess is that this internal table is being declared using the macro parameter. so, if &1 is valued with "10", that internal table will be named itab10.
    Not quite sure about that, but maybe that's what is happening. Try to find the place where the macro is being called and see if &1 value is '1'.

  • Dynamic data declaration

    I posted same thread into "Dictionary section"
    Hi,
    I have a following issue - I am not sure whether this is possible - so I need your feedback/expertise.
    I have a custom table (example ZABC) with several fields in it - one of them being TABNAME . Content of that table ZABC is
    MANDT TABNAME FIELDNAME ZCHECK
    800 KNA1                KUNNR
    800 KNA1                NAME1         X
    800 KNA1                NAME2         X
    800 KNA1                KUNNR
    800 KNVV                BZIRK           X
    800 KNAS                KUNNR
    800 KNAS                STCEG
    etc.
    There is no rule how many entries will be in this ZABC table - I guess it will be less than 20 - but this is not business rule. Also do not know how many different "tables" could be specified.
    Fields MANDT and ZCHECK fields are not important at this stage.
    The challenge I have is to fetch data for only those fields from their specified physical tables (KNA1, KNVV, KNAS) in internal tables.
    In this case I would need to have 3 internal tables one for KNA1, one for KNAS and one for KNVV.
    I need to keep those "internal" table with content throughout the entire program for certain validation.
    I know that I should dynamically define those internal tables but I have issues not knowing how many tables will be defined in ZABC table and I personally do not want to declare "<fs_itab> TYPE ANY TABLE" 20 or so times as fs_itab1 - fs_itab20.
    Is there any way I can dynamically create as many internal tables as needed and keep their content throughout program run-time.
    Regards
    Goran

    All those examples you'all posted are great BUT it does not answer my question nor help me to solve my issue. Maybe I was not clear enough ... or something is wrong with me
    Once again.
    I have no problem to get a dynamically defined table and fill its content from ONE physicall table. That is pretty straight forward. The issue I have is that I do not know how many dynamically tables I will have to define and later asign to field symbol. Look at my custom table above and you will understand what I am trying to say.
    What makes this issue more complex is that, once data fetch from those physicall SAP tables, I have to keep the content for all those internal tables during the entire program run . Second the most, I do not want to limit the program by defining FS "n" times in data declaration section. That is really important since I have no idea how many tables will be accessed.
    If I follow the logic from your examples, I will end up overwritting the FS content every time I assign new internal table to FS.
    In order to solve this issue, I was thinking that whenever I get the data from SAP table into internal table (field symbol) i export the content of internal table / FS to memory and then retrieve them when needed. This sounds like waky /fuzzy process and I am not aware of anything better. I am old fashion ABAP guy who got certified 1995 and have not seen ABAP for at least 5 years.
    I would like that someone either tells me whether I am OK going forard with my "memory" solution or ... in few words gives me hint how to handle multiple dynamicall defined tables AT THE SAME TIME with its content using some OO code.
    Thanks
    G
    P.S.
    I have erroneusly opened the same thread twice. Sorry

  • SCAN ABAP-SOURCE : problems to recognize all DATA declarations

    Hi all !
    My problem is simple :
    When I scan a program, all data declarations structures are not recognized :
            SCAN ABAP-SOURCE t_code_prgm  TOKENS into t_tokens
                                      STRUCTURES into t_structures
                                      STATEMENTS into t_statements
                                          LEVELS into t_levels
                                      WITH INCLUDES
                                      WITH ANALYSIS.
    In "t_structures", for some data declarations, the scan find  statement types "d" (DATA) and "t" (TYPES), but not others ("k" --> constants ...etc...)
    With DATA, SCAN recognize itab like  "DATA : BEGIN OF itab ....", but no "DATA wa_data type ..." !!!
    Do someone know why ?
    I need this to scan programs and control how DATA are named.
    Thanks !
    Stephane.

    Hi,
    If RSA3 is giving the error that means the data source is not ready yet.
    May be you should again do the transports and see if there is no difference between the development and production system.
    Also make sure that you have maintained all the settings for the CO-PA to work as it was in the developement system.
    Also
    Try to run a delta after 2 hours of initialization in production dont schedule it immeadiately.
    Are you sure that delta and init and RSA3 was running fine in quality and developmenet system in the same way as you are trying here??
    Thanks
    Ajeet

  • Global data declaration in a function group..

    hi,
    i have created a function group and created 2 FM in that. Both use some common data declarations so i declared those variables in the top include of the function group named LZFGXXXTOP.
    is this include automatically recognized in my FM or do i have to include it ? sample statements please ..
    thks

    Sorry Rich, I fail to understand what you are saying.
    in simple terms, i need to have some common data declarations for 2 function modules in a function group. Can u pl outline the steps I need to follow ? also i need to have a common set of form routines (FORM ENDFORM) to be used in these 2 function modules, where do i create these ?
    thks a lot

  • Efficient or Better Ways for Data Declaration

    Hi Guys,
    Basically I've always programmed much the same way for a pretty long time now. Lately I've been asking myself the question - "how can i start improving on my tried and trusted ways".(oftern a linear programming approach). As part of this I'm examining ways to declare data better within in programs and to adopt a neat way to do so.
    This may seem pretty trivial but the first question I want to ask is how to declare data better
    e.g. I need to declare constants - each constant corresponds to a rule number; 1, 2,3,4,5,6 - 23 etc.
    Instead of declaring the following line 23 times - is there a better way to declare in such a way.
    Constants: c_rule_1 type c value '1' ,
                    c_rule_2  type c value '2',
                    etc etc etc
    Your thoughts are greatly appreciated.
    Thanks.
    DK
    Edited by: Damien Kesle on Nov 26, 2008 10:00 AM

    Hi,
    With my knowledge, data declarations for all constants with DATA comamnd itself is good practise in point of performance. Alternative is dynamic creation of variables. But it consumes more time and is not good to practise. Instead of crating individual parameters for each constant, you could create a structure and add all constants as fields as follows:
    constants: begin of con,
                       1 type c value '1',
                       2 type c value '2',
                    end of con.
    Regards,
    Prasanth

  • DIFFERENCE BETWEEN THE DATA DECLARATIONS NVARCHAR2 AND VARCHAR2(x CHAR)

    CAN ANYONE HELP ME FIND THE DIFFERENCE BETWEEN THE DATA DECLARATIONS; NVARCHAR2 AND VARCHAR2(x CHAR), WHERE X IS THE SIZE OF DATA TO BE HELD WITH THE VARIABLE OR ATTRIBUTE

    Duplicate posting....
    Difference between nvarchar2(10) and varchar2(10 char )
    Difference between nvarchar2( 10) and varchar2( 10 char)
    Please refer also...
    Nvarchar2

  • Doubt regarding Data transfer from R3 to BW

    Hello Experts,
    I have a basic questions to ask,I am curious to know that how the data is transfered from a
    remote system (let say R3 or CRM) to BW system.Though i know that two systems
    make a RFC connections and make use of idocs.
    But if somebody can through more light on this and help me clear my doubts.
    Also case when the data is transfered with in BW.
    Thanx and Regards
    Priyanka

    Hi,
    Chek in teh follwoing PDF you will get some Idea.
    http://sap-idoc2edi-consulting.com/pdfFiles/EDI_IDoc_Overview.pdf
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/908836c3-7f97-2b10-4cb8-e6790361c152
    Thanks
    Reddy

Maybe you are looking for