Nested Type consisting another table type!

Hi,
How can I achieve below type declarations?
TYPES:BEGIN OF ty_scarr,
        carrid    TYPE scarr-carrid,
        carrname  TYPE scarr-carrname,
        currcode  TYPE scarr-currcode,
      END OF ty_scarr,
      BEGIN OF ty_sflight,
        carrid TYPE sflight-carrid,
        connid TYPE sflight-connid,
        fldate TYPE sflight-fldate,
        price  TYPE sflight-price,
      END OF ty_sflight,
      tt_sflight TYPE STANDARD TABLE OF ty_sflight.
TYPES:BEGIN OF ty_result.
        INCLUDE TYPE ty_scarr.
        TYPES: sflight_tab TYPE tt_sflight,
      END OF ty_result.
The above results in syntax error however below one works:
TYPES:BEGIN OF ty_scarr,
        carrid    TYPE scarr-carrid,
        carrname  TYPE scarr-carrname,
        currcode  TYPE scarr-currcode,
      END OF ty_scarr,
      BEGIN OF ty_sflight,
        carrid TYPE sflight-carrid,
        connid TYPE sflight-connid,
        fldate TYPE sflight-fldate,
        price  TYPE sflight-price,
      END OF ty_sflight,
      tt_sflight TYPE ty_sflight OCCURS 0.
TYPES:BEGIN OF ty_result.
        INCLUDE TYPE ty_scarr.
        TYPES: sflight_tab TYPE tt_sflight,
      END OF ty_result.
Is there a way to achieve above without using "OCCURS 0" keyword as "OCCURS" keyword is not supported withing OO context?
Thanks!

Hello,
Which ABAP release are you working on?
When i use your code (on an ABAP 740 kernel) i get the following error message -
This is because the type is generic w.r.t the key. If you intend to use it in other types, you have to explicitly define the key for the table type.
Since I'm on ABAP release 740 so i can use the addition EMPTY KEY -
      tt_sflight TYPE STANDARD TABLE OF ty_sflight
                 WITH NON-UNIQUE EMPTY KEY.
If you are on previous releases i think you can use the addition DEFAULT KEY.
BR,
Suhas
PS - Further read: ABAP News for Release 7.40 - Internal Tables with Empty Key

