About internal tables

can anybody please tell me
1. Please tell me How to retrieve data into INPUT/OUTPUT field.
For example.When u display a particular row from emp table.I want to display the row number ie SY-TFILL in the INPUT/OUTPUT field.i need it very urgently.?
2. 1. i have two internal tables. both tables which is having 5 records.
itab1 itab2
1 1
3 3
5 7
6 9
8 10.
i want to develop an report which is used to print the same data (1,3) in both tables.
in this only one time we are supposed to compare both internal tables?
tell me logic how we will do that?
2. in selection screen only one parameter field is there. in that i entered data and press enter?at that time what are all the events are supposed to trigger?
3.can we delete data in one internal table with help of another internal table data?
like let us consider this scenerio
itab1 itab2
material no description material no material type
100 some 100 10
101 thing 101 10
103 line 103 13
104 row type 104 15
106 linetype 106 16
can i delete material no (100,101)in itab1 with the help of record material type (10) of itab2

To delete records with the help of other itab..
have a look at following code...
REPORT  zprax_try2.
data:  begin of itab1 occurs 0,
        fld1(3),
       end of itab1,
       begin of itab2 occurs 0,
        fld1(3),
        fld2(2),
       end of itab2.
initialization.
append '100' to itab1.
append '101' to itab1.
append '102' to itab1.
append '103' to itab1.
append '104' to itab1.
append '10010' to itab2.
append '10110' to itab2.
append '10011' to itab2.
append '10111' to itab2.
append '10210' to itab2.
start-of-selection.
loop at itab1.
write:/ itab1-fld1.
endloop.
skip.
loop at itab2.
write:/ itab2-fld1, itab2-fld2.
endloop.
loop at itab2.
check itab2-fld2 eq '10'.
delete itab1 where fld1 = itab2-fld1.
endloop.
skip.
loop at itab1.
write:/ itab1-fld1.
endloop.
skip.
loop at itab2.
write:/ itab2-fld1, itab2-fld2.
endloop.
reward if useful
regards
Prax

