Declaration of itab

Hi
I had declared an internal table as follows
data: begin of itab_grid occurs 0,
      reswk like ekko-reswk,
      gdc_waers like ekko-waers,
      gdc_bsart like ekKO-bsart,
      gdc_bwtar like ekpo-bwtar, 
      gdc_matkl like mara-matkl, 
      gdc_wgbez like t023t-wgbez,
      gdc_sobsl like marc-sobsl,
      end of itab_grid.
Can I declare one more internal table as the above one like
data:itab1 like itab_gdc occurs 0 with header line.
or
is this the best way.
types: begin of itab_grid,
      reswk type ekko-reswk,
      gdc_waers type ekko-waers,
      gdc_bsart type ekKO-bsart,
      gdc_bwtar type ekpo-bwtar, 
      gdc_matkl type mara-matkl, 
      gdc_wgbez type t023t-wgbez,
      gdc_sobsl type marc-sobsl,
      end of itab_grid.
data:itab1 type itab_gdc occurs 0 with header line
data:itab2 type itab_gdc occurs 0 with header line
Thanks,
K.Kiran.

Internal tables are the core of ABAP. They are like soul of a body. For any program we use
internal tables extensively. We can use Internal tables like normal data base tables only, but the
basic difference is the memory allocated for internal tables is temporary. Once the program is
closed the memory allocated for internal tables will also be out of memory.
But while using the internal tables, there are many performance issues to be considered. i.e which
type of internal table to be used for the program..like standard internal table, hashed internal
table or sorted internal table etc..
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.
Like all elements in the ABAP type concept, internal tables can exist both as data types and as data objects A data type is the abstract
description of an internal table, either in a program or centrally in the ABAP Dictionary, that you use to create a concrete data object. The
data type is also an attribute of an existing data object.
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.
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 not. 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
Data objects that are defined either with the data type of an internal table, or directly as an internal table, are always fully defined in
respect of their line type, key and access method. 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 APPEND statement), 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 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 INSERT statement. 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 WHERE condition.
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.
Creating Internal Tables
Like other elements in the ABAP type concept, you can declare internal tables as abstract data
types in programs or in the ABAP Dictionary, and then use them to define data objects.
Alternatively, you can define them directly as data objects. When you create an internal table as a
data object, you should ensure that only the administration entry which belongs to an internal
table is declared statically. The minimum size of an internal table is 256 bytes. This is important if an
internal table occurs as a component of an aggregated data object, since even empty internal
tables within tables can lead to high memory usage. (In the next functional release, the size of the
table header for an initial table will be reduced to 8 bytes). Unlike all other ABAP data objects, you
do not have to specify the memory required for an internal table. Table rows are added to and
deleted from the table dynamically at runtime by the various statements for adding and deleting
records.
You can create internal tables in different types.
You can create standard internal table and then make it sort in side the program.
The same way you can change to hashed internal tables also.
There will be some performance issues with regard to standard internal tables/ hashed internal
tables/ sorted internal tables.
Internal table types
This section describes how to define internal tables locally in a program. You can also define internal tables globally as data types in the
ABAP Dictionary.
Like all local data types in programs , you define internal tables using the TYPES statement. If you do not refer to an existing table type
using the TYPE or LIKE addition, you can use the TYPES statement to construct a new local internal table in your program.
TYPES <t> TYPE|LIKE <tabkind> OF <linetype> [WITH <key>]
[INITIAL SIZE <n>].
After TYPE or LIKE, there is no reference to an existing data type. Instead, the type constructor occurs:
<tabkind> OF <linetype> [WITH <key>]
The type constructor defines the table type <tabkind>, the line type <linetype>, and the key <key> of the internal table <t>.
You can, if you wish, allocate an initial amount of memory to the internal table using the INITIAL SIZE addition.
Table type
You can specify the table type <tabkind> as follows:
Generic table types
INDEX TABLE
For creating a generic table type with index access.
ANY TABLE
For creating a fully-generic table type.
Data types defined using generic types can currently only be used for field symbols and for interface parameters in procedures . The generic
type INDEX TABLE includes standard tables and sorted tables. These are the two table types for which index access is allowed. You cannot
pass hashed tables to field symbols or interface parameters defined in this way. The generic type ANY TABLE can represent any table. You
can pass tables of all three types to field symbols and interface parameters defined in this way. However, these field symbols and
parameters will then only allow operations that are possible for all tables, that is, index operations are not allowed.
Fully-Specified Table Types
STANDARD TABLE or TABLE
For creating standard tables.
SORTED TABLE
For creating sorted tables.
HASHED TABLE
For creating hashed tables.
Fully-specified table types determine how the system will access the entries in the table in key operations. It uses a linear search for
standard tables, a binary search for sorted tables, and a search using a hash algorithm for hashed tables.
Line type
For the line type <linetype>, you can specify:
Any data type if you are using the TYPE addition. This can be a predefined ABAP type, a local type in the program, or a data type from the
ABAP Dictionary. If you specify any of the generic elementary types C, N, P, or X, any attributes that you fail to specify (field length, number
of decimal places) are automatically filled with the default values. You cannot specify any other generic types.
Any data object recognized within the program at that point if you are using the LIKE addition. The line type adopts the fully-specified data
type of the data object to which you refer. Except for within classes, you can still use the LIKE addition to refer to database tables and
structures in the ABAP Dictionary (for compatibility reasons).
All of the lines in the internal table have the fully-specified technical attributes of the specified data type.
Key
You can specify the key <key> of an internal table as follows:
[UNIQUE|NON-UNIQUE] KEY <col1> ... <col n>
In tables with a structured line type, all of the components <coli> belong to the key as long as they are not internal tables or references,
and do not contain internal tables or references. Key fields can be nested structures. The substructures are expanded component by
component when you access the table using the key. The system follows the sequence of the key fields.
[UNIQUE|NON-UNIQUE] KEY TABLE LINE
If a table has an elementary line type (C, D, F, I, N, P, T, X), you can define the entire line as the key. If you try this for a table whose line
type is itself a table, a syntax error occurs. If a table has a structured line type, it is possible to specify the entire line as the key. However,
you should remember that this is often not suitable.
[UNIQUE|NON-UNIQUE] DEFAULT KEY
This declares the fields of the default key as the key fields. If the table has a structured line type, the default key contains all non-numeric
columns of the internal table that are not and do not contain references or internal tables. If the 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.
Specifying a key is optional. If you do not specify a key, the system defines a table type with an arbitrary key. You can only use this to
define the types of field symbols and the interface parameters of procedures . For exceptions, refer to Special Features of Standard Tables.
The optional additions UNIQUE or NON-UNIQUE determine whether the key is to be unique or non-unique, that is, whether the table can
accept duplicate entries. If you do not specify UNIQUE or NON-UNIQUE for the key, the table type is generic in this respect. As such, it can
only be used for specifying types. When you specify the table type simultaneously, you must note the following restrictions:
You cannot use the UNIQUE addition for standard tables. The system always generates the NON-UNIQUE addition automatically.
You must always specify the UNIQUE option when you create a hashed table.
Initial Memory Requirement
You can specify the initial amount of main memory assigned to an internal table object when you define the data type using the following
addition:
INITIAL SIZE <n>
This size does not belong to the data type of the internal table, and does not affect the type check. You can use the above addition to
reserve memory space for <n> table lines when you declare the table object.
When this initial area is full, the system makes twice as much extra space available up to a limit of 8KB. Further memory areas of 12KB each
are then allocated.
You can usually leave it to the system to work out the initial memory requirement. The first time you fill the table, little memory is used. The
space occupied, depending on the line width, is 16 <= <n> <= 100.
It only makes sense to specify a concrete value of <n> if you can specify a precise number of table entries when you create the table and
need to allocate exactly that amount of memory (exception: Appending table lines to ranked lists). This can be particularly important for
deep-structured internal tables where the inner table only has a few entries (less than 5, for example).
To avoid excessive requests for memory, large values of <n> are treated as follows: The largest possible value of <n> is 8KB divided by the
length of the line. If you specify a larger value of <n>, the system calculates a new value so that n times the line width is around 12KB.
Examples
TYPES: BEGIN OF LINE,
COLUMN1 TYPE I,
COLUMN2 TYPE I,
COLUMN3 TYPE I,
END OF LINE.
TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
The program defines a table type ITAB. It is a sorted table, with line type of the structure LINE and a unique key of the component
COLUMN1.
TYPES VECTOR TYPE HASHED TABLE OF I WITH UNIQUE KEY TABLE LINE.
TYPES: BEGIN OF LINE,
COLUMN1 TYPE I,
COLUMN2 TYPE I,
COLUMN3 TYPE I,
END OF LINE.
TYPES ITAB TYPE SORTED TABLE OF LINE WITH UNIQUE KEY COLUMN1.
TYPES: BEGIN OF DEEPLINE,
FIELD TYPE C,
TABLE1 TYPE VECTOR,
TABLE2 TYPE ITAB,
END OF DEEPLINE.
TYPES DEEPTABLE TYPE STANDARD TABLE OF DEEPLINE
WITH DEFAULT KEY.
The program defines a table type VECTOR with type hashed table, the elementary line type I and a unique key of the entire table line. The
second table type is the same as in the previous example. The structure DEEPLINE contains the internal table as a component. The table
type DEEPTABLE has the line type DEEPLINE. Therefore, the elements of this internal table are themselves internal tables. The key is the
default key - in this case the column FIELD. The key is non-unique, since the table is a standard table.
Internal table objects
Internal tables are dynamic variable data objects. Like all variables, you declare them using the DATA statement. You can also declare static
internal tables in procedures using the STATICS statement, and static internal tables in classes using the CLASS-DATA statement. This
description is restricted to the DATA statement. However, it applies equally to the STATICS and CLASS-DATA statements.
Reference to Declared Internal Table Types
Like all other data objects, you can declare internal table objects using the LIKE or TYPE addition of the DATA statement.
DATA <itab> TYPE <type>|LIKE <obj> [WITH HEADER LINE].
Here, the LIKE addition refers to an existing table object in the same program. The TYPE addition can refer to an internal type in the
program declared using the TYPES statement, or a table type in the ABAP Dictionary.
You must ensure that you only refer to tables that are fully typed. Referring to generic table types (ANY TABLE, INDEX TABLE) or not
specifying the key fully is not allowed (for exceptions, refer to Special Features of Standard Tables).
The optional addition WITH HEADER line declares an extra data object with the same name and line type as the internal table. This data
object is known as the header line of the internal table. You use it as a work area when working with the internal table (see Using the
Header Line as a Work Area). When you use internal tables with header lines, you must remember that the header line and the body of the
table have the same name. If you have an internal table with header line and you want to address the body of the table, you must indicate
this by placing brackets after the table name (<itab>[]). Otherwise, ABAP interprets the name as the name of the header line and not of the
body of the table. You can avoid this potential confusion by using internal tables without header lines. In particular, internal tables nested
in structures or other internal tables must not have a header line, since this can lead to ambiguous expressions.
TYPES VECTOR TYPE SORTED TABLE OF I WITH UNIQUE KEY TABLE LINE.
DATA: ITAB TYPE VECTOR,
JTAB LIKE ITAB WITH HEADER LINE.
MOVE ITAB TO JTAB. <- Syntax error!
MOVE ITAB TO JTAB[].
The table object ITAB is created with reference to the table type VECTOR. The table object JTAB has the same data type as ITAB. JTAB also
has a header line. In the first MOVE statement, JTAB addresses the header line. Since this has the data type I, and the table type of ITAB
cannot be converted into an elementary type, the MOVE statement causes a syntax error. The second MOVE statement is correct, since
both operands are table objects.
Declaring New Internal Tables
You can use the DATA statement to construct new internal tables as well as using the LIKE or TYPE addition to refer to existing types or
objects. The table type that you construct does not exist in its own right; instead, it is only an attribute of the table object. You can refer to
it using the LIKE addition, but not using TYPE. The syntax for constructing a table object in the DATA statement is similar to that for defining
a table type in the TYPES statement.
DATA <itab> TYPE|LIKE <tabkind> OF <linetype> WITH <key>
[INITIAL SIZE <n>]
[WITH HEADER LINE].
As when you define a table type , the type constructor
<tabkind> OF <linetype> WITH <key>
defines the table type <tabkind>, the line type <linekind>, and the key <key> of the internal table <itab>. Since the technical attributes of
data objects are always fully specified, the table must be fully specified in the DATA statement. You cannot create generic table types (ANY
TABLE, INDEX TABLE), only fully-typed tables (STANDARD TABLE, SORTED TABLE, HASHED TABLE). You must also specify the key and whether
it is to be unique (for exceptions, refer to Special Features of Standard Tables).
As in the TYPES statement, you can, if you wish, allocate an initial amount of memory to the internal table using the INITIAL SIZE addition.
You can create an internal table with a header line using the WITH HEADER LINE addition. The header line is created under the same
conditions as apply when you refer to an existing table type.
DATA ITAB TYPE HASHED TABLE OF SPFLI
WITH UNIQUE KEY CARRID CONNID.
The table object ITAB has the type hashed table, a line type corresponding to the flat structure SPFLI from the ABAP Dictionary, and a
unique key with the key fields CARRID and CONNID. The internal table ITAB can be regarded as an internal template for the database table
SPFLI. It is therefore particularly suitable for working with data from this database table as long as you only access it using the key.

