Records in an internal table

Hi,
How to check if all the records in an internal table are identical.
could you help soon

Hi,
use the code,
data : begin of itab occurs 0,
          matnr like mara-matnr,
          maktx like makt-maktx.
          end of itab.
parameters : p_matnr like mara-matnr.
start-of-selection.
select * from makt into corresponding fields of table itab
                            where  matnr = p_matnr.
delete adjacent duplicates from itab comparing matnr.
if sy-subrc eq 0.
write : /1 'Entries are identical.' .
endif.
Regards,
Sankar.

Similar Messages

  • Count the Records in  an internal table without a loop.

    How do i count the number of records in an internal table without using the loop  statement.
    The Describe statement give the total no. of records in the internal table.But i want the count of the key fields in the internal table
    For eg
    Row Field
    1       A
    2       A
    3       A
    4       B
    5       B
    6       C
    Count of A = 3
    Count of B = 2
    Count of C = 1

    Dilip,
      I think isn't posible. Only 3 ideas:
    1ª, make other table "table2", similar to your actual table.
         table2[] = yourtable[].
         delete table2 where key <> 'A'.
         describe table table2 lines contA.
        But depending the amount of data, you may have problems in performance or memory consumption...
    2ª, make other table, only with the keys fields and a count field,
        data begin table2
           key_field1,
           cont type i.
        end data.
       when you append lines to yourdata, make a collect to this table:
        table2-keys = yourtable-keys.
        table2-cont = 1.
       collect table2.
       But only works if you can modify the program where data is appended, and you may be carefull when data is deleted :-(...
    3ª if your data if filled in a select, you may fill the table2 of point 2ª, making a similar select but:
       select keyfields count( * ) into table table2
      from ...
      where (the same you have to fill your original table...)
       group by keys.
    But you have the same problem is data is deleted later...
    I hope that any of the three is useful for you...
    Edited by: Diego Alvarez on Jan 5, 2010 5:09 PM

  • How to delete records from dynamic internal table.

    Hi Experts,
    Need urgent help!!!
    Issue is with Dynamic internal tables.
    Below is code written by me :
    FORM select_query USING Lw_tabnam
                      TYPE  t682i-kotabnr.
      DATA :  lw_line  TYPE REF TO data,
              lw_line1 TYPE REF TO data.
        CREATE DATA Lw_line    TYPE (lw_TABNAM).
        ASSIGN      Lw_line->* TO   <WA_tbl>.
        CREATE DATA LW_LINE    TYPE STANDARD TABLE OF (Lw_tabnam)
                               WITH NON-UNIQUE DEFAULT KEY.
        ASSIGN      Lw_line->* TO <TBL>.
        SELECT * FROM  (Lw_tabnam)
                 INTO CORRESPONDING FIELDS OF TABLE <TBL>
                 WHERE (t_keys).
    Endform.
    code is working fine.
    here even the table name and where condition are dynamic,everything is fine upto this point.
    Now i have to delete some record from <TBL> based on some conditons.
         for ex : ( here lc_fieldname is KUNNR)
          loop at t_kunnr.
              lw_tabix = sy-tabix.
            Read table <tbl>
                    with key (lc_fieldname) = t_kunnr-kunnr ASSIGNING <wa_tbl>.
            If sy-subrc = 0.
            *Delete
            delete <tbl> from <wa_tbl>
    delete <tbl> index  lw_tabix.
            Endif.
         Endloop.
    The above delete statement doesn't work ,even we can't use index as it gives a syntax error " something related to "index is not allowed in standard table or hash table.
    Can you help me ab't how to delete records in Dynamic internal table?
    Other option that i am thinking of is to create a static table of type dynamic table.
    means, data itab type standard table of <tbl> .I know the syntax is wrong ,however is there any way to do this?
    Thanks in advance ,
    If you have any suggestion ab't this then do let me know.
    bye,
    Gaurav.

    Hi
    I wrote this code and it works fine:
    DATA LW_TABNAM(10) VALUE 'LFA1'.
    DATA : LW_LINES TYPE REF TO DATA,
           LW_LINE  TYPE REF TO DATA.
    FIELD-SYMBOLS: <TABLE> TYPE TABLE,
                   <WA>    TYPE ANY.
    CREATE DATA LW_LINES TYPE TABLE OF (LW_TABNAM)
    WITH NON-UNIQUE DEFAULT KEY.
    ASSIGN LW_LINES->* TO <TABLE>.
    CREATE DATA LW_LINE TYPE (LW_TABNAM).
    ASSIGN LW_LINE->* TO <WA>.
    DO 10 TIMES.
      APPEND INITIAL LINE TO <TABLE>.
    ENDDO.
    SY-TABIX = 4.
    DELETE <TABLE> INDEX SY-TABIX.
    WRITE SY-SUBRC.
    I hope it help you
    Max

  • Maximum record length in internal table?

    Is there a maximum record length in an internal table?  Please note:  My question is NOT related to table space.  I'm referring only to the length of an individual record (A.K.A. row length).
    I am using a work area to insert data into an internal table.  Both the work area and internal table are defined by the same structure.
    The structure has a total length of 672 bytes.  For the sake of this discussion I'll point out that at the end of the structure, bytes 669, 670, 671, and 672 are four separate fields of 1 character each.
    When viewing the work area record in the debugger I'm seeing all the fields and all the values.  When viewing the internal table in the debugger after a record is inserted, the internal table ends with the field defined at Byte 670.  The internal table does not include the two fields defined at Bytes 671 and 672.
    Am I to assume from the above explanation that the length of a record ( A.K.A. row) in an internal table cannot exceed 670 bytes?
    Thank you.

    Manish,
    False alarm!  While, technically, you didn't answer my question, your request for code ended up helping me answer my own question.
    To provide you with some code I wrote a simple test program using the record layout referred to above, with a DO loop to put some records into the internal table, followed by a LOOP AT, with accompanying WRITE statements to display the contents of the internal table and demonstrate that the last two fields weren't being stored.
    However, when I ran the test program, the last two fields were being displayed.
    It was at that point, when stepping through the debugger that I noticed the scroll arrows above the last column of my internal table that allowed me to scroll to the right and see my final two fields.
    Apparently, because of the large number of fields in my internal table I had reached the default display length of the debugger.  While I was obviously aware of the scroll bar found at the bottom of the display, I had never worked with an internal table of that width in the past and hadn't even noticed the scroll arrows above the last column before.
    Thanks for taking the time to respond helping me get to the solution.

  • @Inserting Records in an Internal Table

    Hi,
    How can I Insert records in an internal table..such that i can insert the records somewhere in the middle based on the entry in a field?

    INSERT wa INTO TABLE itab INDEX idx .
    Effect
    This variant can only be used for standard tables and sorted tables. Each line line_spec to be inserted into the line before the table index idx and the table index of the following lines is increased by one. A data object of the type i is expected for idx.
    If idx contains a value equal to the number of the existing table lines plus one, the new line is appended as the last line in the internal table. If idx contains a greater value, no line is inserted and sy-subrc is set to 4.
    An exception that cannot be handled is raised when:
    idx contains a value less than or equal to 0
    A line to be inserted would cause a duplicate entry in tables with a unique table key
    A line to be inserted would disrupt the sort order of sorted tables
    Within a LOOP loop, you can omit the addition INDEX. Each line to be inserted is inserted before the current table line of the LOOP loop. However, if the current line is deleted in the same loop pass, the response is undefined.

  • Spilt the number of records in a internal table

    Hi all,
            I have a requirement where i must spilt the number of records in my internal table itab .Say if i have 2000 records , i must spilt it taking the first 990 records and doing some posting using Bapi and again take the next 990 records and do the posting .Can some one help me out.
    Good answers will be rewarded with points.

    Hi,
    You can use these instructions using two internal tables, but please be aware to not forget any line.
    REFRESH my_table2.
    APPEND LINES OF my_table FROM 1 TO 990 TO my_table2.
    CALL FUNCTION 'BAPI'....
                 (with my_table2)
    REFRESH my_table2.
    APPEND LINES OF my_table FROM 991 TO my_table2.
    CALL FUNCTION 'BAPI'....
                 (with my_table2)
    Regards,
    Mathieu

  • Count number of records in a internal table

    hi
    i want to count number of records in internal table
    pls let me know how to count the number of records in a internal table.
    regards
    Arora

    hi
    one way is
    data field type i.
    Decribe table itab lines field.
    write: / field.
    displays the no of records in tha internal table
    or if u want to write logic.
    data:
      w_count type i.
    loop at itab.
    w_count = w_count + 1.
    endloop.
    write: / w_count.
    displays the no of records.
    reward points if useful.

  • Delete records in a internal table

    I Have an ALV in which I have selected several lines to delete (icon "-").
    The method get_selected_rows returns the index of the selected lines.
    In a loop I try to delete the lines of the internal table by the index. But I have a problem because when I delete a line, the index number is updated, therefore the second record that I try to delete doesn´t work because the index has changed.
    does there exist the possibility that the index is not updated?
    Thanks

    hi
    try to delete like this
    loop at itab
    delete itab                    
    endloop
    it deletes all the records in the internal table
    outside of the loop
    delete itab index 2   -
    > it deletes the record of index 2
    put it into the while or do while
    i =1.
    while i < 5
    i = i+ 1.
    delete itab index i.
    endwhile.
    it deletes 5 records in the internal table

  • Summarizing records in a internal table

    hi
    what is meant by summarizing records in an internal table
    vamsi

    HI
    please go through this:
    u will get some idea.
    Appending Summarized Lines
    The following statement allows you to summate entries in an internal table:
    COLLECT <wa> INTO <itab>.
    <itab> must have a flat line type, and all of the fields that are not part of the table key must have
    a numeric type (F, I, or P). You specify the line that you want to add in a work area that is
    compatible with the line type.
    When the line is inserted, the system checks whether there is already a table entry that matches
    the key. If there is no corresponding entry already in the table, the COLLECT statement has the
    same effect as inserting the new line [Page 282]. If an entry with the same key already exists, the
    COLLECT statement does not append a new line, but adds the contents of the numeric fields in
    the work area to the contents of the numeric fields in the existing entry.
    You should only use the COLLECT statement if you want to create summarized tables. If you
    use other statements to insert table entries, you may end up with duplicate entries.
    Lines are added to internal tables as follows:
      Standard tables
    If the COLLECT statement is the first statement to fill the standard table, the system
    creates a temporary hash administration that identifies existing entries in the table. The
    hash administration is retained until another statement changes the contents of key fields
    or changes the sequence of the lines in the internal table. After this, the system finds
    existing entries using a linear search. The runtime for this operation increases in linear
    relation to the number of existing table entries. The system field SY-TABIX contains the
    index of the line inserted or modified in the COLLECT statement.
      Sorted tables
    The system uses a binary search to locate existing lines. The runtime for the operation
    increases logarithmically with the number of existing lines. The system field SY-TABIX
    contains the index of the line inserted or modified in the COLLECT statement.
      Hashed tables
    The system finds existing lines using the hash algorithm of the internal table. After the
    COLLECT statement, the system field SY-TABIX has the value 0, since hashed tables
    have no linear index.
    Example
    DATA: BEGIN OF LINE,
    COL1(3) TYPE C,
    COL2(2) TYPE N,
    COL3 TYPE I,
    END OF LINE.
    DATA ITAB LIKE SORTED TABLE OF LINE
    WITH NON-UNIQUE KEY COL1 COL2.
    BC - ABAP Programming SAP AG
    Appending Summarized Lines
    286 April 2001
    LINE-COL1 = 'abc'. LINE-COL2 = '12'. LINE-COL3 = 3.
    COLLECT LINE INTO ITAB.
    WRITE / SY-TABIX.
    LINE-COL1 = 'def'. LINE-COL2 = '34'. LINE-COL3 = 5.
    COLLECT LINE INTO ITAB.
    WRITE / SY-TABIX.
    LINE-COL1 = 'abc'. LINE-COL2 = '12'. LINE-COL3 = 7.
    COLLECT LINE INTO ITAB.
    WRITE / SY-TABIX.
    LOOP AT ITAB INTO LINE.
    WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
    ENDLOOP.
    Thanks
    Shiva

  • Record count in internal table

    i want to know record count for the records stored in
    internal table.
    do we have any system field to display record count?

    Hi,
    Try this:
    Data: count_lines type i.
    describe table my_table lines count_lines.
    Regards,
    Arjan

  • Store the vital info from the absence quota record in an internal table

    Hi experts,
    I want to detrmine if the Absence record’s (PA2001 rec) deduction from date (PA2001-BEGDA) and absence to date (PA2001-ENDDA) are permissible for the validity period of the Absence Quota record (the PA2006 rec).  If the quota’s deduction from date, PA2006-DESTA, is greater than the PA2001-BEGDA, we then need to identify this absence quota record for change and change the deduction from date, PA2006-DESTA, to be the same as PA2001-BEGDA.  Store the vital info from the absence quota record in an internal table and record the new date that the deduction from date that needs to be changed to.  The changes will be made via a BDC session.
    Please help me out...
    Thanks,
    Vicky

    This looks possible if we code it in 'dynamic action' table, but the BDC may not read it during run time.
    Do you still have this issue?
    Thanks
    Narasimha

  • Calcullating no. of records in an internal table based on condition

    Hi,
    i have several records in an internal table. i need to calculate the number of records which meets a condition. is there any simple logic to find the records which meet the required criteria apart from looping into the internal table.
    your help would be appreciated.
    Thanks,
    kranthi.

    Hi,
    U can use sy-dbcnt after the select querry.
    DBCNT  Number of elements in edited dataset with DB operations
    WRITE: /12 'Number of selected records:', SY-DBCNT CENTERED.
    REPORT ZZZ_TEST1 .
    Tables: mara.
    Types: begin of ty_mara,
           matnr like mara-matnr,
          end of ty_mara.
    DATA: i_mara TYPE STANDARD TABLE OF ty_mara.
    DATA: v_cnt like sy-dbcnt.
    SELECT-OPTIONS: s_matnr FOR MARA-matnr.
    SELECT matnr from mara into table i_mara.
    if sy-subrc = 0.
    v_cnt = sy-dbcnt.
    WRITE: /12 'Number of selected records:', v_cnt CENTERED.
    endif.
    Hope this helps u.
    Thanks & Regards,
    Judith.

  • Help needed to get unique record from an internal table

    Hi Everybody,
    I have to get unique record from an internal table. i know we can use read statement with key condition .
    But the problem is i have to use some relational operators like GE or LE.
    eg
    read table itab into wa with key width GE itab-widthfrom
                                                       width LE itab-widthto
                                                       machno eq itab-machno.
    Its giving me error when I use the operators GE , LE.( I think since it can't find a unique record with those relational
    operators in the with key statement)
    Is there any other way to get unique record from internal table without using the loop?
    Thanks,
    Sunny

    Using the read statement you will need some kind of loop. For example.
    DO.
    READ TABLE......
      WITH KEY ......
                        READ = SPACE
    IF SY-SUBRC EQ 0
      TABLE-READ = 'X'.
      MODIFY TABLE
      ADD 1 TO W_FOUND.
    ELSE
      EXIT.
    ENDIF
    ENDDO.
    IF W_FOUND EQ 1.
    ...record is unique.
    ENDIF.

  • To count number of records in an internal table for a condition

    Hello All,
            I want to count number of records in an internal table for a condition.
    For e.g. -- I have one internal table IT which having fields F1, F2, F3, F4, F5.
                     Now, I want number of records in itnternal table IT where F1 = 'ABC'.
    Is it possible to do..?? If yes, then how.??
    Thanks in advance...!!
    Regards,
    Poonam.

    Hi,
    If you mean an internal table, there are a few ways to do this.
    1 One would be to loop over the table with a WHERE clause and increment a counter.
    data: lv_counter type i.
    clear lv_counter.
    loop at itab where fld1 = 'ABC'.
    lv_counter = lv_counter + 1.
    endloop.
    lv_counter now has the number of rows per the condiction.
    2  Well, you may want to try this as well, and compare to the LOOP way. Not sure what kind of overhead you may get doing this way. Here ITAB is our main internal table, and ITAB_TMP is a copy of it. Again I think there may be some overhead in doing the copy. Next, delete out all records which are the reverse of your condition. Then whatever is left is the rows that you want to count. Then simply do a LINES operator on the internal table, passing the number of lines to LV_COUNT.
    data: itab type table of ttab.
    data: itab_tmp type table of ttab.
    itab_tmp[] = itab[].
    delete table itab_tmp where fld1  'ABC'.
    lv_count = lines( itab_tmp ).
    Thanks & Regards,
    ShreeMohan

  • Grouping records in an internal table

    Dear all,
    Pls follow the code and suggest me to get the specified format.
    Consider that  i have created a view to populate the reqd data and collect those in an internal table and do a calculation for one field and modify the internal table.
    when i pass this internal table to the function reuse_alv_grid , it throws out a report. But if i need to group the records of the internal table based on three fields, can i do that , if so , how should i do that, if not what method shud i adopt to get the grouped listing in ALV.
    kindly give your views.
    Code goes here..........
    select distinct edatu j_3akvgr6 mvgr4 matnr bismt vbeln auart bstkd bstkd_e ihrez_e
    bstdk_e bstdk bezei vrvez brgew ntgew volum werks kwmeng j_3asize posnr
    INTO CORRESPONDING FIELDS OF TABLE  itabdelshd
    from ZVDELISHED
    where J_3AKVGR6 IN CUSTOMER AND AUART IN ORDTYP
    AND BISMT IN STYLE  AND MATNR in FGMtrl AND bstdk_e IN PLNDATE
    AND J_3ASIZE IN GRIDVAL and werks in plant and mvgr4 in ppmon and
    bstkd in cpono and vbeln in Sales.
    LOOP AT itabdelshd INTO wadelshd.
          select sum( wmeng ) as tqty into wasumqty-tqty
          from vbep where edatu = wadelshd-edatu and vbeln = wadelshd-vbeln
          and j_3asize = wadelshd-j_3asize.
          select sum( lfimg ) as dqty into wasumqty-dqty
          from lips where vbelv = wadelshd-vbeln and j_3asize = wadelshd-j_3asize
          wadelshd-PLND_QTY = wasumqty-tqty - wasumqty-dqty.
          wadelshd-PLND_QTY = wadelshd-wmeng - wadelshd-lfimg.
          wadelshd-COLOR = wadelshd-j_3asize(4).
          MODIFY itabdelshd  FROM  wadelshd.
    ENDLOOP.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.

    Dear Jorge,
    It is working out, But i need to do the sum for the grouped data, for instance , if the below data is grouped data seen in the alv,
    sales ord      | color    line.Item|  Ord.qty   | Pld.Qty     | Date          "
    | 0001000551  | 002V | 100       | 6,800.000 | 1,200.000 | 25.09.2006"
    | 0001000551  | 002V | 100       | 6,800.000 | 2,500.000 | 25.09.2006"
    | 0001000551  | 002V | 100       | 6,800.000 | 3,100.000 | 25.09.2006"
    | 0001000551  | 003K | 200       | 3,200.000 | 700.000    | 25.09.2006"
    | 0001000551  | 003K | 200       | 3,200.000 | 1,200.000 | 25.09.2006"
    | 0001000551  | 003K | 200       | 3,200.000  | 1,300.000 | 25.09.2006"
    and if want to sum the the planed qty based on the line.Item Grouping, meaning, can i get the report in the below form.
    sales ord      | color    line.Item|  Ord.qty   | Pld.Qty     | Date          "
    | 0001000551  | 002V | 100       | 6,800.000 | 6,800.000 | 25.09.2006"
    | 0001000551  | 003K | 200       | 6,800.000 | 3,200.000 | 25.09.2006"
    what should i do to get this form.

Maybe you are looking for

  • SRM 7.0 Catalog (Web Service) Portal Links Not Working

    Hi, Following an upgrade to the latest Service Packs for SRM, we are encountering an issue with dead links to Catalogs (both Internal MDM and External). Prior to the upgrade the normal catalog (webservice) links, as defined in the SPRO (Supplier Rela

  • How to delete the Junk Data From Excel Sheet

    Dear ABAPers,             I am uploading the Excel sheet from the Desktop to the SAP System. In the Internal table i am getting Unwanted Junk data's for Example '##########'.I am not getting this Junk data for all the times. i am getting it for Some

  • Airport to gateway network disappears

    I have two networks set up on my G5 iMac, one for iTunes (connected to an AEX), and another one connected to my Qwest gateway for internet access. The internet network keeps disappearing. I have to go to the Airport menu and do a "Join other network"

  • Exporting Animated Slides for widescreen - Best format for export?

    I need to build a looping video to be played on a bunch of flat-screen TV's mounted to a trade-show booth. I'm guessing I need to build it for wide-screen - 16.9 ratio? I used iMovie to build a simple video of images panning in and out. When I go to

  • Time Machine: Can I make a backup of the original backup?

    I use Time Machine. Once a month, for corporate security reasons, I need to move a duplicate of our company's Time Machine backup hard disk to an offsite storage spot 30 miles away. (Just in case of hurricanes, civil unrest, uncivil unrest etc.) If I