Skip to Content

SE24 help needed


I want to know how to declare an internal table which will be global for the class step by step.

I want to use this internal table and modify the values inside this at runtime using the methods.

Please tell me how to proceed further

Points for all helpful answers

Message was edited by:

Grame Smith

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Sep 05, 2007 at 07:38 PM

    Just create a table type in the Data Dictionary (SE11), then create an attribute of TYPE <createdtabletype>.


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 05, 2007 at 07:47 PM

    Hello Grame

    If you want to use the itab as <b>public </b>attribute or as parameter in public methods then you must use a table type that is defined either in the DDIC or within a type-pool.

    However, if the itab is a <b>private </b>attribute (yet still global within the class!) then you can define your own table type in the <i>local definitions</i> sections.



    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Grame Smith

      Hi Grame,

      Please see HELP link

      TYPE-POOLS <pool>.

      This statement allows you to use all the data types and constants defined in the type group <pool> in your program. You can use several type groups in the same program.

      Let the type group HKTST be created as follows in the ABAP Dictionary:

      TYPE-POOL hktst.

      TYPES: BEGIN OF hktst_typ1,

      col1(10) TYPE c,

      col2 TYPE i,

      END OF hktst_typ1.

      TYPES hktst_typ2 TYPE p DECIMALS 2.

      CONSTANTS hktst_eleven TYPE i VALUE 11.

      This type group defines two data types HKTST_TYP1 and HKTST_TYP2, as well as a constant HKTST_ELEVEN with the value 11.

      Any ABAP program can use this definition with the TYPE-POOLS statement:

      TYPE-POOLS hktst.

      DATA: dat1 TYPE hktst_typ1,

      dat2 TYPE hktst_typ2 VALUE '1.23'.

      WRITE: dat2, / hktst_eleven.

      The output is:



      The data types defined in the type group are used to declare data objects with the DATA statement and the value of the constant is, as the output shows, known in the program.


      Also read previous posting

      <b>type pools



  • author's profile photo Former Member
    Former Member
    Posted on Sep 06, 2007 at 09:22 AM

    If it's an INTERNAL table which doesn't imply persistence (i.e the data being stored / worked on isn't permanent) then a MUCH MUCH better idea is to use a Dynamic table even if you aren't going to use a GRID.

    For example in your application program code something like this


    TYPES: BEGIN OF s_elements,

    vbeln TYPE vapma-vbeln,

    posnr TYPE vapma-posnr,

    matnr TYPE vapma-matnr,

    kunnr TYPE vapma-kunnr,

    werks TYPE vapma-werks,

    vkorg TYPE vapma-vkorg,

    vkbur TYPE vapma-vkbur,

    status(5) TYPE c,

    END OF s_elements.

    DATA: my_line TYPE s_elements.

    CREATE OBJECT z_object EXPORTING z_object = z_object.

    CALL METHOD z_object->build_dynamic_structures


    my_line = my_line

    calling_program = sy-repid


    dy_table = dy_table


    it_fldcat = it_fldcat.

    in your class definition have these methods

    METHOD build_dynamic_structures.

    caller = calling_program.

    CALL METHOD me->return_structure


    my_line = my_line.

    CALL METHOD me->create_dynamic_fcat


    it_fldcat = it_fldcat.

    CALL METHOD me->create_dynamic_table


    it_fldcat = it_fldcat


    dy_table = dy_table.

    ENDMETHOD. "build_dynamic_structures

    METHOD return_structure.

    lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( my_line ).

    zogt[] = lr_rtti_struc->components.

    ENDMETHOD. "return_structure

    METHOD create_dynamic_fcat.

    LOOP AT zogt INTO zog.

    CLEAR wa_it_fldcat.

    wa_it_fldcat-fieldname = zog-name .

    wa_it_fldcat-dataTYPE = zog-TYPE_kind.

    wa_it_fldcat-intTYPE = zog-TYPE_kind.

    wa_it_fldcat-intlen = zog-length.

    wa_it_fldcat-decimals = zog-decimals.

    wa_it_fldcat-coltext = zog-name.

    wa_it_fldcat-lowercase = 'X'.

    case sy-tabix.

    When 2. "edit fields if using a grid --not necessary for standard pgm

    wa_it_fldcat-edit = 'X'.

    When 4.

    wa_it_fldcat-edit = 'X'.

    when 6.

    wa_it_fldcat-edit = 'X'.

    when others.

    wa_it_fldcat-edit = ' '.


    APPEND wa_it_fldcat TO it_fldcat .


    ENDMETHOD. "create_dynamic_fcat

    METHOD create_dynamic_table.

    CALL METHOD cl_alv_table_create=>create_dynamic_table


    it_fieldcatalog = it_fldcat


    ep_table = dy_table.

    Now fill you dynamic table with data

    for example

    FORM populate_dynamic_itab.

    ASSIGN dy_table->* TO <dyn_table>.

    CREATE DATA dy_line LIKE LINE OF <dyn_table>.

    ASSIGN dy_line->* TO <dyn_wa>.

    SELECT vbeln posnr matnr kunnr werks vkorg vkbur

    UP TO 200 rows

    FROM vapma


    In your data definition

    <dyn_table> TYPE STANDARD TABLE,

    <orig_table> TYPE STANDARD TABLE,

    <dyn_wa> TYPE ANY.

    Now this will be available both to the class / methods in the class AND your application program.

    Remember in OO you can't have tables with header lines anyway.

    I think the dynamic table approch works best for "non persistent" data and can be used with ANY structure whether in the ddic or not.

    <b>If you want to do it by the the standard method</b>

    Then proceed as follows

    In your class in the PUBLIC section (SE24)

    code something like this for your internal table structure


    begin of s_matord,

    matnr type vbap-matnr,

    arktx type vbap-arktx,

    kunnr type vapma-kunnr,

    vbeln type vapma-vbeln,

    posnr type vapma-posnr,

    audat type vapma-audat,

    auart type vapma-auart,

    kwmeng type vbap-kwmeng,

    vrkme type vbap-vrkme,

    netwr type vbap-netwr,

    end of s_matord .


    zmatord type standard table of s_matord .

    Now in a method where we want to use this table

    (method in the class is get_orders_for_material)

    set the parameters as follows

    Material (import) type vapma-matnr

    MATORD (export) type zmatord.

    now in your application program



    begin of s_matord,

    matnr type vbap-matnr,

    arktx type vbap-arktx,

    kunnr type vapma-kunnr,

    vbeln type vapma-vbeln,

    posnr type vapma-posnr,

    audat type vapma-audat,

    auart type vapma-auart,

    kwmeng type vbap-kwmeng,

    vrkme type vbap-vrkme,

    netwr type vbap-netwr,

    end of s_matord .

    DATA: matord type table of s_matord,

    obj type ref to zcl_sales_order. "Your class

    • Instantiate our Sales order from parameter

    create object obj exporting vbeln = p_vbeln.

    now when you call your method

    <b>call method obj->get_orders_for_material

    exporting material = p_matnr

    importing matord = matord.</b>

    Your data will be in matord. It doesn't have a header line but you can use a field symbol or xxxx[] = yyyy[] type of construct to read the table line by line.

    Here's the METHOD defined in the class


    data: t_matord type standard table of s_matord,

    l_matord type s_matord.

    select amatnr aauart avbeln aposnr aaudat akunnr

    barktx bkwmeng bvrkme bnetwr

    into corresponding fields of table t_matord

    from ( vapma as a

    inner join vbap as b

    on avbeln eq bvbeln

    and aposnr eq bposnr )

    where a~matnr eq material.

    matord[] = t_matord[].


    Works in reverse as well --the method can READ your table that you pass to it - you need to set of course correct export / import / changing parameters.

    In the method use the xxxx[] = yyyyy[] construct to get the data into a table.

    Don't make this stuff more complicated than you need. I often read posts in the OO forum where people seem to make a great problem out of what should be a fairly simple solution.

    Using this approach you don't have to worry about DDIC fields or type pools either.

    I prefer the Dynamic table approach myself as it's totally more general but the "Classical" way still works as shown above.



    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07, 2007 at 04:52 PM

    Thanks for the answers

    I found a good solution to my problem

    1. Either goto SE24 and create table types and declare them for your internal table type.

    2. Declare local structures in your table... then create a type table for it

    types: t_data type table of ts_data

    Then in the attributes give the type as t_data or Se12 created table type.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.