Similar Messages

  • Need information about Internal Tables

    Hi Every one!
    I Need some information about Internal tables. Pls help be above the same.
    Thanks & with Regards,
    Chandra.

    Hi..,
    <b>
    Internal tables </b>
    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.
    <b>Internal Tables as Data Types</b>
    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.
    <b>Line type</b>
    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.
    <b>Key</b>
    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.
    <b>
    Table type</b>
    The table type determines how ABAP will access individual table entries. Internal tables can be divided into three types:
    <u>Standard tables</u> 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.
    <u>
    Sorted tables</u> 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.
    <u>
    Hashed tables</u> 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.
    <b>
    Generic Internal Tables</b>
    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.
    <b>Internal Tables as Dynamic Data Objects</b>
    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.
    <b>
    Choosing a Table Type</b>
    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.
    <b>
    Standard tables</b>
    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.
    <b>Sorted tables</b>
    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.
    <b>
    Hashed tables</b>
    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,
    sai ramesh

  • Briefly about internal tables

    briefly about internal tables
    standerd internal tables
    hash internal tables
    sorted internal tables
    index internal tables

    Hi,
    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.
    Types of internal tables :
    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.
    Creating Internal Tables
    You define internal tables first as an abstract data type in the program or ABAP Dictionary, and then as a data object based on that, or they are declared directly as a fully specified data object. 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 size of table headers for initial tables is currently 8 bytes. This should be heeded whenever internal tables occur as components of complex data objects. Also, empty tables can use up a relatively high amount of storage space as components of tables. The size of the entire storage space required for an internal table is not defined in the declaration – as is the case for data objects of the type string or xstring. Table rows are added to and deleted from the table dynamically at runtime by the various statements for adding and deleting records.
    Structure of internal tables :
    STRUCTURE OF INTERNAL TABLE
    TYPES : BEGIN OF ITAB,
                    PERNR TYPE PERSNO,
                    WERKS TYPE WERKS,
                   END OF ITAB.
    INTERNAL TABLE DECLARATION FOR THE ABOVE STRUCTURE
    DATA : INT_TAB TYPE STANDARD TABLE OF ITAB,
                WA_TAB TYPE ITAB.        "WORK AREA OF THE INTERNAL TABLE
    Thanks,
    Sakthi C
    Rewards if useful *

  • Details About Internal tables

    Hi Friends,
    Tell me diffrent type of iT with significance
    Thanks,
    Prasad

    Hi,
    I assume you are asking about the Internal Tables in ABAP.
    Types of IT:
    1.Standard Tables: Commonly used  ,here the search is made by Index.
    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 (APPEND statement), and read, modify and delete entries by specifying the index). The response time is proportional to the number of records.
    2.Sorted tables: search is  based on table key.
    You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key.
    3.Hashed Tables:
    You cannot access a hashed table using its index. The response time for key access remains constant.
    Thanks,
    Felix

  • Clear idea about internal table.

    I'm new in sap. i need a clear idea about what is  table type , line type and  type groups   in internal table. and why we are using this ?  and give me an idea about work area also.. theses terms are confusing me. if possible please explain me with example. thanks in advance.
    Welcome to SCN - but please do not duplicate post or ask basic questions.
    Edited by: Rob Burbank on Apr 19, 2009 4:20 P

    I'm new in sap. i need a clear idea about what is  table type , line type and  type groups   in internal table. and why we are using this ?  and give me an idea about work area also.. theses terms are confusing me. if possible please explain me with example. thanks in advance.
    Welcome to SCN - but please do not duplicate post or ask basic questions.
    Edited by: Rob Burbank on Apr 19, 2009 4:20 P

  • Solve this :about internal tables

    hi experts,
    could u pls solve this query asap.
    i have 7 internal tables,
    in  one internal table i've field
    orgunits
    1
    2
    3
    4
    in other internal tables i have fields like this
    orgunits       personalnumbers
    1                     11
    2                     12
    1                     13
    1                     14
    3                     15
    1                     16
    now i want how many personalnumbers in each orgunit.
    i want the count.
    so, how can i solve this in short coding.
    example :for orgunit 1----
    the count is 4.(11,13,14,15).
    pls explain with coding as soon as possible.
    thanks all.
    Message was edited by:
            devender reddy

    REPORT  ZTEST_00000 message-id zmsg.
    data : cnt type i.
    data : begin of itab1 occurs 0, "internal table with all org units
    org type i, "change data type
    end of itab1.
    data : begin of itab2 occurs 0, "internal table with org units and pernrs
    org type i, "change data type
    per type i, "change data type
    end of itab2.
    data : begin of itab3 occurs 0, "internal table with org units and count of pernrs
    org type i,
    count type i,
    end of itab3.
    itab1-org = 1.
    append itab1.
    clear itab1.
    itab1-org = 2.
    append itab1.
    clear itab1.
    itab1-org = 3.
    append itab1.
    clear itab1.
    itab1-org = 4.
    append itab1.
    clear itab1.
    itab2-org = 1.
    itab2-per = 10.
    append itab2.
    clear itab2.
    itab2-org = 1.
    itab2-per = 11.
    append itab2.
    clear itab2.
    itab2-org = 2.
    itab2-per = 9.
    append itab2.
    clear itab2.
    itab2-org = 2.
    itab2-per = 4.
    append itab2.
    clear itab2.
    itab2-org = 2.
    itab2-per = 7.
    append itab2.
    clear itab2.
    itab2-org = 3.
    itab2-per = 11.
    append itab2.
    clear itab2.
    itab2-org = 4.
    itab2-per = 14.
    append itab2.
    clear itab2.
    sort itab2 by org per.
    sort itab1 by org.
    loop at itab2.
    at new org.
    clear cnt.
    endat.
    cnt = cnt + 1.
    at end of org.
    itab3-org = itab2-org.
    itab3-count = cnt.
    append itab3.
    clear itab3.
    endat.
    endloop.
    loop at itab1.
    read table itab3 with key org = itab1-org.
    if sy-subrc <> 0.
    itab3-org = itab1-org.
    itab3-count = 0.
    append itab3.
    clear itab3.
    endif.
    endloop.
    sort itab3 by org count.
    loop at itab3.
    write :/ itab3-org , itab3-count.
    endloop.
    Regards
    vasu

  • Internal table and work area

    Hi,
           can anybody explain the concepts of Internal table and work area.Thanks in advance.

    hai,
    This may help u.
    WORKAREA is a structure that can hold only one record at a time. It is a collection of fields. We use workarea as we cannot directly read from a table. In order to interact with a table we need workarea. When a Select Statement is executed on a table then the first record is read and put into the header of the table and from there put into the header or the workarea(of the same structure as that of the table)of the internal table and then transferred top the body of the internal table or directly displayed from the workarea.
    Each row in a table is a record and each column is a field.
    While adding or retrieving records to / from internal table we have to keep the record temporarily.
    The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
    Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
    e.g.
    data: begin of itab occurs 10,
    ab type c,
    cd type i,
    end of itab. " this table will have the header line.
    data: wa_itab like itab. " explicit work area for itab
    data: itab1 like itab occurs 10. " table is without header line.
    Internal tables are used for storing records which are obtained as a result when we use select statement on database. internal tables are run time entities and doesn't occupy any memory. they are dynamic.
    internal tables are of types.
    1. internal tables with header line. [header and body]
    2. internal tables with out header line. [only body]
    Workarea is the concept which is mainly useful when working with internal tables with out header line.
    at any point of time we can access only one record through header of a internal table. every thing should be done [inserting,modifying, reading ] through header only.
    ex: data: itab like standard table of mara with header line.
    for internal tables with out header line we will create a work area [explicit header] as type of table for storing data into internal table.
    ex: data: itab like mara,
    wa like mara.
    more about internal table types:
    Standard table:
    The key access to a standard table uses a sequential search. The time required for an access is linearly dependent on the number of entries in the internal table.
    You should usually access a standard table with index operations.
    Sorted table:
    The table is always stored internally sorted by its key. Key access to a sorted table can therefore use a binary search. If the key is not unique, the entry with the lowest index is accessed. The time required for an access is logarithmically dependent on the number of entries in the internal table.
    Index accesses to sorted tables are also allowed. You should usually access a sorted table using its key.
    Hash table:
    The table is internally managed with a hash procedure. All the entries must have a unique key. The time required for a key access is constant, that is it does not depend on the number of entries in the internal table.
    You cannot access a hash table with an index. Accesses must use generic key operations (SORT, LOOP, etc.).
    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.
    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.
    DATA ITAB TYPE HASHED TABLE OF SPFLI
    WITH UNIQUE KEY CARRID CONNID.
    with regards,
    B.Sowjanya,
    reward points if helpful.

  • Memory released after delete in internal tables ?

    hi friends,
    i have one quick question about internal tables and memory consumption.
    if i have an internal table of say 100 entries and that does occupy memory for 100 entries. now if i delete 20 lines of this table...is the memory occupied by those 20 also released/freed or will the table size be 100 also and just the 20 deleted lines empty ?

    Hi!
    If you defined you table with the OCCURS 100 statement, then it will allocate always at least 100 records.
    The other tables will occupy only the memory size of their actual record length * record number bytes (plus some header information).
    Use REFRESH / FREE statement to delete the contents of unneccessary internal tables.
    Regards
    Tamá

  • How internal tables are physicaly located in memory?

    Array, chained list, or else? Plese provide any opinion or documentation.
    Sincerely yours, Long Nguyen.

    A data model is an abstraction of a part of the real world which is represented using formal structures. A relational database basically uses one formal structure known as a table.
    A table can be defined as a two-dimensional matrix made of rows and columns. It can also be described as a group of records of the same type.Records are groups of fields based on existing data types. These data types are previously defined in the datadictionary. A table is a similar concept to a conventional indexed file; the difference is that in the relational model the main index is known as the primary key, which is made of one or more fields of the record. A record is also known as tuple or simply a row. The most significant feature of the primary key is that it identifies univocally one and only one record of the table: a table does not permit records with duplicated primary keys.
    Structures. The object structure refers to the definition of a compound object that does not have any content. It's like a table or a view, but it never has entries: it's only a structure. These types of objects are used in programs for defining data structures or for defining data in the interfaces from the module pools and the screens. The basic difference between structures and tables (or views) is that the
    structure does not exist at the underlying database system level; however, both tables and views do exist in the database. Structures only exist as definitions in the dictionary. As a result, structures do not need to be activated.
    Table. As previously explained, a table is a two-dimensional data matrix. A table can contain zero or many rows, corresponding to the predefined table structure (entity type). This is, at the same time, a complex structure, which can be made up of one or several fields (attributes). Every row that makes up the database table has the same structure and properties. The fields that make up the structure of the table records, as well as its attributes, permitted value range, and so on, are set when defining the table.
    Some general recommendations for internal tables:
    •     As long as all that you need from an internal table is to append lines to it and perhaps to sort it after filling it, standard tables are still the best choice. The other table kinds are too expen-sive for these simple tasks. Keep in mind that when inserting or deleting lines in index tables containing many lines, the administration of the logical index that manages the lines of the ta-ble internally can become expensive, with regard to performance and additional memory space. Only for standard tables that are filled with APPEND only, and where no lines are de-leted except for the last line, is there no need for a logical index, and hence
    no additional costs are incurred.
    •If memory space is an issue, for very large internal tables (> 500000 lines) with a
    small line size, sorted tables might be preferable to hashed tables, since for internal administration, they need only 6 bytes per line compared to 18 bytes for hashed tables.
    •When declaring internal tables, use the addition INITIAL SIZE only for inner tables in nested tables. For outer tables, the automatic allocation of initial memory size is appropriate. For inner tables, though, it may result in saving a large amount of memory.
    •When reading internal tables with READ TABLE or LOOP AT, choose the appropriate output behavior. Writing into a work area wa with the addition INTO wa is only necessary if you want to change the work area without influencing the internal table. For pure reading purposes or for modifying the contents of the internal table, the additions ASSIGNING <fs> for assigning internal table lines to a field symbol <fs> and REFERENCE INTO dref for setting a refer-ence in a data reference variable dref to internal table lines are the better choices by far.
    •Use CLEAR instead of REFRESH for internal tables. The reason is that for internal tables with-out header lines, the general statement CLEAR does exactly the same as the special state-ment REFRESH. Since internal tables with header lines should no longer be used, the state-ment REFRESH is effectively obsolete. In order to free more memory, you can consider the use of FREE.
    •The statement COLLECT should no longer be used for standard tables — use COLLECT mainly for hashed tables. The reason is that COLLECT is based on a hash algorithm. While the hash administration of a hashed table is always available and robust, for standard tables a temporary hash administration must be created when the COLLECT statement is used. This temporary hash administration is invalidated when the table is accessed for changing. If fur-ther COLLECT statements are entered after an invalidation, a linear search of all table rows must be performed. Furthermore, COLLECT only works properly on internal tables with unique lines, while a unique table key is guaranteed for hashed tables only. Therefore, for standard tables it cannot be guaranteed that the contents will always be suitable for editing using COLLECT.
    •Don’t use APPEND SORTED BY — use SORT instead. The reason is that creating a ranked list with APPEND SORTED BY is based on several assumptions about the internal table and how it is filled. Using SORT is the general method that can be applied to all kinds of table and inde-pendent from the mode of filling.
    Chk these links for more information about internal tables
    internal tables
    Regards,
    Balaji Reddy G
    **Rewards for helpful answers

  • Read info about files in specific folder into internal table

    Hi Experts
    I need to have last modified date and filename information read into an internal table. I need to read in the information of all files in a specific (UNIX) folder (I do not know the name of the single files).
    I really hope someone can help.
    Thanks a lot
    Kind regards,
    Torben

    Hi Guys
    Thanks a lot for you input.
    I managed to get my program to works as follows:
    REPORT  ZDELETE_ARCHIVING_FILES.
    *Step 1: Get the list of files in the directory into internal table :
    DATA: DLIST    LIKE EPSFILI OCCURS 0 WITH HEADER LINE,
          DPATH    LIKE EPSF-EPSDIRNAM,
          MDATE    LIKE SY-DATUM,
          MTIME    LIKE SY-UZEIT.
    DATA: BEGIN OF FATTR OCCURS 0,
              FILE_NAME  LIKE EPSF-EPSFILNAM,
              FILE_SIZE  LIKE EPSF-EPSFILSIZ,
              FILE_OWNER LIKE EPSF-EPSFILOWN,
              FILE_MODE  LIKE EPSF-EPSFILMOD,
              FILE_TYPE  LIKE EPSF-EPSFILTYP,
              FILE_MTIME(12),
          END OF FATTR.
    DATA: P_PATH(50) TYPE C.
    CONCATENATE '/ARCHIVE/' sy-sysid '/archive' INTO P_PATH.
    *        WRITE: / P_PATH.
    DPATH = P_PATH.
    *Get files in folder - read into internal table DLIST
    *if filenames are longer than 40 characters
    *then use FM SUBST_GET_FILE_LIST.
    CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
         EXPORTING
              DIR_NAME               = DPATH
         TABLES
              DIR_LIST               = DLIST
         EXCEPTIONS
              INVALID_EPS_SUBDIR     = 1
              SAPGPARAM_FAILED       = 2
              BUILD_DIRECTORY_FAILED = 3
              NO_AUTHORIZATION       = 4
              READ_DIRECTORY_FAILED  = 5
              TOO_MANY_READ_ERRORS   = 6
              EMPTY_DIRECTORY_LIST   = 7
              OTHERS                 = 8.
    IF SY-SUBRC EQ 0.
    *Step 2: Read the file attributes into an internal table
    *Read info about the files (attributes) into the internal table FATTR
    *as we need info about the last time it was changed (MTIME)
      LOOP AT DLIST.
        CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
             EXPORTING
                  FILE_NAME              = DLIST-NAME
                  DIR_NAME               = DPATH
             IMPORTING
                  FILE_SIZE              = FATTR-FILE_SIZE
                  FILE_OWNER             = FATTR-FILE_OWNER
                  FILE_MODE              = FATTR-FILE_MODE
                  FILE_TYPE              = FATTR-FILE_TYPE
                  FILE_MTIME             = FATTR-FILE_MTIME
             EXCEPTIONS
                  READ_DIRECTORY_FAILED  = 1
                  READ_ATTRIBUTES_FAILED = 2
                  OTHERS                 = 3.
        IF SY-SUBRC EQ 0.
          FATTR-FILE_NAME = DLIST-NAME.
          APPEND FATTR.
        ENDIF.
      ENDLOOP.
      SORT FATTR BY FILE_NAME.
      DATA: time(10), date LIKE sy-datum.
      DATA: months TYPE i.
      DATA: e_file TYPE string.
      LOOP AT FATTR.
      CLEAR: time, months, e_file.
        IF FATTR-FILE_NAME(10) = 'archive_BW'.
    *Convert the unix time into readable time
          PERFORM p6_to_date_time_tz(rstr0400) USING FATTR-FILE_MTIME
                                                     time
                                                     date.
    *Calculate the number of months between date (MTIME) and current day
    *ex 31.03.2009 - 01.04.2009 = 1 month
    *ex 01.02.2009 - 01.04.2009 = 2 month
        CALL FUNCTION 'MONTHS_BETWEEN_TWO_DATES'
          EXPORTING
            i_datum_von = date
            i_datum_bis = sy-datum
          IMPORTING
            e_monate = months.
            CONCATENATE DPATH '/' FATTR-FILE_NAME INTO e_file.
    *        WRITE: / FATTR-FILE_NAME,
    *                 FATTR-FILE_SIZE,
    *                 date,
    *                 time,
    *                 sy-datum,
    *                 months,
    *                 e_file.
    *Step 3: Delete files where months > 1
          IF months > 1.
            OPEN dataset e_file for output in text mode encoding default.
            DELETE dataset e_file.
            CLOSE dataset e_file.
          ENDIF. "months > 1
        ENDIF.
      ENDLOOP.
    ENDIF.

  • Question about XML mapping to ABAP internal table

    Hi experts.
    I'm trying to XML mapping. But it doesn't work well. Assume there are XML file as below.
    <HEADER>
      <ITEM>
        <FOO>123</FOO>
        <BAR>ABC</BAR>
      </ITEM>
      <ITEM>
        <FOO>456</FOO>
        <BAR>DEF</BAR>
      </ITEM>
    <HEADER>
    and I want to trasformation it as below.
    ITAB
    FOO       |      BAR
    123         |  ABC
    456         | DEF
    How could I trasformation using "call transformation"?
    Regards.

    Hi,
    REPORT  zind_xml_to_sap NO STANDARD PAGE HEADING.
    Data Declaration                                                    *
    DATA: client      TYPE REF TO if_http_client, "Interface
          host        TYPE string,
          port        TYPE string,
          proxy_host  TYPE string,
          proxy_port  TYPE string,
          path        TYPE string,
          scheme      TYPE i,
          xml         TYPE xstring,
          response    TYPE string.
    DATA: t_xml       TYPE smum_xmltb OCCURS 0 WITH HEADER LINE.  "XML Table structure used
                                                                  "for retreive and output XML doc
    DATA: g_stream_factory TYPE REF TO if_ixml_stream_factory.    "Interface
    DATA : return  LIKE  bapiret2 OCCURS 0 WITH HEADER LINE.      "XML Table structure used for retreive
                                                                  "and output XML doc
    Parameters                                                          *
    PARAMETER : p_add TYPE string LOWER CASE ,
                p_dfile   LIKE rlgrap-filename.
    AT Selection-Screen on value-request for file                       *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dfile.
    Get file
      PERFORM 100_get_file.
    Start-of-Selection                                                  *
    START-OF-SELECTION.
    Perform to upload xml data from URL to SAP internal table
      PERFORM 200_xml_upload.
      IF t_xml[] IS NOT INITIAL.
      Perform to Download data from Internal Table to a text file in local drive
        PERFORM 300_download.
        write : / 'Data Uploaded to Internal Table Successfully'.
        write : / 'XML Data Downloaded to Local path', p_dfile.
      else.
        write : / 'No Data for upload'.
      ENDIF.
    *if t_xml[] is INITIAL.
    WRITE : address, 'Given URl cannot be Converted' .
    else.
    LOOP AT t_xml .
       WRITE:  t_xml-cname, t_xml-cvalue.
    ENDLOOP.
    endif.
    *&      Form  get_file
          Get File
    FORM 100_get_file .
      CALL FUNCTION 'F4_FILENAME'
      EXPORTING
        PROGRAM_NAME        = SYST-CPROG
        DYNPRO_NUMBER       = SYST-DYNNR
        FIELD_NAME          = ' '
       IMPORTING
         file_name           = p_dfile
    ENDFORM.                    " 100_get_file
    *&      Form  200_xml_upload
          form to upload xml data from URL to SAP internal table
    FORM 200_xml_upload .
    *Check HTTP:// and concatenate
      IF p_add NS 'http://' OR p_add NS 'HTTP://'.
        CONCATENATE 'http://' p_add
                    INTO p_add.
      ENDIF.
    Fetching the address of the URL
      CALL METHOD cl_http_client=>create_by_url
        EXPORTING
          url    = p_add
        IMPORTING
          client = client.
    *Structure of HTTP Connection and Dispatch of Data
      client->send( ).
    *Receipt of HTTP Response
      CALL METHOD client->receive
        EXCEPTIONS
          http_communication_failure = 1
          http_invalid_state         = 2
          http_processing_failed     = 3
          OTHERS                     = 4.
      IF sy-subrc <> 0.
        IF sy-subrc = 1.
          MESSAGE 'HTTP COMMUNICATION FAILURE' TYPE 'I' DISPLAY LIKE 'E'.
          EXIT.
        ELSEIF sy-subrc = 2.
          MESSAGE 'HTTP INVALID STATE' TYPE 'I' DISPLAY LIKE 'E'.
          EXIT.
        ELSEIF sy-subrc = 3.
          MESSAGE 'HTTP PROCESSING FAILED' TYPE 'I' DISPLAY LIKE 'E'.
          EXIT.
        ELSE.
          MESSAGE 'Problem in HTTP Request' TYPE 'I' DISPLAY LIKE 'E'.
          EXIT.
        ENDIF.
      ENDIF.
    Get data of the xml to Response
      response = client->response->get_cdata( ).
    *FM converting the XML format to abap
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text   = response
        IMPORTING
          buffer = xml.
    *FM converting XMl to readable format to a internal table.
      CALL FUNCTION 'SMUM_XML_PARSE'
        EXPORTING
          xml_input = xml
        TABLES
          xml_table = t_xml
          return    = return.
    ENDFORM.                    " 200_xml_upload
    *&      Form  300_download
    *form to Download data from Internal Table to a text file in local drive
    FORM 300_download .
      DATA filename TYPE string.
      filename = p_dfile.
      CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                        = filename
        WRITE_FIELD_SEPARATOR           = 'X'
      TABLES
        data_tab                        = t_xml
    EXCEPTIONS
       FILE_WRITE_ERROR                = 1
       NO_BATCH                        = 2
       GUI_REFUSE_FILETRANSFER         = 3
       INVALID_TYPE                    = 4
       NO_AUTHORITY                    = 5
       UNKNOWN_ERROR                   = 6
       HEADER_NOT_ALLOWED              = 7
       SEPARATOR_NOT_ALLOWED           = 8
       FILESIZE_NOT_ALLOWED            = 9
       HEADER_TOO_LONG                 = 10
       DP_ERROR_CREATE                 = 11
       DP_ERROR_SEND                   = 12
       DP_ERROR_WRITE                  = 13
       UNKNOWN_DP_ERROR                = 14
       ACCESS_DENIED                   = 15
       DP_OUT_OF_MEMORY                = 16
       DISK_FULL                       = 17
       DP_TIMEOUT                      = 18
       FILE_NOT_FOUND                  = 19
       DATAPROVIDER_EXCEPTION          = 20
       CONTROL_FLUSH_ERROR             = 21
       OTHERS                          = 22
      IF sy-subrc <> 0.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.

  • Question about reading csv file into internal table

    Some one (thanks those nice guys!) in this forum have suggested me to use FM KCD_CSV_FILE_TO_INTERN_CONVERT to read csv file into internal table. However, it can be used to read a local file only.
    I would like to ask how can I read a CSV file into internal table from files in application server?
    I can't simply use SPLIT as there may be comma in the content. e.g.
    "abc","aaa,ab",10,"bbc"
    My expected output:
    abc
    aaa,ab
    10
    bbb
    Thanks again for your help.

    Hi Gundam,
    Try this code. I have made a custom parser to read the details in the record and split them accordingly. I have also tested them with your provided test cases and it work fine.
    OPEN DATASET dsn FOR input IN TEXT MODE ENCODING DEFAULT.
    DO.
    READ DATASET dsn INTO record.
      PERFORM parser USING record.
    ENDDO.
    *DATA str(32) VALUE '"abc",10,"aaa,ab","bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"bbc"'.
    *DATA str(32) VALUE '"a,bc","aaaab",10,"bbc"'.
    *DATA str(32) VALUE '"abc","aaa,ab",10,"b,bc"'.
    *DATA str(32) VALUE '"abc","aaaab",10,"bbc"'.
    FORM parser USING str.
    DATA field(12).
    DATA field1(12).
    DATA field2(12).
    DATA field3(12).
    DATA field4(12).
    DATA cnt TYPE i.
    DATA len TYPE i.
    DATA temp TYPE i.
    DATA start TYPE i.
    DATA quote TYPE i.
    DATA rec_cnt TYPE i.
    len = strlen( str ).
    cnt = 0.
    temp = 0.
    rec_cnt = 0.
    DO.
    *  Start at the beginning
      IF start EQ 0.
        "string just ENDED start new one.
        start = 1.
        quote = 0.
        CLEAR field.
      ENDIF.
      IF str+cnt(1) EQ '"'.  "Check for qoutes
        "CHECK IF quotes is already set
        IF quote = 1.
          "Already quotes set
          "Start new field
          start = 0.
          quote = 0.
          CONCATENATE field '"' INTO field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            CONDENSE field.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
    *      WRITE field.
        ELSE.
          "This is the start of quotes
          quote = 1.
        ENDIF.
      ENDIF.
      IF str+cnt(1) EQ ','. "Check end of field
        IF quote EQ 0. "This is not inside quote end of field
          start = 0.
          quote = 0.
          CONDENSE field.
    *      WRITE field.
          IF field IS NOT INITIAL.
            rec_cnt = rec_cnt + 1.
            IF rec_cnt EQ 1.
              field1 = field.
            ELSEIF rec_cnt EQ 2.
              field2 = field.
            ELSEIF rec_cnt EQ 3.
              field3 = field.
            ELSEIF rec_cnt EQ 4.
              field4 = field.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      CONCATENATE field str+cnt(1) INTO field.
      cnt = cnt + 1.
      IF cnt GE len.
        EXIT.
      ENDIF.
    ENDDO.
    WRITE: field1, field2, field3, field4.
    ENDFORM.
    Regards,
    Wenceslaus.

  • Dumb question about monodimensional internal tables

    Hi all gurus,
    in ABAP/4 it is possible to define an internal table made up by a single field , so that we could consider such a declaration:
    DATA: itab TYPE TABLE OF EBELN
    as a single-dimension array.
    Now, supposing I want to fast access this vector directly with a read table... I don't have an explicit field name to refer to in the WITH KEY clause.
    My workaround actually is to define such a vector in this way:
    DATA: begin of itab,
                doc_no TYPE EBELN,
                end of itab.
    so that a fast READ TABLE statement can be possible specifying the WITH TABLE clause in this way:
    READ TABLE itab WITH KEY doc_no = <valuetosearchfor>  .
    Anyway, I'm wondering if these ops are possible even in an itab defined in the first form, without the need of defining a specific itab structure. In many situation I find mono-dimensional tables really useful, I'd like to avoid every time an explicit DATA type def.

    Hello,
    I dont know if this is what you are looking for. You can use the addition:
    ... WITH TABLE KEY [keyname COMPONENTS] ...
    SAp documentation also adds:
    The pseudo component table_line can be specified as a component for tables with an unstructured row type, if their whole table entry is defined as a table key.
    For more details on psuedo components read this : [http://help.sap.com/abapdocu_70/en/ABENITAB_COMPONENTS.htm|http://help.sap.com/abapdocu_70/en/ABENITAB_COMPONENTS.htm]
    Hope this helps.
    BR,
    Suhas

  • About finding internal tables to manage screen changes

    Dear experts,
    I am working to enhance ME51 ME52 in order to allow storing of some customer fields in
    screen 111 using MEREQ001.
    How can i know which internal table i should use in order to define the screen fields in screen painter
    ex in Name what i will give as <internaltable>-<fieldname>.How can i know in which structure data is going.
    Regards,
    Aditya Sharma

    Try this :
    1-Re: enhancements MEREQ001 in purchase requisition
    2-http://sap.niraj.tripod.com/id63.html
    Regards
    Neha

  • Question about Subroutine and Internal tables

    See I  have this code.
    TABLES: SFLIGHT.
        TYPES: BEGIN OF LINE,
               Carrid like SFLIGHT-CARRID,
               Connid like SFLIGHT-CONNID,
               Fldate like SFLIGHT-FLDATE,
               Seatsmax like SFLIGHT-SEATSMAX,
               Seatsocc like SFLIGHT-SEATSOCC,
               Percen type p decimals 2,
               END OF LINE.
       DATA: ISFLIGHT TYPE STANDARD TABLE OF LINE INITIAL SIZE 10 WITH HEADER LINE.
       DATA: Percent type p decimals 2.
       PARAMETERS: CID LIKE SFLIGHT-CARRID.
       DATA: Num type I value 0.
       INITIALIZATION.
       CID = '004'.
       SELECT CARRID CONNID FLDATE  SEATSMAX  SEATSOCC FROM SFLIGHT INTO TABLE ISFLIGHT WHERE CARRID = CID.
    So far I've gotten this far. but now I need to compute for the percentage, which I'm required to do in a subroutine.
    So I tried
    FORM U TABLES ISFLIGHT STRUCTURE SFLIGHT.
    ISFLIGHT-Percen = ( ISFLIGHT-Seatsocc / ISFLIGHT-Seatsmax ) * 100.
    ENDFORM.
    But I keep getting an error o that. It keeps telling me that ISFLIGHT does not have a Percen field. Also I'm suppose to use a pass by value to this subroutine but I don't know what that means.
    Basically I need to compute for the percentage and insert it tot he internal table. which I would sort by percentage. After which I'm suppose to print the ouput by passing the internal table to the subroutine.
    I know I'm doing something wrong but I just don't know how to fix this since I only started working on subroutines today. Any help would be appreciated.

    Hi.
    line defined in data dictionary. Try this:
    TABLES: sflight.
    DATA: BEGIN OF my_line,
    carrid LIKE sflight-carrid,
    connid LIKE sflight-connid,
    fldate LIKE sflight-fldate,
    seatsmax LIKE sflight-seatsmax,
    seatsocc LIKE sflight-seatsocc,
    percen TYPE p DECIMALS 2,
    END OF my_line.
    DATA: isflight LIKE my_line OCCURS 10 WITH HEADER LINE.
    DATA: percent TYPE p DECIMALS 2.
    PARAMETERS: cid LIKE sflight-carrid.
    DATA: num TYPE i VALUE 0.
    INITIALIZATION.
      cid = '004'.
      SELECT carrid connid fldate seatsmax seatsocc FROM sflight INTO TABLE
      isflight WHERE carrid = cid.
    FORM u TABLES isflight STRUCTURE my_line.
      isflight-percen = ( isflight-seatsocc / isflight-seatsmax ) * 100.
    ENDFORM.                    "U
    regards
    Walter Habich

Maybe you are looking for

  • Error while uploading file using wininet in c++.

    I'm going to upload text.txt file using wininet. Here is a code. #include "stdafx.h" #include "iostream" #include "windows.h" #include "wininet.h" #include "tchar.h" #include "iostream" #include "string" #include "sstream" #pragma comment(lib, "ws2_3

  • Capturing with Gl2

    Hey All, I am capturing from a GL2 (DV) via my Quad's firewire 400 to a remote drive connected via firewire 800. When I plug in the camera, FCP 5.1 freezes on me. When I disconnect the camera the program runs great. This is a Quad with an Apple scree

  • Rating Photos 1-5

    Hi there, I use the rating feature of iPhoto all the time to help cull the rubbish and keep the good stuff, while using the 5 star stuff in print projects and slide shows etc. Is there anyway to do this in Photos, without clicking on the info button

  • Just bought a new computer, downloaded cc but I only have access to trials when I have full membership?

    Now that I have a more powerful computer, I would like to use my software's. Although once downloaded it advises me that I only have access to trials wheres as I am paying monthly. What am I missing?

  • Kleine Fragen zu 5.0.2

    Hallo, bin recht begeistert, aber ein paar kleine Fragen sind schon noch: a. Kann es auch identische Bilder finden? Habe leider ein paar tausend doppelt :-( b. Kann ich nur direkt bei Kodak Bilder bestellen? (Ist ja leider nicht der günstigste :-( )