Types statement

Hi ABAP Experts,
  I have some doubt on declaring Internal tables, could you tell me which case  case1 or case 2  is correct.
Case1.
types: begin of t_kunnr,
           name1(30) type c,
           name2(30) type c,
           kunnr(10) type c,
       end of t_kunnr.
TYPES it_kunnr TYPE standard table of t_kunnr.
DATA: wa_kunnr TYPE t_kunnr.
DATA: it_kunnr type t_kunnr.
wa_kunnr-name1 = 'KK'.
wa_kunnr-name2 = 'MM'.
wa_kunnr-kunnr = '4999'.
append wa_kunnr to it_kunnr.
wa_kunnr-name1 = 'KK1'.
wa_kunnr-name2 = 'MM1'.
wa_kunnr-kunnr = '4999'.
append wa_kunnr to it_kunnr.
wa_kunnr-name1 = 'KK1'.
wa_kunnr-name2 = 'MM1'.
wa_kunnr-kunnr = '3999'.
append wa_kunnr to it_kunnr.
loop at it_kunnr into wa_kunnr.
  write : / wa_kunnr-name1, wa_kunnr-kunnr.
endloop.
case2
types: begin of t_kunnr,
           name1(30) type c,
           name2(30) type c,
           kunnr(10) type c,
       end of t_kunnr.
DATA: wa_kunnr TYPE t_kunnr,
           it_kunnr TYPE STANDARD TABLE OF t_kunnr.
wa_kunnr-name1 = 'KK'.
wa_kunnr-name2 = 'MM'.
wa_kunnr-kunnr = '4999'.
append wa_kunnr to it_kunnr.
wa_kunnr-name1 = 'KK1'.
wa_kunnr-name2 = 'MM1'.
wa_kunnr-kunnr = '4999'.
append wa_kunnr to it_kunnr.
wa_kunnr-name1 = 'KK1'.
wa_kunnr-name2 = 'MM1'.
wa_kunnr-kunnr = '3999'.
append wa_kunnr to it_kunnr.
loop at it_kunnr into wa_kunnr.
  write : / wa_kunnr-name1, wa_kunnr-kunnr.
endloop.
Thanks in advance.

Hi,
As everyone has said case 2 is the right way.
In Case1.
TYPES it_kunnr TYPE standard table of t_kunnr.
DATA: it_kunnr type t_kunnr.
these two statements are wrong.  First one rong because 'Types ' statement is used to decalre local program types, which only have a defenition and no related object in Data Base.  Data statement is used to create objects in DB of a specific type.
Second statement is wrong because it only creates a DB object of structure type and not table type.
As suggested u can use occurs 0 additions but this is obsolete and not advisable anymore. This is because occurs 0 creates a table with a header line and header line concept is obsolete.
The best practise is to declare the Type using TYPES statement and the decalring table of that type using  "type [STANDARD/HASHED/SORTED] table of " addition.