Similar Messages

  • Need ITAB declaration for type defined structure.

    Hi All,
              I have defined my ITAB as below
    TYPES: begin of ZRMCP1.
             INCLUDE TYPE RMCP1.
    TYPES: end of ZRMCP1.
    data:it_rmcp1 type table of ZRMCP1.
    data:wa_rmcp1 like line of it_rmcp1.
    When I am checking in Debugging my IT_RMCP1 is showing only first 7 fields.
    Tell me how to declare my ITAB for getting all the fileds.
    Thanks,
    Shiva.

    Old or new debugger?
    I just checked it, using your data declaration in the new debugger, and all columns are there. You do have to use the scroll bar at the bottom of the table control, or the 'arrow' icons |<, <, > and >| at the top of the table control.
    In the classic (old) debugger (if internal table has at least ONE entry), you can use the icons at top of the screen |<, <, > and >|, or use function code CTRLSHIFTF5 / F6 F7 or F8 to move back and forth.
    Edited by: Micky Oestreich on Jun 4, 2009 5:27 PM

  • Custome BAPI - declare ITAB and define the Function Module and Subroutine

    Hello Experts
    I want to create a Custom BAPI and it has the following scenario:
    1) a Function Module which collects some records into it internal table, say ITAB
    2) a Subroutine which moved the records from ITAB to BAPI table
    Now, I want to declare ITAB and define the Function Module and Subroutine.
    Where and How can I do this?
    Plz suggest.
    Regards
    BD

    Hi,
      1) Got to SE37 and create an RFC .
      2) Declare the ITAB directly in the TABLES tab of the FM.
      3) Inside the FM source Code tab, collect all the data using SELECT query and directly or by using logic, put the data into the
          ITAB.
      4) Since the data collected is directly put into the itab you dont need a subroutine to be written.
      5) If subroutine is a necessity, then just write PERFORM SUB ROUTINE NAME.
           AND DEFINE THE FORM ENDFORM OF THE SUBROUTINE AFTER THE ENDFUNCTION OF THE FM
       Let me know if any issues....
    Regards,
    Vimal.

  • Loop at itab in a Smarform problem

    Hi Guys,
    Right now i'm developing my first OO program that calls a Smartform, but I'm having the following issue.
    I call a method exporting the internal table that i want to pass to the SF, but when i want to make a loop statement in the SF I get a dump. I asked some friends and they told me that right now is obsolete the table statement, so i declare in the SF in the importing tab and then declare it in the exporting part of the FM that calls the SF.
    Now when i try to activate the SF i guet the following error: "You may only read from table "IT_GRID1". - reading.".
    so my question is, how can i declare my itab in order to be able to add a loop statement?.
    Regards,
    Eric

    Hi Subramanian,
    At first I did what you suggest, but for a reason that I can`t explain, when the loop begins I always get a dump. The only way that i could make the dump disappear was by replacing the name of the parameter that I receive from the method for the original table.
    Example:
    " I call the method in the main method.
           lcl_reporte_auditoria=>llamar_sf( EXPORTING
                                                               table = it_sf ).
      METHOD llamar_sf.
    *   Llamar al Formulario
        CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
          EXPORTING
            formname           = 'ZQM_RPT_AUDITORIA_LLANTA_VERDE'
          IMPORTING
            fm_name            = fm_name
          EXCEPTIONS
            no_form            = 1
            no_function_module = 2
            OTHERS             = 3.
    *¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*
    * CONFIGURO LOS OPARAMETROS DE SALIDA PARA Q NO APAREZACA       *
    * LA CAJA DE DIALOGO DE LA IMPRESION                            *
        wa_ssfctrlop-device     = 'PRINTER'.
        wa_ssfctrlop-langu      = sy-langu.
        wa_ssfctrlop-replangu1  = sy-langu.
        wa_ssfctrlop-replangu2  = sy-langu.
        wa_ssfctrlop-replangu3  = sy-langu.
        wa_ssfctrlop-no_dialog  = 'X'.      "SIN DIALOGO
        wa_ssfctrlop-preview    = 'X'.      "VISTA PREVIA
        wa_ssfcompop-tddest     = 'LOCL'.   "LOCAL AL PC
        wa_ssfcompop-tdimmed    = 'X'.      "IMPRESION IMEDIATA
        CALL FUNCTION fm_name
          EXPORTING
            control_parameters = wa_ssfctrlop
            output_options     = wa_ssfcompop
            user_settings      = ''
          TABLES
            it_grid1               = table
          EXCEPTIONS
            formatting_error   = 1
            internal_error     = 2
            send_error         = 3
            user_canceled      = 4
            OTHERS             = 5.
      ENDMETHOD.                    "llamar_sf
    In this case I get a dump as soon as the SF reach the loop statement. If I change the
    TABLES
    it_grid1 = table
    for
    TABLES
    it_grid1 = it_sf
    The dump doesn't appear anymore.
    The dump says: MOVE_TO_LIT_NOTALLOWED_NODATA
    Assignment error: Overwriting a protected field.
    At that moment a friend told me that the table statement was obsolete in OO programing, and encourage me to change it for a exporting parameter. This is the reason why i'm doing it, please anyone tell me is that affirmation is correct. Otherwise, could someone explain me why i'm getting that error when i export the table that i'm receiving in the method call.
    Regards,
    Eric
    Message was edited by:
            Eric Hernandez Pardo

  • Problem in uploading text file to itab

    Hi experts,
    I declared a itab with two fields which refers a a dB table fields.Then i created a excel file: In the firest column i placed entry for the first field
    and in the second column  i placed entry for the second field.Both fields i have taken from thatDB table.Then i saved that excel file as type text-tab delimited.Then i called GUI_UPLOAD.
    So when exicute my pgm i see the contents in the itab as follows:
    Field1          field2
    kv_sub_area0    004#descvription by ravikumar.
    But i should get like this:
    Field1            field2
    kv_sub_area0004   descvription by ravikumar.
    Why # is coming and it is taking some characters from field1 to filed2.
    I am using version 4.7 Actually field1 is of length 30 as per DB table.
    If i reduce the length in the itab declaration then it is giving corect..
    can any body tellme why this problem occurs?
    Regards

    in GUI_UPLOAD
    mention as
    FILE_TYPE = 'ASC'.
    HAS_FIELD_SEPERATOR = 'X'.
    if you provide the above both, i believe your problem will be solved.
    that '#' special symbol is for horizantal tab.
    regards
    srikanth
    Message was edited by: Srikanth Kidambi

  • ABAP program issues..Unicode program "ITAB" must have the same structure?

    Dear Expert,
    I coded below code in se38, but system give below error message, could please kindly advie issue reason? Thanks!!
         Error message: A line of "ITAB" and "LINE" are not mutually convertible. In a Unicode program "ITAB" must have the same structure layout as "LINE" independent of the length of a . Unicode character. Unicode character.          
    REPORT  ZTEST_HIHIHI.
    Data: begin of line,
    num type i,
    sqr type i,
    end of line,
    itab type standard table of line with key table_line.
    Do 5 times.
    line-num = sy-index.
    line-sqr = sy-index ** 2.
    append line to itab.
    enddo.
    loop at itab into line.
    write: / line-num, line-sqr.
    endloop.
    clear itab.

    Hello Hoo Laa,
    This is because the way you have defined LINE, it is a structure & not a data type. Hence you are facing the issue
    You have to change the data declaration to:
    itab LIKE STANDARD TABLE OF line WITH KEY table_line.
    BR,
    Suhas

  • Function module not showing my itab

    hi
    am working on smartforms  in se38 i declared an internal table it_regup after decalrations and select statements i went to smart forms i looped there and am displaying i called tht function moudule after calling SSF_FUNCTION_MODULE_NAME and in the i gave all the parameters and in tables it_regup = it_regup1 everything is fine .
       in the main program as i had to show multiple vendors i declared an itab for print options itab TYPE STANDARD TABLE OF pa0001
       and i declared it below the tables
                             it_regup = it_regup1
                               itab = itab
    as now i had done with the smartform  i want to transport it so before tht i want to declare the itab in smartforms global definitions so i declared tht there thinking it will come when i call the smartform so tht i can pass it in SE38 but only it_regup is comming the second one itab is not comming
    why? i already declared it in global definitions?
    thanks in advance
    cheers
    uday

    after activating that smartform, you need to call the smartform again in your program. It cannot get reflectedautomatically. Delete that small part of the code from the report and call the FM again after getting its value from SSF_FUNCTION_MODULE_NAME.
    This wud solve ur problem.
    Thanks
    Nayan

  • When we define itabs or global definitions

    at form interface of a smartform creating screen, are we required to use Line type, is not is possible to use a database table we have created?
    For example ZST table has been created as a db table and has data in it.
    If I want to print this data via a smartform, I have to declare an itab at form interface of the smartform and a work area at global definitions...
    How can I print these data?
    Do I need a loop or what other thing is required?
    I had headache because of this subject since 2 days.
    Please help.
    Deniz.

    hi deniz,
    FORM INTERFACE  -  is to pass variable,internal table etc from print program to  smartform so you cannot declare any thing until you are passing it in your print program.
    Print program will have one function module which will export several parameters,
    that can be imported to smart form by this form interface. you cant declare on ur own
    hope it will clear
    more please revert back.
    regards
    prabhu

  • Passing itab in a perform statement

    Hi Experts,
    In a Fucn Module, I need to write a perform statement and the corresponding FORM lies in an include. I need to pass an internal table(itab) & workarea(wa_itab) in perform as below :
    Declaration of itab:
    types: BEGIN OF ty_out1,
             f1(16) TYPE c,
             f2 TYPE wrbtr,
           END OF ty_out1.
    data : itab type standard table of ty_out1,
              wa_itab type ty_out1,
    PERFORM <form name> tables itab
      USING wa_itab
      test1.
    Dbl click on above perform takes us to an include prog and the form is declared as below -
    what should be the syntax of the FORM in INCLUDE statement.
    Note: I should not use the top include of the main prog for any declarations.
    form search_slash tables ptab2 like itab
                   using wa2_itab like wa_itab
                   test2 .
    Now what should be the syntax of the form above? Is the above right?
    Please suggest
    Thanks
    Dan

    Hi,
    If you want to pass only the internal table with header line,
    then use tables ptab2 structure wa2_itab
    For internal table with header line use:
    tables ptab2 like wa2_itab
    or
    tables ptab2[ ] like wa2_itab.
    Hope this helps.
    Reward if helpful.
    Regards,
    Sipra

  • Passing itabs in subroutines

    I cannot pass my itab to the subroutine pool within my program.
    Actually I can, but it does not respect the itab as one which has a structure. Even though I declare the itab LIKE BSEG (which has  a structure), the subroutines do not think the itab has a structure.
    TABLES: DD02T.
    DATA: itab_bseg LIKE BSEG occurs 10 WITH HEADER LINE.
    DATA: CODE(72) occurs 10,
    prog(8), MSG(120), LIN(3), WRD(10), OFF(3).
    DATA: STRING1(30), STRINGY(40), STRING2(30), PERIOD TYPE C.
    DATA: BUKRSVAL LIKE BSEG-BUKRS.
    DATA: COUNTER TYPE I.
    data: cond type string.
    DATA: TABNAME LIKE DD02T-TABNAME.
    DATA: FAIL, SUCCESS TYPE STRING.
    FIELD-SYMBOLS: <f1>, <f2>.
    refresh code.
    REFRESH ITAB_BSEG.
    * Main Routine *
    * Populating Internal Table
    * With Certain Records
    SELECT * APPENDING TABLE ITAB_BSEG FROM BSEG WHERE BUKRS = '2300' AND
    BELNR = '0100000000'.
    APPEND ITAB_BSEG.
    IF SY-SUBRC <> 0.
      WRITE:/ 'ERROR AT SELECTION'.
      EXIT.
    ENDIF.
    * Calling the subroutine that constructs
    * the dynamic condition for matching
    * {pool executes that conditions}
    * PERFORM dynamic_conditions USING itab_bseg.
    * FORM dynamic_conditions *
    * Form creates
    * FORM dynamic_conditions USING itab_bseg_two.
      LOOP AT ITAB_BSEG.
        MOVE: ITAB_BSEG-BUKRS TO BUKRSVAL.
        TABNAME = 'ITAB_BSEG'.
        CONCATENATE TABNAME
                    'BUKRS'
                    INTO COND.
        ASSIGN  cond TO <F1>.
        ASSIGN BUKRSVAL TO <F2>.
        APPEND 'PROGRAM SUBPOOL.'
           TO CODE.
        APPEND 'FORM DYN1 TABLES ITAB_BSEG.'
           TO CODE.
    *    STRING1 = '''' <F2> ''''.
        CONCATENATE
                 <F1>
                 'EQ'
                 '' <F2> ''
                 INTO STRINGY SEPARATED BY SPACE.
        CONCATENATE STRINGY
                    INTO STRING1.
        CONCATENATE 'IF'
                    STRING1
                    INTO STRING2 SEPARATED BY SPACE.
        APPEND STRING2 TO CODE.
        SUCCESS = 'SUCCESS'.
        FAIL = 'FAIL'.
        APPEND 'WRITE:/ SUCCESS.' TO CODE.
        APPEND 'ELSE.' TO CODE.
        APPEND 'WRITE: / FAIL.' TO CODE.
        APPEND 'ENDIF.' TO CODE.
        APPEND 'ENDFORM.' TO CODE.
        GENERATE SUBROUTINE POOL CODE NAME PROG
        MESSAGE MSG
        LINE LIN
        WORD WRD
        OFFSET OFF.
        IF SY-SUBRC <> 0.
          WRITE: /'Error during generation in line', LIN.
          WRITE:/ MSG.
          WRITE: /'Word:', WRD, 'at offset', OFF.
        ELSE.
          WRITE:/ 'The name of the subroutine pool is', PROG.
          SKIP.
          PERFORM DYN1 IN PROGRAM (PROG) TABLES itab_bseg.
        ENDIF.
      ENDLOOP.
    I've read through F1 and cannot figure out why. If you know why, please help.

    Howard, i ran your program, and inside the varible "CODE" you have this:
    PROGRAM SUBPOOL.
    FORM DYN1 TABLES ITAB_BSEG.
    IF ITAB_BSEG-BUKRS EQ  FI02.   "MY BURKS
    WRITE:/ SUCCESS.
    ELSE.
    WRITE: / FAIL.
    ENDIF.
    ENDFORM.
    I think you must declare inside "CODE" ITAB_BSEG too. Try this and let me know any response.
    Regards,
    Carlos Lerzundy
    Venezuela
    P.S: Sorry, i don't know why my reply was posted twice.
    Message was edited by: Carlos A. Lerzundy

  • Declaring a table like another table

    Hello,
    I am trying to define another table, say itab, that has the same structure as, say, EDISEGSTRU so that I can use it in the function call: SEGMENTDEFINITION_READ as a parameter for Tables. May I know how can I declare the itab? Thanks a lot!
    Regards,
    Anyi

    In order to reference a structure in the interface of a function module, the structure must be created in the data dictionary.  Check that your structure exists via SE11,  if so, then you can use it in the tables parameter section of your function module.
    <b>
    Parameter Name       Type Spec   Reference Type</b>
    name_of_table        LIKE        EDISEGSTRU     
    Regards,
    Rich Heilman

  • Itable declaration error

    hi all
    im jst tryin to  create a bsp page 
    i hve declare an itable in the page attributes  tab but even thn when i use tht itab in pgm i get an error lke it s neither specified under table nor defined as an itab
    where do i do the mistake
    help me

    Hi varalakshmi kannan,
       Please check the structure of the internal table.
    I think you have declared your itab like this...
    itab type ztablename.
    The above itab is a work area and not an table.
    In order to do this...
    You need to declare a structure in the type definition tab or a global structure(table type) in the se11.
    For creating a structure in the type definition tab...
    Check the below code...
    types: begin of struct1,
    columnname1 type datatype1
    columnname2 type datatype2
    columnname3 type datatype3
    end of struct1.
    columnname1, columnname2, columnname3 are your itab structure.
    Now you can use this structure in the page attributes tab like...
    itab type struct1.
    Hope it solves your problem.
    Regards,
    Maheswaran.B
    Message was edited by: Maheswaran B

  • " Can not interpret the data in file " error while uploading the data in DB

    Dear All ,
    After running the below report I am getting the " Can not interpret the data in file " error.
    Need to upload the data in DB through excel or .txt file.
    Kindly advise to resolve the issue.
    REPORT  ZTEST_4.
    data : it like ZPRINT_LOC occurs 0 with header line,
    FILETABLE type table of FILE_TABLE,
    wa_filetable like line of filetable,
    wa_filename type string,
    rc type i.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
    CHANGING
    FILE_TABLE = filetable
    RC = rc.
    IF SY-SUBRC = 0.
    read table filetable into wa_filetable index 1.
    move wa_filetable-FILENAME to wa_filename.
    Else.
    Write: / 'HI'.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    start-of-selection.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    FILENAME = wa_filename
    FILETYPE = 'ASC'
    HAS_FIELD_SEPARATOR = 'X'
    TABLES
    DATA_TAB = it.
    IF SY-SUBRC = 0.
    Write: / 'HI'.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    insert ZPRINT_LOC from table it.
    if sy-subrc = 0.
    commit work.
    else.
    rollback work.
    endif.
    Regards
    Machindra Patade
    Edited by: Machindra Patade on Apr 9, 2010 1:34 PM

    Dear dedeepya reddy,
    Not able to upload the excel but have sucess to upload the .csv file to db through the below code. Thanks for your advise.
    REPORT  ZTEST_3.
             internal table declaration
    DATA: itab TYPE STANDARD TABLE OF ZPRINT_LOC,
          wa LIKE LINE OF itab,
          wa1 like line of itab.
                       variable  declaration
    DATA: v_excel_string(2000) TYPE c,
           v_file LIKE v_excel_string VALUE    'C:\Documents and Settings\devadm\Desktop\test.csv',  " name of the file
            delimiter TYPE c VALUE ' '.         " delimiter with default value space
         read the file from the application server
      OPEN DATASET v_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc NE 0.
    write:/ 'error opening file'.
      ELSE.
        WHILE ( sy-subrc EQ 0 ).
          READ DATASET v_file INTO wa.
          IF NOT wa IS INITIAL.
            append wa TO itab.
          ENDIF.
          CLEAR wa.
        ENDWHILE.
      ENDIF.
    CLOSE DATASET v_file.
    EXEC SQL.
         TRUNCATE TABLE "ZPRINT_LOC"
    ENDEXEC.
    *------display the data from the internal table
    LOOP AT itab into wa1.
    WRITE:/ wa1-mandt,wa1-zloc_code,wa1-zloc_desc,wa1-zloc,wa1-zstate.
    ENDLOOP.
    insert ZPRINT_LOC from table itab.

  • Look Up - Important

    Hello,
    I am loading data from a DSO to Cube. While i do this i have to pick up two fields from another look up DSO and fill these fileds in the Cube fields along with source DSO fields for each record which are same structure.
    I have written some code but not working. Please correct it.
    DATA: LT1_ZCCCHP09 TYPE _ty_t_tg_1,  ( These are internal tables and work areas of result_package which is cube )
             LT2_ZCCCHP09 TYPE _ty_t_tg_1,
             LS1_ZCCCHP09 TYPE _ty_s_tg_1,
             LS2_ZCCCHP09 TYPE _ty_s_tg_1,
             /BIC/ZCCCHP205 TYPE /BIC/OIZCCCHP205.
       LT1_ZCCCHP09 = RESULT_PACKAGE.
       CLEAR: RESULT_PACKAGE[].
           LOOP AT LT1_ZCCCHP09 INTO LS1_ZCCCHP09.
           SELECT single /BIC/ZCCCHP205 /BIC/ZCCCHP206 /BIC/ZCCCHP207
          /BIC/ZCCCHP208 /BIC/ZCCCHP209 /BIC/ZCCCHP210 /BIC/ZCRCHA094
          /BIC/ZCRCHA089
               /BIC/ZCRCHA093 /BIC/ZCRCHA090 /BIC/ZCRCHA091 /BIC/ZPDCHA058
               /BIC/ZPDCHA061 /BIC/ZCCCHP211 /BIC/ZCCCHP212 ( Fields to be picked up from look up DSO /BIC/AZCCCHP0900 )
        FROM /BIC/AZCCCHP0900 INTO CORRESPONDING FIELDS OF  LS2_ZCCCHP09
        WHERE /BIC/ZCCCHP200 = LS1_ZCCCHP09-/BIC/ZCCCHP200.
             IF SY-SUBRC = 0.
             LS2_ZCCCHP09-/bic/ZCCCHP201 = LS1_ZCCCHP09-/bic/ZCCCHP201. ( These fields are source DSO fields to be filled along with above fields in each record )
             LS2_ZCCCHP09-/bic/ZCCCHP202 = LS1_ZCCCHP09-/bic/ZCCCHP202.
             LS2_ZCCCHP09-/bic/ZPDCHA077 = LS1_ZCCCHP09-/bic/ZPDCHA077.
             LS2_ZCCCHP09-/bic/ZCCCHP204 = LS1_ZCCCHP09-/bic/ZCCCHP204.
              LS2_ZCCCHP09-/bic/ZCCCHP203 = LS1_ZCCCHP09-/bic/ZCCCHP203.
              LS2_ZCCCHP09-/bic/ZCCCHP213 = LS1_ZCCCHP09-/bic/ZCCCHP213.
              LS2_ZCCCHP09-/bic/ZCCCHP214 = LS1_ZCCCHP09-/bic/ZCCCHP214.
              LS2_ZCCCHP09-/bic/ZCCCHP215 = LS1_ZCCCHP09-/bic/ZCCCHP215.
              LS2_ZCCCHP09-/bic/ZCCCHP216 = LS1_ZCCCHP09-/bic/ZCCCHP216.
              LS2_ZCCCHP09-/bic/ZCCCHP217 = LS1_ZCCCHP09-/bic/ZCCCHP217.
              LS2_ZCCCHP09-/bic/ZCCCHP218 = LS1_ZCCCHP09-/bic/ZCCCHP218.
             APPEND LS1_ZCCCHP09 TO RESULT_PACKAGE.
             ELSEIF
             SY-SUBRC NE 0.
             CONTINUE.
       ENDIF.
      ENDLOOP.
      CLEAR: LS1_ZCCCHP09, LS2_ZCCCHP09.
      REFRESH LT1_ZCCCHP09[].
    Edited by: Syed786 on Dec 4, 2009 12:23 PM

    Hi,
    Try with following code.
    DATA: LT1_ZCCCHP09 like line of RESULT_PACKAGE,  ( These are internal tables and work areas of result_package which is cube )
             LT2_ZCCCHP09 like line of RESULT_PACKAGE,
             LS2_ZCCCHP09 like line of RESULT_PACKAGE,
             /BIC/ZCCCHP205 TYPE /BIC/OIZCCCHP205.
    DATA: Declare  LS1_ZCCCHP09 itab with required fileds.
       if NOT RESULT_PACKAGE IS INITIAL.
           SELECT single /BIC/ZCCCHP205 /BIC/ZCCCHP206 /BIC/ZCCCHP207
          /BIC/ZCCCHP208 /BIC/ZCCCHP209 /BIC/ZCCCHP210 /BIC/ZCRCHA094
          /BIC/ZCRCHA089
               /BIC/ZCRCHA093 /BIC/ZCRCHA090 /BIC/ZCRCHA091 /BIC/ZPDCHA058
               /BIC/ZPDCHA061 /BIC/ZCCCHP211 /BIC/ZCCCHP212 ( Fields to be picked up from look up DSO /BIC/AZCCCHP0900 )
        FROM /BIC/AZCCCHP0900 INTO CORRESPONDING FIELDS OF  LS1_ZCCCHP09
        WHERE /BIC/ZCCCHP200 = LS1_ZCCCHP09-/BIC/ZCCCHP200.
    endif.
    loop at RESULT_PACKAGE into LS2_ZCCCHP09.
    read table LS1_ZCCCHP09 with key (give key filed names here).
             IF SY-SUBRC = 0.
             LS2_ZCCCHP09-/bic/ZCCCHP201 = LS1_ZCCCHP09-/bic/ZCCCHP201. ( These fields are source DSO fields to be filled along with above fields in each record )
             LS2_ZCCCHP09-/bic/ZCCCHP202 = LS1_ZCCCHP09-/bic/ZCCCHP202.
             LS2_ZCCCHP09-/bic/ZPDCHA077 = LS1_ZCCCHP09-/bic/ZPDCHA077.
             LS2_ZCCCHP09-/bic/ZCCCHP204 = LS1_ZCCCHP09-/bic/ZCCCHP204.
              LS2_ZCCCHP09-/bic/ZCCCHP203 = LS1_ZCCCHP09-/bic/ZCCCHP203.
              LS2_ZCCCHP09-/bic/ZCCCHP213 = LS1_ZCCCHP09-/bic/ZCCCHP213.
              LS2_ZCCCHP09-/bic/ZCCCHP214 = LS1_ZCCCHP09-/bic/ZCCCHP214.
              LS2_ZCCCHP09-/bic/ZCCCHP215 = LS1_ZCCCHP09-/bic/ZCCCHP215.
              LS2_ZCCCHP09-/bic/ZCCCHP216 = LS1_ZCCCHP09-/bic/ZCCCHP216.
              LS2_ZCCCHP09-/bic/ZCCCHP217 = LS1_ZCCCHP09-/bic/ZCCCHP217.
              LS2_ZCCCHP09-/bic/ZCCCHP218 = LS1_ZCCCHP09-/bic/ZCCCHP218.
             modify RESULT_PACKAGE from   LS2_ZCCCHP09.
             ELSEIF
             SY-SUBRC NE 0.
             CONTINUE.
       ENDIF.
      ENDLOOP.
      CLEAR: LS1_ZCCCHP09, LS2_ZCCCHP09.
      REFRESH LT1_ZCCCHP09[].

  • All Records not showing in Report

    Hi All,
    U just solved my amount problem....
    But now i gives my earlier problem again, means displaying only 1 rows, when i executing for 1 month in selection criteria...and amount showing right total of all records...
    example---
    Document No......Doc. date.......P.date........Vendor..........Name.........Tax Code.........Base Amt....... Tax Amt........Ven. Ref.........P. Doc...
    5500000022 .......22.04.2008 ...28.04.2008....1011............XXXXXXX........NB..................500,000............25,000.............A-102.......4500034463
    This Document No. is my 1st Document no. (5500000022)..
    Here Base Amount (500,000) & Tax Amount (25,000) is the total of more than 100 records total but showing in Single Row...(This rows showing the only 1st record)...
    Here what is the problem in my program...where i m wrong in clearing the itab or itab2...
    please let me know...
    I m again sending my corrected Program...
    Code-----
    REPORT  zak_form_c4 NO STANDARD PAGE HEADING LINE-SIZE 125  .
    TABLES : bsik,bkpf,bseg,j_1imovend,lfa1,t001,t005u,bsak,ekko,bsis, ekkn, anla, anlc.
    TYPE-POOLS : slis.
    DATA : BEGIN OF itab OCCURS 0,
           hkont LIKE bseg-hkont, "Gl account
           mwskz LIKE bseg-mwskz, "Tax Code
           dmbtr LIKE bseg-dmbtr, "Amount
           buzei LIKE bseg-buzei, "line item
           ebeln LIKE bseg-ebeln, "Purchasing Document
           ebelp LIKE bseg-ebelp, "line item nbr
           hwbas LIKE bseg-hwbas, "Base amount
           shkzg LIKE bseg-shkzg, "Debit/Credit code
           belnr LIKE bsik-belnr, "Document number
           gjahr LIKE bsik-gjahr, "Fiscal Year
           bldat LIKE bsik-bldat, "Document Date
           budat LIKE bsik-budat, "Posting Date
           lifnr LIKE bsik-lifnr, "Vendor number
           xblnr LIKE mkpf-xblnr, "Ven invoice nbr
           name1(25),                                           "name1
           ort01 LIKE lfa1-ort01,   "City
           j_1ilstno LIKE j_1imovend-j_1ilstno,  " Vendor tin nbr
           regio LIKE lfa1-regio, "Region Code
           bezei LIKE t005u-bezei, "Region desc
           dmbtr1 LIKE bseg-dmbtr, "Amount
           hwbas1 LIKE bseg-hwbas, "Base amount
    END OF itab.
    DATA : BEGIN OF itab3 OCCURS 0.
            INCLUDE STRUCTURE itab.
    DATA:END OF itab3.
    DATA : wa LIKE LINE OF itab.
    DATA : BEGIN OF itab1 OCCURS 0.
            INCLUDE STRUCTURE itab.
    DATA:END OF itab1.
    DATA : BEGIN OF itab2 OCCURS 0.
            INCLUDE STRUCTURE itab.
    DATA:END OF itab2.
    ***********************************Purchase order history
    DATA:   BEGIN OF bet OCCURS 50.
            INCLUDE STRUCTURE ekbe.
    DATA:   END OF bet.
    DATA:   BEGIN OF bzt OCCURS 50.
            INCLUDE STRUCTURE ekbz.
    DATA:   END OF bzt.
    DATA:   BEGIN OF betz OCCURS 50.
            INCLUDE STRUCTURE ekbez.
    DATA:   END OF betz.
    DATA:   BEGIN OF bets OCCURS 50.
            INCLUDE STRUCTURE ekbes.
    DATA:   END OF bets.
    DATA:   BEGIN OF xekbnk OCCURS 10.
            INCLUDE STRUCTURE ekbnk.
    DATA:   END OF xekbnk.
    DATA : w_container TYPE scrfname VALUE 'CL_GRID',
           w_cprog TYPE lvc_s_layo,
           g_repid LIKE sy-repid,
           w_save TYPE c,
           w_exit TYPE c,
           cl_grid TYPE REF TO cl_gui_alv_grid,
           cl_custom_container TYPE REF TO cl_gui_custom_container,
           it_fld_catalog TYPE slis_t_fieldcat_alv,
           wa_fld_catalog TYPE slis_t_fieldcat_alv WITH HEADER LINE ,
           layout TYPE slis_layout_alv,
           col_pos  LIKE sy-cucol ,
           alvfc TYPE slis_t_fieldcat_alv.
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS       :  hkont LIKE bseg-hkont OBLIGATORY. "GL Code
    *SELECT-OPTIONS   : hkont FOR bseg-hkont .
    SELECT-OPTIONS   : belnr FOR bsik-belnr .
    SELECT-OPTIONS   : gjahr FOR bsik-gjahr .
    SELECT-OPTIONS   : bldat FOR bsik-bldat.
    SELECT-OPTIONS   : budat FOR bsik-budat.
    SELECTION-SCREEN : END OF BLOCK b1.
    PERFORM fill_catalog1 USING:
    'HKONT'    'ITAB2'    'G/L Code' ,
    'BELNR'    'ITAB2'    'Document Number',
    'GJAHR'    'ITAB2'    'Year',
    'BLDAT'    'ITAB2'    'Doc. date' ,
    'BUDAT'    'ITAB2'    'Posting Date',
    'LIFNR'    'ITAB2'    'Vendor',
    'NAME1'    'ITAB2'    'Name',
    'EBELN'    'ITAB2'    'Purchasing Document',
    'MWSKZ'    'ITAB2'    'Tax Code',
    'HWBAS'    'ITAB2'    'Base Amount',
    'DMBTR'    'ITAB2'    'Tax Amount',
    'XBLNR'    'ITAB2'    'Vendor Inv. No.'.
    SELECT DISTINCT hkont belnr gjahr bldat budat INTO CORRESPONDING FIELDS OF TABLE itab
                      FROM bsis
                      WHERE bukrs = '1000'
                      AND hkont = hkont
                      AND belnr IN belnr
                      AND gjahr IN gjahr
                      AND bldat IN bldat
                      AND budat IN budat.
    SORT itab BY belnr.
    LOOP AT itab.
      SELECT * FROM bseg WHERE belnr = itab-belnr  AND gjahr = itab-gjahr
                                                   AND bukrs = '1000'
                                                   AND ( ebeln <> ' ' OR hkont = hkont ).
        IF sy-subrc = 0.
          itab-buzei = bseg-buzei.
          itab-mwskz = bseg-mwskz.
          IF bseg-ebeln <> ' '.
            itab-ebeln = bseg-ebeln.
            itab-ebelp = bseg-ebelp.
            MODIFY itab.
          ENDIF.
          IF bseg-hkont = hkont.
            itab-shkzg = bseg-shkzg.
            itab-hwbas = bseg-hwbas.
            itab-dmbtr = bseg-dmbtr.
            IF itab-shkzg = 'H'.
              itab-dmbtr = itab-dmbtr * ( -1 ).
            ENDIF.
            MOVE-CORRESPONDING itab TO itab2.
            APPEND itab2.
          ENDIF.
        ENDIF.
      ENDSELECT.
    ENDLOOP.
    LOOP AT itab2.
      SELECT SINGLE * FROM ekko WHERE ebeln = itab2-ebeln.
      IF sy-subrc = 0.
        itab2-lifnr = ekko-lifnr.
      ENDIF.
      CALL FUNCTION 'ME_READ_HISTORY'
        EXPORTING
          ebeln  = itab2-ebeln
          ebelp  = itab2-ebelp
          webre  = 'X'
        TABLES
          xekbe  = bet
          xekbz  = bzt
          xekbes = bets
          xekbez = betz
          xekbnk = xekbnk.
      itab2-xblnr = bet-xblnr.
      SELECT SINGLE * FROM lfa1 WHERE lifnr = itab2-lifnr.
      itab2-name1 = lfa1-name1.
      itab2-ort01 = lfa1-ort01.
      itab2-regio = lfa1-regio.
      SELECT SINGLE * FROM t005u WHERE bland = itab2-regio
                                  AND spras = 'EN'
                                  AND land1 = 'IN'.
      itab2-bezei = t005u-bezei.
      SELECT SINGLE * FROM  j_1imovend WHERE lifnr = itab2-lifnr.
      IF sy-subrc = 0 .
        itab2-j_1ilstno = j_1imovend-j_1ilstno.  " Vendor tin nbr
      ENDIF.
      MODIFY itab2.
    ENDLOOP.
    SORT itab2 BY belnr.
    LOOP AT itab2.
      DATA : cnt TYPE i,
             cnt1 TYPE i.
      itab1-dmbtr1 = itab1-dmbtr1 + itab2-dmbtr.
      itab1-hwbas1 = itab1-hwbas1 + itab2-hwbas.
      AT END OF belnr.
        cnt = sy-tabix.
        cnt1 = cnt - 1.
        DO cnt1 TIMES.
          DELETE itab2.
        ENDDO.
        CLEAR itab2.
        itab2-dmbtr = itab1-dmbtr1.
        itab2-hwbas = itab1-hwbas1.
        MODIFY itab2 TRANSPORTING dmbtr hwbas .
      ENDAT.
    ENDLOOP.
    layout-zebra = 'X' .
    layout-colwidth_optimize(1) = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program = 'ZAK_FORM_C4'
        is_layout          = layout
        it_fieldcat        = it_fld_catalog
        i_default          = 'X'
        i_save             = 'A'
      TABLES
        t_outtab           = itab2
      EXCEPTIONS
        program_error      = 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.
    *&      Form  FILL_CATALOG1
          text
         -->P_FIELDNAME  text
         -->P_REF_TABLE  text
         -->P_SCRTEXT    text
    FORM fill_catalog1  USING   p_fieldname TYPE any
                                p_ref_table TYPE any
                                p_scrtext   TYPE any.
      CLEAR : wa_fld_catalog.
      wa_fld_catalog-fieldname  = p_fieldname.
      wa_fld_catalog-tabname    = p_ref_table.
      wa_fld_catalog-seltext_s  = p_scrtext.
      wa_fld_catalog-seltext_m  = p_scrtext.
      wa_fld_catalog-seltext_l  = p_scrtext.
    wa_fld_catalog-datatype = 'CURR'.
      wa_fld_catalog-outputlen = 20.
      APPEND wa_fld_catalog TO it_fld_catalog.
    ENDFORM.                    " fill_catalog1.
    Plz let me know...
    Thanks

    Hello Prince,
    I just want that my code will show single time records..and Sum of base Value and Tax amount...
    You want to summarise Base Value and Tax amount per document, right
    I am making a very very small modification to the declaration of ITAB:
    DATA :
    BEGIN OF itab OCCURS 0,
    belnr LIKE bsik-belnr, "Document number "--> Add here
    buzei LIKE bseg-buzei, "line item "--> Add here
    hkont LIKE bseg-hkont, "Gl account
    mwskz LIKE bseg-mwskz, "Tax Code
    dmbtr LIKE bseg-dmbtr, "Amount
    " buzei LIKE bseg-buzei, "line item "--> Delete Here
    ebeln LIKE bseg-ebeln, "Purchasing Document
    ebelp LIKE bseg-ebelp, "line item nbr
    hwbas LIKE bseg-hwbas, "Base amount
    shkzg LIKE bseg-shkzg, "Debit/Credit code
    " belnr LIKE bsik-belnr, "Document number "--> Delete here
    gjahr LIKE bsik-gjahr, "Fiscal Year
    bldat LIKE bsik-bldat, "Document Date
    budat LIKE bsik-budat, "Posting Date
    lifnr LIKE bsik-lifnr, "Vendor number
    xblnr LIKE mkpf-xblnr, "Ven invoice nbr
    name1(25), "name1
    ort01 LIKE lfa1-ort01, "City
    j_1ilstno LIKE j_1imovend-j_1ilstno, " Vendor tin nbr
    regio LIKE lfa1-regio, "Region Code
    bezei LIKE t005u-bezei, "Region desc
    dmbtr1 LIKE bseg-dmbtr, "Amount
    hwbas1 LIKE bseg-hwbas, "Base amount
    END OF itab.
    And modified the code as below:
    DATA:
    V_DMBTR TYPE DMBTR,
    V_HWBAS TYPE HWBAS.
    LOOP AT ITAB2.
      V_DMBTR = V_DMBTR + ITAB2-DMBTR.
      V_HWBAS = V_HWBAS + ITAB2-HWBAS.
      AT END OF BELNR.
        ITAB2-DMBTR = V_DMBTR.
        ITAB2-HWBAS = V_HWBAS.
        APPEND ITAB2 TO ITAB3.
        CLEAR: ITAB2, V_DMBTR, V_HWBAS.
      ENDAT.
    ENDLOOP.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = 'ZAK_FORM_C4'
    is_layout = layout
    it_fieldcat = it_fld_catalog
    i_default = 'X'
    i_save = 'A'
    TABLES
    t_outtab = itab3 "itab2 --> Use ITAB3 instead of ITAB2
    EXCEPTIONS
    program_error = 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.
    BR,
    Suhas
    Edited by: Suhas Saha on Jan 13, 2009 3:23 PM

Maybe you are looking for

  • RGB Only Prints in Black and White

    My Illustrator CS3 seems to have developed a strange problem.  If I create a new RGB based document, a 'Web Document' or a 'Basic RGB Document' for example, and the print it, I only get a black and white print.  If I create a CMYK based document it p

  • Why does Logic 9 not work with Snow Leopard?

    I have the basic system and it fails to load everytime.  Had to reinstall Leopard and lost all my prefs... very much a pain.  I don't understand why Apple makes updated operating systems and doesn't ensure that their own products are compatible.  App

  • Re: Error reverse engineering HFM with ODI 10.1.3.5

    Hi Experts, I'm new of ODI, I got any error message for ODI reverse data. I tried to do reverse in Financial Management model. I got an error messageas below. still get the same error message. Even i'm not able to see metadata in Model Folder., do yo

  • Runtime error "1101" invalid resource value.

    Hi there I am getting this error message "runtime error "1101"  invalid resource value" while I am trying to run my vba to populate my "Work" field. It was working fine for other files.But as soon as I started a new file with same columns and fields

  • Unable to open Illustrator CS6 in Mac OS X Yoesemite

    Hope somebody an help me here, every time I try to open Illustrator CS6 it will open almost to the point of being able to open a file but then closes and tells me there "Adobe Illustrator quit unexpectedly" It used o open no problem in an older versi