Similar Messages

  • How to get the line type of a table type

    Hi,
      i want to indetify the line type of a table type dynamically in my program. how to do?
    For example:
    data: lv_ttype type type ROLLNAME value 'PRXCTRLTAB'.
    how to identify line type of lv_ttype in the program.
    Thanks,
    johnney.

    Hello Johnney,
    try like this...
    types: begin of ty_itab,
                matnr like mara-matnr,
                werks like marc-werks,
                maktx like makt-maktx,
              end of g_t_itab.
    data: g_t_itab type table of ty_itab.
    data: <b>wa_itab like line of g_t_itab.</b> " This is line type... so called work area.
    Reward If Helpful.
    Regards
    Sasidhar Reddy Matli.

  • Copy value of condition type to another condition type *Not Percentage*

    Hi SAP community!
    How can I copy the value of a condition type to another condition type in my pricing procedure?  The rules are that these conditions are not Percentage. The calculation type is Quantity for the two conditions.
    I want to copy the value of condition type PMIN (Minimum Price) to another Z condition type.
    Thank you all

    Hi Lakshmipathi;
    In fact, there are two Z conditions that I need to have with the same value of the PMIN. I 've maintained my pricing procedure this way:
    For the PMIN, the step is 320
    For the ZPV1, the step is 920 and I put in "From " field 320 and in the "To" field 320
    For the ZPV0, the steo is 925 and I put in "From " field 320  and in the "To" field 320
    But when I looked the Conditions Tab in the sales order there is no value copied to the Z conditions. 
    In order to do this, my Z conditions do not need an access sequence assigned, right?

  • How can i change a pdf file type to another file type

    how can i change a pdf file type to another file type

    You can copy the contents and paste it into a Word file. Just don't expect everything to transfer or to retain all of the formatting.

  • How to shift valuation class from one material type to another material type ?

    I have came across following weird scenario:
    We already created huge no.of materials of material type say ZABC with two valuation classes say 1100 and 1200(GL accounts for these VCs for different posting keys in OBYC settings are same). Account category reference for this material type is 0010.
    After that we created new material type say ZPQR  with new Account category reference 0025, and valuation class 1200 is linked with this ACR 0025. Because of this, valuation class 1200 disappeared from material type ZABC. In order to avoid inconsistency, we need to have valuation class 1200 linked with older material type i.e.ZABC.How we can do this ? What impacts must have happened in this period (from MM/FI) in the system, where valuation class get shifted from one material type(ZABC) to another material type(ZPQR)....please help us in this scenario.

    Thanks Sana,
    We are also looking for the solution provided by you i.e. reassign ACR 0010 to Valuation class 1200.
    Your are also correct in terms of  statement "config doesnt allow me to assign same valuation class to 2 different AREF (Account reference number/Account category reference).
    I wanted to know, what are the possible impacts in the system during this re-assignment of ACR to old material type ZABC.
    Regards,
    Sudarshan.

  • Populating 0-many complex type within another complex type

    I have a process that is returning 'Person' types. These contain much info, from which, for each person I need to add only 3 node values to a 'member' type within an 'event' type.
    The person types are all processed individually by separate user tasks.
    Is addChildNode() the thing to be using here? Possibly with addElement()? I've looked in JDev at the descriptions of these functions, but to be honest they just confuse me more... it's been a long day... :D
    Any help much appreciated,
    Dan

    If this Re: Joining two output tables in ONE table is for 7.2 still correct, the solution seems to be as there is no solution except handle it in the service itself

  • Auto fill as I type from another table? and more

    Hi!
    I´m new to Numbers
    I want to create a document where I can have all my Invoice records
    So I want to have a sheet (clients) where I can keep all my clients with their info (column A: names, column B: Address, column C: city, column D: code, column E: Company Name)
    Then in another sheet (could be a specific month, such as october) I want to put all the invoices I create in october, one by row, so I want to start typing the name and want to numbers automatically can fill it up with that especific client wich I´m typing along with all his other columns (B to E) so on with all other rows
    I need it to be specific because I don´t always work for all my clients
    Can it be done?
    Hope I explain myself
    Sorry for my bad english

    Alex,
    The LOOKUP function should work nicely here.
    Let's say that your client list table is named "Clients".
    Here's an approach:
    In Column B, write:=IFERROR(LOOKUP($A, Clients::$A, Clients::B), ".")
    Fill Across.
    Select the cells with expressions in Row 2 and Fill Down.
    As you add names, the other data will be broght in.
    Jerry

  • Question about changing a file type into another file type

    Hello. This isnt a java question but you guys have been so helpful in the past I hope its ok if I ask this question for a friend.
    How can I import a scriptware file into Screenwriter 2000, or change a .scw file into a .tag file?
    Anyone who can help thanks.

    I know nothing about scriptware or Screenwriter. But, my only advice is to see if Scriptware can export some other file type (not necessarily a .scw file) that Screenwriter can read. Sometimes, when I have two text editors whose native formats are incompatible (like opening a paper typed in a new version of Microsoft Word using an old version of WordPerfect or something), I save the file as an RTF file, rather than in the native format. Maybe something like that applies to your situation, too.
    Hope that helps.
    Jason

  • Data types in internal tables.

    Examples for LINE & KEY.

    Mithun,
    Internal Tables as Data Types
    Internal tables and structures are the two structured data types in ABAP. The data type of an internal table is fully specified by its line type, key, and table type.
    Line type
    The line type of an internal table can be any data type. The data type of an internal table is normally a structure. Each component of the structure is a column in the internal table. However, the line type may also be elementary or another internal table.
    Key
    The key identifies table rows. There are two kinds of key for internal tables - the standard key and a user-defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method.
    If a table has a structured line type, its default key consists of all of its non-numerical columns that are not references or themselves internal tables. If a table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty.
    The user-defined key can contain any columns of the internal table that are not references or themselves internal tables. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key.
    Pls. reward if useful

  • Table type

    Hi,
       I dont know how to create table type through se11. what is line type. please help me.

    hi,
    Self-Defined Table Types
    You can start a screen sequence from an ABAP program using
    TYPES dtype TYPE|LIKE tabkind OF linetype [WITH key] ... .
    This defines an internal table type with access type tabkind, line type linetype and key key. The line type linetype can be any known data type. Specifying the key is optional. Internal tables can thus be generic.
    Internal Tables
    The syntax for declaring an internal table directly as a data type of a variable is the same as you would use to define one using the TYPES statement:
    DATA itab TYPE|LIKE tabkind OF linetype [WITH key] ... .
    The variable itabis declared as an internal table with access type tabkind, line type linetype, and key key. The line type linetype can be any known data type.
    For more information, refer to Internal Tables.
    Range Tables
    Using the statements:
    TYPES dtype {TYPE RANGE OF type}|{LIKE RANGE OF dobj} ... .
    DATA rtab {TYPE RANGE OF type}|{LIKE RANGE OF dobj} ... .
    you can define a special table type as a separate data type for Range tables, or as an attribute of the data object rtab of the type standard table, with a standard key and a specially structured line type.
    For more information on Range Tables see the keyword documentation.
    PROGRAM demo_internal_table.
    TYPES: BEGIN OF mytext,
             number TYPE i,
             name   TYPE c LENGTH 10,
           END OF mytext.
    TYPES mytab TYPE STANDARD TABLE OF mytext WITH DEFAULT KEY.
    DATA text TYPE mytext.
    DATA itab TYPE mytab.
    text-number = 1. text-name = 'John'.
    APPEND text TO itab.
    text-number = 2. text-name = 'Paul'.
    APPEND text TO itab.
    text-number = 3. text-name = 'Ringo'.
    APPEND text TO itab.
    text-number = 4. text-name = 'George'.
    APPEND text TO itab.
    LOOP AT itab INTO text.
      WRITE: / text-number, text-name.
    ENDLOOP.
    This program produces the following output on the screen:
    1  John
    2  Paul
    3  Ringo
    4  George
    In this example, first a data type mytext is defined as a structure. Then, a data type mytab is defined as an internal table with the line type mytext. The data objects text and itab  are declared with reference to the internal data types mytext und mytab. This lines of the internal table itab are generated dynamically with the APPEND statement. The contents of the internal table itab are written to the list using the structure text.
    Internal Tables
    Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.
    Data Type of an Internal Table
    The data type of an internal table is fully specified by its line type, key, and table type.
    Line Type
    The line type of an internal table can be any data type. The data type of an internal table is normally a structure. Each component of the structure is a column in the internal table. However, the line type may also be elementary or another internal table.
    Key
    The key identifies table rows. There are two kinds of key for internal tables - the standard key and a user-defined key. You can specify whether the key should be UNIQUE or NON-UNIQUE. Internal tables with a unique key cannot contain duplicate entries. The uniqueness depends on the table access method.
    At tables with structured row type, the standard key is formed from all character-type columns of the internal table. If a table has an elementary line type, the default key is the entire line. The default key of an internal table whose line type is an internal table, the default key is empty. At tables with non-structured row type, the standard key consists of the entire row. If the row type is also a table, an empty key is defined.
    The user-defined key can contain any columns of the internal table that are no internal table themselves, and do not contain internal tables. References are allowed as table keys. Internal tables with a user-defined key are called key tables. When you define the key, the sequence of the key fields is significant. You should remember this, for example, if you intend to sort the table according to the key.
    Table type
    The table type determines how ABAP will access individual table entries. Internal tables can be divided into three types:
    Standard tables have an internal linear index. From a particular size upwards, the indexes of internal tables are administered as trees. In this case, the index administration overhead increases in logarithmic and not linear relation to the number of lines. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. The key of a standard table is always non-unique. You cannot specify a unique key. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries.
    Sorted tables are always saved sorted by the key. They also have an internal index. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional to the number of table entries, since the system uses a binary search. The key of a sorted table can be either unique or non-unique. When you define the table, you must specify whether the key is to be UNIQUE or NON-UNIQUE. Standard tables and sorted tables are known generically as index tables.
    Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of table entries, and is constant, since the system access the table entries using a hash algorithm. The key of a hashed table must be unique. When you define the table, you must specify the key as UNIQUE.
    Generic Internal Tables
    Unlike other local data types in programs, you do not have to specify the data type of an internal table fully. Instead, you can specify a generic construction, that is, the key or key and line type of an internal table data type may remain unspecified. You can use generic internal tables to specify the types of field symbols  and the interface parameters of procedures . You cannot use them to declare data objects.
    Internal Tables as Dynamic Data Objects
    Internal tables are always completely specified regarding row type, key and access type. However, the number of lines is not fixed. Thus internal tables are dynamic data objects, since they can contain any number of lines of a particular type. The only restriction on the number of lines an internal table may contain are the limits of your system installation. The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes. A more realistic figure is up to 500 megabytes. An additional restriction for hashed tables is that they may not contain more than 2 million entries. The line types of internal tables can be any ABAP data types - elementary, structured, or internal tables. The individual lines of an internal table are called table lines or table entries. Each component of a structured line is called a column in the internal table.
    Choosing a Table Type
    The table type (and particularly the access method) that you will use depends on how the typical internal table operations will be most frequently executed.
    Standard tables
    This is the most appropriate type if you are going to address the individual table entries using the index. Index access is the quickest possible access. You should fill a standard table by appending lines (ABAP APPENDstatement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command). The access time for a standard table increases in a linear relationship with the number of table entries. If you need key access, standard tables are particularly useful if you can fill and process the table in separate steps. For example, you could fill the table by appending entries, and then sort it. If you use the binary search option (BINARY) with key access, the response time is logarithmically proportional to the number of table entries.
    Sorted tables
    This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERTstatement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHEREcondition.
    Hashed tables
    This is the most appropriate type for any table where the main operation is key access. You cannot access a hashed table using its index. The response time for key access remains constant, regardless of the number of table entries. Like database tables, hashed tables always have a unique key. Hashed tables are useful if you want to construct and use an internal table which resembles a database table or for processing large amounts of data.
    regards,
    sreelakshmi.

  • Reg: Creation of Table Types

    Hi All,
    I have a small question regaridng the creation of Table type.
    Let us suppose I am creating Table type for a custom table zsample which is having 5 fields. I am generally creating a structure similar to custom table and using that structure as line type for the table type. Let us suppose if there are any changes in the custom table like change in the order of fields or if new fields are added the table type will give dump.
    My question is If I use the custom table itself as a line type, will there be any effect in the performance or some thing or I can go ahead and use it..
    Thanks,
    Ravee

    What dump are you expecting ???
    It is idea behind the creation with reference to get structures and tables which always look like
    the tables they refer to.
    I can not see a possibilty for a dump as long as you create only an internal table.
    A dump could appear, if the internal table is later used to update another db-table. But there it should be clear that the structure of an internal should be created with reference to the tables which they change.
    Siegfried

  • Generic standard table type

    Anybody please resolve my doubt
    types tb_std_type type table of sflight.
    -->this i understand as not a generic table type.'NON-UNIQUE" and DEFAULT KEYS are implicity defined .
    data it_std type tb_std.-->Since i could declare an internal table of tb_std_type,i strongly belive tb_std_type is not a genric table type.
    But when i try to declare another type of same table type tb_std_type ie
    types tb2_type type tb_std_type.
    This is giving me an error saying\
    tb_std_type has a generic type.Use of this type is only possible for typing field symbols and  formal parameters.
    If thats true then how was i able to create a internal table  out of it...
    In case of sorted and hashed tables it behaves as exactly as it is defined.(Like if  generic,can only  be used for typing formal params.field symbold..and if non generic--internal tables declaration and normal typing is possible)
    Please resolve this
    *Would be great if could avoid a copy paste from std.help..because i have been through it..

    Hello Teenu,
    Query#1
    types tb2_type type tb_std_type.
    This is giving me an error saying\
    tb_std_type has a generic type.Use of this type is only possible for typing field symbols and formal parameters.
    Why is the table generic? An excerpt from SAP documentation clearly states that:
    An internal table that has no table key or an incomplete table key is generic with respect to the table key. A table type of this nature can be used only for typing formal parameters or field symbols.
    Query#2
    If thats true then how was i able to create a internal table out of it...
    SAP says:
    A standard table type with a generic primary table key can only be specified after TYPE when DATA is used.
    Source: [http://help.sap.com/abapdocu_70/en/ABAPTYPES_KEYDEF.htm|http://help.sap.com/abapdocu_70/en/ABAPTYPES_KEYDEF.htm]
    BR,
    Suhas

  • Information about Table Type

    Hi Guys,
    What does Table Type mean?
    What are uses of Table Type?
    Regards,
    Chandru

    Hi
    Analogous to the predefined ABAP types such as C or I , one may define user-defined types in the dictionary.
    The following user-defined types are allowed
    Data elements: Describe an elementary type by defining   the data type, length and possibly decimal places.
    Structures: Consist of components that can have any       type.
    Table types: Describe the structure of an internal table.
    Elaboration on the type categories.
    There are three different type categories in the ABAP Dictionary:
    Data elements (elementary types) Elementary types have no structure. They describe the data type attributes (such as given Dictionary data type, number of places) and information that is relevant for the screen (such as title) of unstructured data objects (variables/fields).
    Structures (structured types) Structured types describe the structure and functions of any structured data objects, that is of data structures with components of any type. A component can be a field with an elementary type or can itself be a structure. A table can also be used as a component in a structure. A database table always has a structure and is therefore implicitly a structured type. However, the fields of a database table can only have an elementary type.
    Table types Table types describe the structure and functions of internal tables in the ABAP program. Their rows can have any row type. Table types with elementary row type therefore can be defined just the same as multi-dimensional table types (table types with a table type as row type) or table types using structures with table-like components.
    Any complex user-defined type may be built using the
    previously mentioned basic types.

  • Create a Ranges Table Type

    I tried to create a Ranges Table Type as per SAP Help. It does get created,
    But the warning message occurs when create line type for this table type.
    I had been through standard help of Creating a Ranges Table Type:
    URL:
    http://help.sap.com/saphelp_47x200/helpdata/en/4f/991f82446d11d189700000e8322d00/frameset.htm)
    The warning message is as under:
    Field name OPTION is reserved (Do not use structure as include in DB table)
    I replaced this field with another name, then it asks for fieldname "OPTION".
    Your valuable suggestions please!

    Hi
    Just I said in my prevoius answer you can define a dictionary structure like this:
    FIELD     DATA ELEMENT    
    .INCLUDE  SRANGE
    LOW       MATNR
    HIGH      MATNR
    In this way you have a structure like the range R_MATNR, and you can use it to define your paramenter in TABLE PARAMETER of Function:
    FUNCTION ZTRANSFER_RANGES.
    ""Interfaccia locale:
    *"  TABLES
    *"      RMATNR STRUCTURE  ZMATNR
    DATA T_MARA LIKE STANDARD TABLE OF MARA.
    SELECT * FROM MARA INTO TABLE T_MARA WHERE MATNR IN RMATNR.
    ENDFUNCTION.
    But you can also define a table parameter without definition:
    FUNCTION ZTRANSFER_RANGES.
    ""Interfaccia locale:
    *"  TABLES
    *"      RMATNR
    DATA T_MARA LIKE STANDARD TABLE OF MARA.
    SELECT * FROM MARA INTO TABLE T_MARA WHERE MATNR IN RMATNR.
    ENDFUNCTION.
    Max

  • Dont work 'REUSE_ALV_FIELDCATALOG_MERGE' with table type

    Hi Experts ;
    My problem about   'REUSE_ALV_FIELDCATALOG_MERGE' .
    I use intarnal table with Table Type ( with header line ). And 'REUSE_ALV_FIELDCATALOG_MERGE'  is not working . Field catalog is employ. I dont use 'REUSE_ALV_FIELDCATALOG_MERGE' have any problem.

    'REUSE_ALV_FIELDCATALOG_MERGE' expects a flat structure.
    Give the reference of the line type of the table type if you wish to have fieldcatalog as per that..
    Even if you dont use 'REUSE_ALV_FIELDCATALOG_MERGE' you can create your own Fieldcatalog..

Maybe you are looking for