Similar Messages

  • Difference between DEclaring Itab with DATA & TYpe Statement?

    HI Friends,
      What is the Difference between Declaring Itab with DATA & TYpe Statement?

    Hi,
    The Statements TYPES and DATA
    Each ABAP program define its own data types using the statement.
    TYPES dtype TYPE type ...
    and declare its own variables or instance attributes of classes using the statement
    DATA var {TYPE type} ...
    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
    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.
    Reward Points if found helpfull..
    Cheers,
    Chandra Sekhar.

  • Regarding types statement in ECC 6.0...plz reply..urgent

    Hi,
    I am copying a program which is in<b> 4.7 to ECC 6.0,</b>i am facing error regarding <b>structures with types<b>...
    The following code in<b> 4.7</b>
    <b>DATA:BEGIN OF W_BMM00.
            INCLUDE STRUCTURE BMM00.
    DATA:END OF W_BMM00.
    DATA:BEGIN OF W_BMMH1.
            INCLUDE STRUCTURE BMMH1.
    DATA:END OF W_BMMH1.
    DATA:BEGIN OF W_BMMH7.
            INCLUDE STRUCTURE BMMH7.
    DATA:END OF W_BMMH7.
    DATA : BEGIN OF TAB_TLINE OCCURS 0.
            INCLUDE STRUCTURE TLINE.
    DATA : END OF TAB_TLINE.</b>
    i have written the same in <b>ECC6.0</b> as below
    <b>TYPES:BEGIN OF tw_bmm00.
            INCLUDE STRUCTURE bmm00.
    TYPES:END OF tw_bmm00 ,
          tt_bmm00 TYPE STANDARD TABLE OF tw_bmm00.
    TYPES:BEGIN OF tw_bmmh1.
            INCLUDE STRUCTURE bmmh1.
    TYPES:END OF tw_bmmh1 ,
              tt_bmmh1 TYPE STANDARD TABLE OF tw_bmmh1.
    TYPES:BEGIN OF tw_bmmh7.
            INCLUDE STRUCTURE bmmh7.
    TYPES:END OF tw_bmmh7 ,
          tt_bmmh7  TYPE STANDARD TABLE OF tw_bmmh7.
    TYPES:BEGIN OF tw_TAB_TLINE.
            INCLUDE STRUCTURE TLINE.
    TYPES:END OF tw_TAB_TLINE,
          tt_tab_tline TYPE STANDARD TABLE OF tw_tab_tline.
    lw_bmm00 TYPE tw_bmm00,
          lt_bmm00 TYPE tt_bmm00,
          lw_bmmh1 TYPE tw_bmmh1,
          lt_bmmh1 TYPE tt_bmmh1,
          lw_bmmh7 TYPE tw_bmmh7,
          lt_bmmh7 TYPE tt_bmmh7,
          lw_tab_thead TYPE tw_tab_thead,
          lt_tab_thead TYPE tt_tab_thead,</b>....
    when i check SLIN errors i am getting the following errors<b>...plz resolve</b>..
    <b>The current ABAP command is obsolete
    <b>Within classes and interfaces, you can only use "TYPE" to refer to ABAP Dictionary
    types (not "LIKE" or "STRUCTURE").</b></b>
    <b></b>

    include strture not allowed.
    rules.
    ABAP Development under Unicode
    Prior to Unicode the length of a character was exactly one byte, allowing implicit typecasts or memory-layout oriented programming. With Unicode this situation has changed: One character is no longer one byte, so that additional specifications have to be added to define the unit of measure for implicit or explicit references to (the length of) characters.
    Character-like data in ABAP are always represented with the UTF-16 - standard (also used in Java or other development tools like Microsoft's Visual Basic); but this format is not related to the encoding of the underlying database.
    A Unicode-enabled ABAP program (UP) is a program in which all Unicode checks are effective. Such a program returns the same results in a non-Unicode system (NUS) as in a Unicode system (US). In order to perform the relevant syntax checks, you must activate the Unicode flag in the screens of the program and class attributes.
    In a US, you can only execute programs for which the Unicode flag is set. In future, the Unicode flag must be set for all SAP programs to enable them to run on a US. If the Unicode flag is set for a program, the syntax is checked and the program executed according to the rules described in this document, regardless of whether the system is a US or a NUS. From now on, the Unicode flag must be set for all new programs and classes that are created.
    If the Unicode flag is not set, a program can only be executed in an NUS. The syntactical and semantic changes described below do not apply to such programs. However, you can use all language extensions that have been introduced in the process of the conversion to Unicode.
    As a result of the modifications and restrictions associated with the Unicode flag, programs are executed in both Unicode and non-Unicode systems with the same semantics to a large degree. In rare cases, however, differences may occur. Programs that are designed to run on both systems therefore need to be tested on both platforms.
    Other Changes
    1. Bit Statements
    2. Adding Field Sequences
    3. Loops with VARY and VARYING
    4. Creating Subroutines
    5. Saving Programs
    6. Assigning Types for GET/SET PARAMETER
    7. Unreachable Statements
    8. Function Modules with Incorrect Parameter Names
    1. Bit Statements
    Previously, the system checked for the bit statements SET BIT i OF f [TO g] and GET BIT i OF f [INTO g]whether the field f is character-type; X fields, X strings, and flat structures are usually regarded as character-type. For Unicode programs this is no longer useful, because the types X and XSTRING no longer count as character-type and the bit by bit access to character-type fields or structures is no longer platform-independent. Therefore, with these operations in Unicode programs, the field f must be type X or XSTRING.
    For the bit mask operations f O x, f Z x, and f M x you could previously use all number-type and hence all character-type types for the left operand f. In Unicode programs, the f operand must now be type X or XSTRING.
    2. Adding Field Sequences
    When adding field sequences, restrictions apply to the following statements in Unicode:
    ADD n1 THEN n2 UNTIL nz [ ACCORDING TO sel ] GIVING m ...
    ADD n1 THEN n2 UNTIL nz TO m [ RANGE str ].
    1. The operands n1, n2, and nz must be type-compatible with one another.
    2. The distance between nz and n1 must be an integral multiple of the distance between n2 and n1.
    3. A syntax or runtime error occurs if the fields n1, n2, and nz are not in a structure. This structure must be recognizable statically or its valid area must be marked explicitly using the RANGE addition.
    4. At runtime, the system ensures that the RANGE area is not left.
    ADD n1 FROM i1 GIVING m [ RANGE str ].
    1. Field n1 must be within the structure. The structure must be explicitly defined using the RANGE addition if it is not recognizable statically.
    2. For this variant, the system also checks at runtime whether n1 and the addressed values are within the structure.
    3. Loops
    Loops with the VARY or VARYING addition are also problematic in Unicode, since a type-a access to memory contents cannot be ensured and memory can be overwritten inadvertently.
    DO ... VARYING f FROM f1 NEXT f2.
    For this statement, the fields f, f1, and f2 must be type-compatible with each other. To prevent memory contents being overwritten, a RANGE for valid accesses is introduced implicitly or explicitly for the following statements:
    DO ... TIMES VARYING f FROM f1 NEXT f2 [ RANGE f3 ].
    WHILE ... VARY f FROM f1 NEXT f2 [ RANGE f3 ].
    A syntax or runtime error is caused if f1 or f2 are not included in f3. If the RANGE addition is missing, it is defined implicitly from FROM f1 NEXT f2 as follows:
    1. If both f1 and f2 are statically recognizable components of the same structure, the valid RANGE area is defined from the smallest structure that comprises f1 and f2.
    2. A syntax error is triggered if it is recognizable statically that f1 and f2 are not part of the same structure.
    3. A valid area must be defined explicitly using the RANGE addition if the connection between f1 and f2 is not recognizable statically.
    If you specify a deep structure as the RANGE addition, the system checks for every loop pass that there are no field references, object references, tables, or strings in the area read.
    4. Creating Subroutines
    When automatically generating subroutines using the statement GENERATE SUBROUTINE POOL itab NAME name, the generated program inherits the content of the Unicode flag of the generating program.
    5. Saving Programs
    When automatically generating programs using the statement INSERT REPORT prog FROM itab, default values are set for the TRDIR entry as before. Amongst other things, this statement has the new addition UNICODE ENABLING uc, with which the Unicode flag of the inserted report receives the value of uc. If this addition is missing, the following applies:
    1. A Unicode program creates a Unicode program.
    2. A non-Unicode program in turn creates a non-Unicode program.
    3. A non-Unicode program becomes a Unicode program if it is overwritten by a Unicode program.
    4. A Unicode program remains a Unicode program if it is overwritten by a non-Unicode program.
    6. Assigning Types for GET/SET PARAMETER
    For the statements GET PARAMETER ID pid FIELD f and GET PARAMETER ID pid FIELD f, f must be character-type. You can use the EXPORT and IMPORT statements for storing non-character-type fields and structures.
    7. Unreachable Statements
    In Unicode programs, unreachable statements cause a syntax error. In non-Unicode programs, there was previously only a syntax warning.
    8. Function Modules with Incorrect Parameter Names
    In Unicode programs, calling a function module, whose parameter names are specified statically as a literal or constant, causes an exception that can be handled if an incorrect parameter name was specified. This only applies to function modules that are not called via Remote Function Call. In non-Unicode programs, an incorrect name was previously ignored.
    http://service.sap.com/instguides
    --> SAP Business Suite Applications
    --> SAP ERP
    --> mySAP ERP 2005
    --> Upgrade
    --> Upgrade Documentation - mySAP ERP 2005 SR2
    There choose your database and operating system.
    If you're looking for functional details check
    http://service.sap.com/releasenotes

  • Difference between tables statement and by using type statement

    Hi all,
    I need to know the difference between the two of the below statements
    Tables spfli.
    and
    data spfli type spfli with header line.
    As far as i know both seem same to me.
    Thanks in advance,
    Bala.

    >
    Bala Shanmuga Priyan wrote:
    > Hi all,
    >
    > I need to know the difference between the two of the below statements
    >
    >
    Tables spfli.
    this will create a work area (spfli), looks like DB table spfli, but the statement is obsolate
    Bala Shanmuga Priyan wrote:
    >
    data spfli type spfli with header line.
    this will result in a syntax error, because this would also create a work area, but they cannot have header lines, so you should leave the WITH HEADER LINE addition.
    To create work area use:
    DATA : gw_spfli TYPE spfli.
    To create internal table:
    DATA : gt_spfli TYPE TABLE OF spfli.

  • Red TYPE statement in ABAP

    has anyone seen this format in ECC 5.0 ...
    TYPE pernr#TYPE pa0000-pernr. "Personnel number
    In the editor it is displayed in red.
    many thanks, john

    Wow,  you wouldn't think that you could use a reserved word in a macro def.  This really is not a good thing.  I'm with Neil,  it could be a macro.
    report zrich_0001.
    data: pernr#type(10) type c,
          pa0000-pernr type pa0000-pernr.
    define type.
    write:/ &1, &2.
    end-of-definition.
    pernr#type = 'This'.
    pa0000-pernr = '123456'.
    TYPE pernr#TYPE pa0000-pernr.
    Regards,
    Rich Heilman

  • TYPES statement in abap class to include structure

    hi ,
    i have declared following in a abap class...
    TYPES:
          zts_alv_line TYPE zmat_pr_costest_alv.
         TYPES:BEGIN OF ts_alv_line,
                include type zts_alv_line,
                matkl type mara-matkl,
                t023t type t023t-wgbez,
                lvorm type mara-lvorm,
                end of ts_alv_line.
         TYPES: tt_alv_data TYPE STANDARD TABLE OF ts_alv_line WITH DEFAULT KEY.
         DATA:
          alv_data TYPE tt_alv_data.
    now while refering to alv_data-matnr the sap is giving error that this component does not have matnr.
    please help.
    Edited by: Suhas Saha on Feb 3, 2012 1:11 PM

    TYPES: zts_alv_line TYPE zmat_pr_costest_alv.
    TYPES:BEGIN OF ts_alv_line,
                include type zts_alv_line,
                matkl type mara-matkl,
                t023t type t023t-wgbez,
                lvorm type mara-lvorm,
                end of ts_alv_line.
    Actually by defining this you've defined include as field of ts_alv_line. Actually ts_alv_line is a nested structure.
    I think you need to re-define the structure definition as:
    TYPES:BEGIN OF ts_alv_line.
          INCLUDE TYPE zts_alv_line.
    TYPES: matkl TYPE mara-matkl,
           t023t TYPE t023t-wgbez,
           lvorm TYPE mara-lvorm.
    TYPES: END OF ts_alv_line.
    BR,
    Suhas

  • Missing Return Type Statement...

    I'm currently working on a CodeLab assignment for my Intro to Programming class, and I keep running into the same error. I'll post the question here and show what I tried:
    Write the definition of a method twice , which receives an integer parameter and returns an integer that is twice the value of the parameter.
    And this is my code:
    public static int twice(int Total)
    Total = Total * 2;
    I'm sure that this is a very simple error, but I've tried a bunch of different ways that haven't worked. Thanks in advance.

    public static int twice(int Total)
    Total = Total * 2;
    }how about return Total; on the last line.

  • Difference b/w DATA TYPE and DATA OBJECT & differences b/w TYPE and LIKE

    hai
    can any one say the differences between Data type and Data Object.
    And also differences between TYPE and LIKE
    thanks
    Gani

    hi,
    _Data Types and Data Objects_
          Programs work with local program data – that is, with byte sequences in the working memory. Byte sequences that belong together are called fields and are characterized by a length, an identity (name), and – as a further attribute – by a data type. All programming languages have a concept that describes how the contents of a field are interpreted according to the data type.
          In the ABAP type concept, fields are called data objects. Each data object is thus an instance of an abstract data type. There are separate name spaces for data objects and data types. This means that a name can be the name of a data object as well as the name of a data type simultaneously.
    Data Types
       As well as occurring as attributes of a data object, data types can also be defined independently. You can then use them later on in conjunction with a data object. The definition of a user-defined data type is based on a set of predefined elementary data types. You can define data types either locally in the declaration part of a program using the TYPESstatement) or globally in the ABAP Dictionary. You can use your own data types to declare data objects or to check the types of parameters in generic operations.
         All programming languages distinguish between various types of data with various uses, such as ….. type data for storing or displaying values and numerical data for calculations. The attributes in question are described using data types. You can define, for example, how data is stored in the repository, and how the ABAP statements work with the data.
    Data types can be divided into elementary, reference, and complex types.
    a. Elementary Types
    These are data types of fixed or variable length that are not made up of other types.
    The difference between variable length data types and fixed length data types is that the length and the memory space required by data objects of variable length data types can change dynamically during runtime, and that these data types cannot be defined irreversibly while the data object is being declared.
    Predefined and User-Defined Elementary Data Types
    You can also define your own elementary data types in ABAP using the TYPES statement. You base these on the predefined data types. This determines all of the technical attributes of the new data type. For example, you could define a data type P_2 with two decimal places, based on the predefined data type P. You could then use this new type in your data declarations.
    b.  Reference Types
    Reference types are deep data types that describe reference variables, that is, data objects that contain references. A reference variable can be defined as a component of a complex data object such as a structure or internal table as well as a single field.
    c. Complex Data Types
    Complex data types are made up of other data types. A distinction is made here between structured types and table types.
    Data Objects
          Data objects are the physical units with which ABAP statements work at runtime. The contents of a data object occupy memory space in the program. ABAP statements access these contents by addressing the name of the data object and interpret them according to the data type.. For example, statements can write the contents of data objects in lists or in the database, they can pass them to and receive them from routines, they can change them by assigning new values, and they can compare them in logical expressions.
           Each ABAP data object has a set of technical attributes, which are fully defined at all times when an ABAP program is running (field length, number of decimal places, and data type). You declare data objects either statically in the declaration part of an ABAP program (the most important statement for this is DATA), or dynamically at runtime (for example, when you call procedures). As well as fields in the memory area of the program, the program also treats literals like data objects.
            A data object is a part of the repository whose content can be addressed and interpreted by the program. All data objects must be declared in the ABAP program and are not persistent, meaning that they only exist while the program is being executed. Before you can process persistent data (such as data from a database table or from a sequential file), you must read it into data objects first. Conversely, if you want to retain the contents of a data object beyond the end of the program, you must save it in a persistent form.
    Declaring Data Objects
          Apart from the interface parameters of procedures, you declare all of the data objects in an ABAP program or procedure in its declaration part. These declarative statements establish the data type of the object, along with any missing technical attributes. This takes place before the program is actually executed. The technical attributes can then be queried while the program is running.
         The interface parameters of procedures are generated as local data objects, but only when the procedure is actually called. You can define the technical attributes of the interface parameters in the procedure itself. If you do not, they adopt the attributes of the parameters from which they receive their values.
    ABAP contains the following kinds of data objects:
    a.  Literals
    Literals are not created by declarative statements. Instead, they exist in the program source code. Like all data objects, they have fixed technical attributes (field length, number of decimal places, data type), but no name. They are therefore referred to as unnamed data objects.
    b.  Named Data Objects
    Data objects that have a name that you can use to address the ABAP program are known as named objects. These can be objects of various types, including text symbols, variables and constants.
    Text symbols are pointers to texts in the text pool of the ABAP program. When the program starts, the corresponding data objects are generated from the texts stored in the text pool. They can be addressed using the name of the text symbol.
    Variables are data objects whose contents can be changed using ABAP statements. You declare variables using the DATA, CLASS-DATA, STATICS, PARAMETERS, SELECT-OPTIONS, and RANGESstatements.
    Constants are data objects whose contents cannot be changed. You declare constants using the CONSTANTSstatement.
    c.  Anonymous Data  Objects
    Data objects that cannot be addressed using a name are known as anonymous data objects. They are created using the CREATE DATAstatement and can be addressed using reference variables.
    d.  System-Defined Data Objects
    System-defined data objects do not have to be declared explicitly - they are always available at runtime.
    e.  Interface Work Areas
    Interface work areas are special variables that serve as interfaces between programs, screens, and logical databases. You declare interface work areas using the TABLES and NODESstatements.
    What is the difference between Type and Like?
    Answer1:
    TYPE, you assign datatype directly to the data object while declaring.
    LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.
    Answer2:
    Type is a keyword used to refer to a data type whereas Like is a keyword used to copy the existing properties of already existing data object.
    Answer3:
    type refers the existing data type
    like refers the existing data object
    reward if useful
    thanks and regards
    suma sailaja pvn

  • A type table as a row in a table

    The question is simple. Can I use a type table into a Z table ?? Any way to do this ??
    Thanks in advance.

    hi maraia,
    Structures
    A structure is a sequence of any other data types from the ABAP Dictionary, that is, data elements, structures, table types, or database tables. When you create a structure in the ABAP Dictionary, each component must have a name and a data type.
    In an ABAP program, you can use the TYPEaddition to refer directly to a structure.
    If you define a local data type in a program by referring to a structure as follows:
    TYPES dtype TYPE structure.
    the construction blueprint of the structure is used to create a local structure dtype in the program. The predefined Dictionary data types of the domains used by the data elements in the structure are converted into the corresponding ABAP types. The semantic attributes of the data elements are used for the corresponding components of the structure in the program. The components of the local structure dtype have the same names as those of the structure in the ABAP Dictionary.
    To ensure compatibility with previous releases, it is still possible to use the LIKE addition in an ABAP program to refer to a structure in the ABAP Dictionary (except in classes).
    Suppose the structure STRUCT is defined as follows in the ABAP Dictionary:
    Field name
    Type name
    Short Description
    COL1
    CHAR01
    Character field with length 1
    COL2
    CHAR08
    Character field with length 8
    COL3
    CHAR10
    Character field with length 10
    The types CHAR01 to CHAR10 are data elements with corresponding domains. We can refer to this structure in ABAP:
    TYPES struct_type TYPE struct.
    DATA wa TYPE struct_type.
    wa-col1 = '1'.
    wa-col2 = '12345678'.
    wa-col3 = '1234567890'.
    This program creates a local structure in the program - struct_type  - and a corresponding data object wa. We can address the components using the component names from the original structure.
    Table types
    Table types are construction blueprints for internal tables that are stored in the ABAP Dictionary. When you create a table type in the ABAP Dictionary, you specify the line type, access type, and key. The line type can be any data type from the ABAP Dictionary, that is, a data element, a structure, a table type, or the type of a database table. You can also enter a predefined Dictionary type directly as the line type, in the same way that you can with a domain.
    In an ABAP program, you can use the TYPEaddition to refer directly to a table type.
    If you define a local data type in a program by referring to a table type as follows:
    TYPES dtype TYPE table.
    the construction blueprint of the table type is used to create a local internal table dtype in the program. The predefined Dictionary data types of the domains used by the data elements in the structure are converted into the corresponding ABAP types. The semantic attributes of the data elements are used for the corresponding components of the internal table in the program.
    Suppose the table type STRUCT_TABLE is defined in the Dictionary with the line type STRUCT from the previous example. We can refer to this in ABAP:
    TYPES table_type TYPE struct_table.
    DATA: table_wa TYPE table_type,
          line_wa  LIKE LINE OF table_wa.
    LOOP AT table_wa INTO line_wa.
      WRITE: line_wa-col1, line_wa-col1, line_wa-col1.
    ENDLOOP.
    This program defines an internal table type table_type . From it, we define data objects table_wa and, consequently, line_wa. line_wa corresponds to the line type of the table type in the Dictionary, and is therefore compatible with the structure STRUCT
    Type Groups
    Before Release 4.5A, it was not possible to define standalone types in the ABAP Dictionary to which you could refer using a TYPEaddition in an ABAP program. It was only possible to refer to flat structures. Structures in programs corresponded to the structures of database tables or structures in the ABAP Dictionary. In ABAP programs, you could only refer to database tables and structures in the ABAP Dictionary using LIKE. It was, however, possible to refer to individual components of the Dictionary type. Complex local data types such as internal tables or deep structures had no equivalent in the ABAP Dictionary. The solution to this from Release 3.0 onwards was to use type groups. Type groups were based on the include technique, and allowed you to store any type definitions globally in the Dictionary by defining them using TYPES statements.
    The definition of a type group is a fragment of ABAP code which you enter in the ABAP Editor. The first statement for the type group pool is always:
    TYPE-POOL pool.
    After that, you define data types using the statement TYPES. It was also possible to define global constants using the CONSTANTS statement. All the names of these data types and constants must begin with the name of the type group and an underscore: pool_
    In an ABAP program, you must declare a type group as follows before you can use it:
    TYPE-POOLS pool.
    if you want complete info just click
    http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3138358411d1829f0000e829fbfe/content.htm
    thanks
    karthik
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 15, 2008 3:09 PM

  • Alter type in 8.1.7

    hi everyone.
    i'm using the alter type statement as seen in ora92 help to work with my types written and implemented in an 8.1.7 database and its retrieving an missing or invalid option error everytime. is there some difference between 8i and 9i statements I should be aware off before trying to alter types?
    Merci.-

    There's quite a lot of difference between the 8i syntax and the 9i syntax. So you may want to compare the docs closely.
    Cheers, APC

  • Function module to convert character type to required data type

    Hi,
    Is there a function module which can convert data in character type to any other required data type?
    Like i have a date 12.2.2008 and it is stored as character now i want to convert it into type d.
    so that when i use
    Describe field <field_name> type <type>.
    statement afterwards then it gives me  D not C as its data type.
    The requirement does'nt stick to conversion of just one data type.I need an FM which can convert data in character type to any data type.
    Hope you understood the problem.
    Thanks for your time.

    Hi,
    Use the code.
    data : date like sy-datum.
    call function 'CONVERT_DATE_TO_INTERNAL'
      exporting
        date_external                  =  '01.01.2008'
    IMPORTING
       DATE_INTERNAL                  = date
    EXCEPTIONS
       DATE_EXTERNAL_IS_INVALID       = 1
       OTHERS                         = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Regards,
    Morris Bond.
    Reward Points if Helpful.

  • Should Java introduce new primitive data types??

    In Java SE 5.0, many character- related methods (especially in the class Character) handle code points by using int type, i.e. return (code point) type is int, or receive (code point) int as parameter. This leads several problems. First, the variable used for storing returned result should be carefully stated, otherwise confusion may arise. Second, the parameters of method should be carefully ordered, otherwise conflict of method signature may meet.
    By those reasons, I suggest that Java should introduce new primitive data types for handling characters, they are:
    1. wchar
    this type states the variable stores 32-bit UNSIGNED integer, and it could be used to store either the code point, or the UTF-16 code of a character.
    2. ascii
    this type states the variable stores 8-bit UNSIGNED integer, and it could be used to store the code point of a elemental (ascii) character.

    short char, no. Nononono.
    No.
    wchar, I think I'd pref to see Java version 2 come
    out, and that be wchar by default, but that is not
    going to happen.
    I don't see a great need for it at this time.http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4504839
    Though I do not think that Java developer would like to change too much program code for using proposed (unsigned) primitive data types, I still believe that Java developer will eventually introduce these types, because it is not efficient to pretend signed integer to unsigned integer, and the success of a programming language is determined by how it can meet the programmers' need.

  • Data types and Data object

    Can Any one give me Clear definition of Data type and Data objects.
    Concept i know clearly.. but unable to explain it..
    Regards,
    Prasanna

    Data consists of strings of bytes in the memory area of the program. A string of related bytes is called a field. Each field has an identity (a name) and a data type. All programming languages have a concept that describes how the contents of a field are interpreted according to the data type.
             In the ABAP type concept, fields are called data objects. Each data object is an instance of an abstract data type. Data types in ABAP are not just attributes of fields, but can be defined in their own right. There are separate name spaces for data objects and data types. This means that a name can at the same time be the name of a data   object as well as the name of a data type.
    <b>Data Types:</b>
                     As well as occurring as attributes of a data object, data types can also be defined independently. The definition of a user-defined data type is based on a set of predefined elementary data types. You can define data types either locally in the declaration part of a program (using the TYPES statement) or globally in the ABAP Dictionary. You can use your own data types to declare data objects or to check the types of parameters in generic operations.
             Data types can be divided into elementary, reference, and complex types
    <b>Data objects:</b>
                      Data objects are the physical units with which ABAP statements work at runtime. Each ABAP data object has a set of technical attributes, which are fully defined at all times when an ABAP program is running. The technical attributes of a data object are its length, number of decimal places, and data type. ABAP statements work with the contents of data objects and interpret them according to their data type. You declare data objects either statically in the declaration part of an ABAP program (the most important statement for this is DATA), or dynamically at runtime (for example, when you call procedures). As well as fields in the memory area of the program, the program also treats literals like data objects.
    ABAP contains the following kinds of data objects
      Literals
       Named Data Objects
      Predefined Data Objects
      Dynamic Data Objects

  • Data type and Data object

    Hi Friends,
            What is the difference between Data type and Data object?
    Best Regards,
    VRV Singh

    hi
    good
    Each ABAP program define its own data types using the statement.
    TYPES dtype TYPE type ...
    and declare its own variables or instance attributes of classes using the statement
    DATA var {TYPE type} ...
    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
    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.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/content.htm
    thanks
    mrutyun^

  • Data types and data objects

    diff b/w data types and data objects

    hi prasanth,
    Data Types and Data Objects
    Programs work with local program data – that is, with byte sequences in the working memory. Byte sequences that belong together are called fields and are characterized by a length, an identity (name), and – as a further attribute – by a data type. All programming languages have a concept that describes how the contents of a field are interpreted according to the data type.
    In the ABAP type concept, fields are called data objects. Each data object is thus an instance of an abstract data type. There are separate name spaces for data objects and data types. This means that a name can be the name of a data object as well as the name of a data type simultaneously.
    Data Types
    Data types are templates for creating data objects. Data types can be defined independently in the ABAP program or in the ABAP Dictionary. As attributes of a data object, data types can also exist in a non-independent state. Data types do not use any memory space for work data, but may require memory for administration information.
    As well as occurring as attributes of a data object, data types can also be defined independently. You can then use them later on in conjunction with a data object. The definition of a user-defined data type is based on a set of predefined elementary data types. You can define data types either locally in the declaration part of a program using the TYPESstatement) or globally in the ABAP Dictionary. You can use your own data types to declare data objects or to check the types of parameters in generic operations.
    All programming languages distinguish between various types of data with various uses, such as ….. type data for storing or displaying values and numerical data for calculations. The attributes in question are described using data types. You can define, for example, how data is stored in the repository, and how the ABAP statements work with the data.
    Data types can be divided into elementary, reference, and complex types.
    a. Elementary Types
    These are data types of fixed or variable length that are not made up of other types.
    The difference between variable length data types and fixed length data types is that the length and the memory space required by data objects of variable length data types can change dynamically during runtime, and that these data types cannot be defined irreversibly while the data object is being declared.
    Predefined and User-Defined Elementary Data Types
    You can also define your own elementary data types in ABAP using the TYPES statement. You base these on the predefined data types. This determines all of the technical attributes of the new data type. For example, you could define a data type P_2 with two decimal places, based on the predefined data type P. You could then use this new type in your data declarations.
    b. Reference Types
    Reference types are deep data types that describe reference variables, that is, data objects that contain references. A reference variable can be defined as a component of a complex data object such as a structure or internal table as well as a single field.
    c. Complex Data Types
    Complex data types are made up of other data types. A distinction is made here between structured types and table types.
    Data Objects
    A data object is an instance of a data type and occupies as much memory space as its type specifies. An ABAP program only works with data that is available as content of data objects. Data objects are either created implicitly as named data objects, or exanonymous data objects using CREATEDATA.
    Data objects are the physical units with which ABAP statements work at runtime. The contents of a data object occupy memory space in the program. ABAP statements access these contents by addressing the name of the data object and interpret them according to the data type.. For example, statements can write the contents of data objects in lists or in the database, they can pass them to and receive them from routines, they can change them by assigning new values, and they can compare them in logical expressions.
    Each ABAP data object has a set of technical attributes, which are fully defined at all times when an ABAP program is running (field length, number of decimal places, and data type). You declare data objects either statically in the declaration part of an ABAP program (the most important statement for this is DATA), or dynamically at runtime (for example, when you call procedures). As well as fields in the memory area of the program, the program also treats literals like data objects.
    A data object is a part of the repository whose content can be addressed and interpreted by the program. All data objects must be declared in the ABAP program and are not persistent, meaning that they only exist while the program is being executed. Before you can process persistent data (such as data from a database table or from a sequential file), you must read it into data objects first. Conversely, if you want to retain the contents of a data object beyond the end of the program, you must save it in a persistent form.
    Declaring Data Objects
    Apart from the interface parameters of procedures, you declare all of the data objects in an ABAP program or procedure in its declaration part. These declarative statements establish the data type of the object, along with any missing technical attributes. This takes place before the program is actually executed. The technical attributes can then be queried while the program is running.
    The interface parameters of procedures are generated as local data objects, but only when the procedure is actually called. You can define the technical attributes of the interface parameters in the procedure itself. If you do not, they adopt the attributes of the parameters from which they receive their values.
    ABAP contains the following kinds of data objects:
    a. Literals
    Literals are not created by declarative statements. Instead, they exist in the program source code. Like all data objects, they have fixed technical attributes (field length, number of decimal places, data type), but no name. They are therefore referred to as unnamed data objects.
    b. Named Data Objects
    Data objects that have a name that you can use to address the ABAP program are known as named objects. These can be objects of various types, including text symbols, variables and constants.
    Text symbols are pointers to texts in the text pool of the ABAP program. When the program starts, the corresponding data objects are generated from the texts stored in the text pool. They can be addressed using the name of the text symbol.
    Variables are data objects whose contents can be changed using ABAP statements. You declare variables using the DATA, CLASS-DATA, STATICS, PARAMETERS, SELECT-OPTIONS, and RANGESstatements.
    Constants are data objects whose contents cannot be changed. You declare constants using the CONSTANTSstatement.
    c. Anonymous Data Objects
    Data objects that cannot be addressed using a name are known as anonymous data objects. They are created using the CREATE DATAstatement and can be addressed using reference variables.
    d. System-Defined Data Objects
    System-defined data objects do not have to be declared explicitly - they are always available at runtime.
    e. Interface Work Areas
    Interface work areas are special variables that serve as interfaces between programs, screens, and logical databases. You declare interface work areas using the TABLES and NODESstatements.
    regards,
    sravanthi

Maybe you are looking for

  • Submit...to Spool in background, ALV Grid

    Hello, I am trying to using the SUBMIT to SPOOL statement for SAP std. program RKPEP003. Now this works well when i execute in the foreground mode but doesnt work in the background mode, it gives an error "Make an Entry in All Required fields" RKPEP0

  • How to parse BEX Query data to Flex interface via XML

    Hi, How can we pass the Bex Query data in XML tabular format so it can be consumed by a Flex interface? And communicate back and forth. Regards Vivek

  • Reset admin password

    I'm using apex 4.0.1, I can't reset the admin password, I have tried ALTER USER ANONYMOUS ACCOUNT UNLOCK; apxchpwd.sql; apxxepwd.sql any help please? Thanks

  • Error #1009 !! Can't solve :(

    Hi, guys . I made an interactive movie ( or i'm making....) Check it out :http://mr-agu.deviantart.com/#/d2s1vfc The PROBLEM is that the Error #1009 comes up. Here is the actionscript I used. home_btn.addEventListener(MouseEvent.CLICK, home); functio

  • Problem with clone stamp

    Hi Problem with Photoshop CC on PC When I try to use clone stamp near the border of the picture it copies wrong area. It always take the border when I choose near the border. I try to do the same in my old copy of CS6 and there it worked properly on