Number of records in internal table

Hi
How can I tjeck an internal table for the number of records it contains (even if it contains 0).
Thanks in advance, regards
Torben

Hi,
DESCRIBE TABLE itab.
Effect
Returns the attributes of the internal table itab. You must use at least one of the additions listed below:
Note
The DESCRIBE statement cannot be used for all ABAP types. In connection with ABAP Objects, SAP has introduced a RTTI concept based on system classes to determine type attributes at runtime. This concept applies to all ABAP types and as such covers all the functions of the DESCRIBE TABLE statement.
Extras:
1. ... LINES n
2. ... OCCURS n
3. ... KIND   k
Addition 1
... LINES n
Effect
Places the number of filled lines of the table t in the field lin. The value returned to lin has type I.
Note
The number of filled lines of the table itab can also be ascertained using the predefined function lines( itab ).
Example
DATA: N    TYPE I,
      ITAB TYPE TABLE OF I.
CLEAR ITAB.
APPEND 36 TO ITAB.
DESCRIBE TABLE ITAB LINES N.
Result: N contains the value 1.
Addition 2
... OCCURS n
Effect
Passes the size of the OCCURS parameter from the table definition (as defined with DATA) to the variable n. The value returned to n has type I.
Example
DATA: N1    TYPE I,
      N2    TYPE I,
      ITAB1 TYPE TABLE OF I INITIAL SIZE 10,
      ITAB2 TYPE I OCCURS 5.
DESCRIBE TABLE ITAB1 OCCURS N1.
DESCRIBE TABLE ITAB2 OCCURS N2.
Result: OCC contains the value 10 and N2 the value 5.
Addition 3
... KIND k
Effect
Writes the table type from itab to the variables n. The value returned to k is of type C. The constants SYDES_KIND-STANDARD, SYDES_KIND-SORTED and SYDES_KIND-HASHED are defined in the type group SYDES for the return values.
Example
Generic FORM routine any table type
TYPE-POOLS: SYDES.
FORM GENERIC_FORM USING ITAB TYPE ANY TABLE.
  DATA: K TYPE C.
  DESCRIBE TABLE ITAB KIND K.
  CASE K.
    WHEN SYDES_KIND-STANDARD.
    WHEN SYDES_KIND-SORTED.
    WHEN SYDES_KIND-HASHED.
  ENDCASE.
ENDFORM.
Notes
Performance: The runtime for executing the DESCRIBE TABLE statement is approximately 4 msn (standardized microseconds).
The DESCRIBE TABLE statement also passes values to the SY-TFILL and SY-TLENG System fields
Additional help
Determining the Attributesof Internal Tables
Thanks,
Sankar M

Similar Messages

  • How to update Records from Internal table to u2018Zu2019 table?

    Hi Friends,
    How to update Records from Internal table to u2018Zu2019 table.
    I have records in Internal table , that records want to update on u2018Zmarau2019 Table.
    ( my internal table & u2018 Zu2019 table structures are same.)
    Thanking you.
    Regards,
    Subash

    Hi,
    loop at internal table.
    modify <Z- table > from values < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    endloop.
    or
    UPDATE <Z- table > from table < internal table Workarea>.
    if sy-subrc = 0.
      COMMIT work.
    else.
      ROLLBACK waork.
    endif.
    Prabhudas

  • Number of records in SETUP table

    Hello
    I am working with PO extractor. Is the number of records in XXXXXXSETUP table equal to the number of records setup?

    Hi if I understand the question the answer is no.  For example I have recently carried out a setup run for Stock Initialisation MC03BX0SETUP.
    The number of records in this table is just over 4000 and when I carry out an opening balance load to BW for the 2LIS_03_BX the number of records are just under 2million
    The setup tables are cluster tables

  • NUMBER OF RECORDS IN EACH TABLE???

    Hi!
    how can i find the number of records in each table in the database. the result should be like this
    table_1 123
    table_2 60
    table_3 88
    thanks!!
    also if we want to see it only for a particular schema???

    You can get all the table names and schemas from ALL_TABLES table.
    then you can stored that on a cursor,
    then you can create a function where you use an execute_immediate to run the queries dinamically. with that you can run a COUNT for each TABLE
    That's the idea give it a shot :)
    Regards

  • How  to retrieve one row from the number of records in a table

    i want to retrieve the rows from the number of records in a table without using the perticular column name.

    select count(*) from table
    /If you have your table currently analyzed, and no changes have been made, then you could
    select num_rows from user_tables where table_name = 'table'

  • Inserting records from internal table to database table

    Hi all,
    i want to insert records from internal table to zDatabase table, can u plz guide me which statement is better in performance to insert the records.
    1) insert one by one record from internal table
    loop at itab.
    insert ztable from wa.
    endloop.
    2) insert total records at a time
    INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or let me know if any other statement is there with high performance.
    i internal table contains nearly 40000 records.
    thanks.

    Hi,
    Insert the entire table at atime rather than a record so as to increase the performance.
    you can use INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or
    MODIFY ZPRODUCT FROM TABLE GI_AFPO.
    Regards,
    Raj.

  • Determine Number of  rows in Internal Table

    Hi,
      I have defined my internal table as follows:
         TYPES : BEGIN OF ABC_KEY,
                  FIELD1(2)   TYPE C,
                  FIELD2(1)   TYPE C,
                  FIELD3(8)   TYPE N,
                  END OF ABC_KEY.
    DATA: itab1 TYPE TABLE OF ABC_KEY
                      WITH KEY FIELD1,
           wa_lines_1 LIKE LINE OF itab1.
    How can I retrieve the number of rows in Internal Table?
    Thanks.
    Regards,
    bw_newbie

    You can define the number of rows of the internal table using the DESCRIBE itab command .
    As the rest have already stated a sample code snippet .
    For more info type in DESCRIBE in your prgram and click on (F1) by placing the cursor on DESCRIBE .
    You will find more options as to how you can use the DESCRIBE command according to your requirement .
    Thanks ,
    Hari

  • To delete duplicate records from internal table

    hi friends,
    i have to delete records from internal table based on following criterion.
    total fields are 7.
    out of which  if 4 fields are same and 5th field is different,then both records must be deleted.
    in case all five fields are same,the program should do nothing.
    for example.
    if there are 3 records as follows
    a1 b1 c1 d1 e1 f g
    a1 b1 c1 d1 e2 w r
    a1 b1 c1 d1 e1 j l
    then first two records should be deleted as four fields are same but fifth(e) field differs.
    but third record should remain as it is evenif first five fields are same for first and third record.
    values of last two fields need not to be consider for deleting the records.

    LOOP AT ITAB.
      V_FILED5 = ITAB-F5. "to compare later
      V_TABIX = SY-TABIX. "used to delete if condition not matches
      READ TABLE ITAB WITH KEY F1 = ITAB-F1
                               F2 = ITAB-F2
                               F3 = ITAB-F3
                               F4 = ITAB-F4.
      IF SY-SUBRC = 0.
        IF ITAB-F5 <> V_FIELD5.
    *--both the records to be deleted,as Field5 is different.
          DELETE ITAB INDEX SY-TABIX. "deletes that record
          DELETE ITAB INDEX V_TABIX. "deletes the current record
        ENDIF.
      ENDIF.
    ENDLOOP.
    Message was edited by: Srikanth Kidambi
    added comments
    Message was edited by: Srikanth Kidambi

  • Regarding how to delete the record in internal table

    Hi experts ,
    how to delete the record in intarnal table after validating the data,
    if record contains invalid fields?
    i am giving my code see this and give me the answer?
    loop at it_data into wa_data .
    Validate  Cost Center
        READ TABLE it_kostl INTO wa_kostl WITH KEY kostl = wa_data-kostl BINARY SEARCH.
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-004.
        ENDIF.
    Validate source file material ( material number )
    loop at it_mara into wa_mara .
      read table it_ausp into wa_ausp with key atwrt = wa_data-i_matnr .
               if sy-subrc NE 0 .
       PERFORM update_error_log USING wa_data
                                           text-002.
    delete it_data-objek .
         else.
      read table it_mara into wa_mara with key  matnr = wa_ausp-objek .
           if sy-subrc EQ 0 .
           wa_data-objek = wa_mara-matnr.
           wa_data-matkl = wa_mara-matkl.
         ENDIF.
         Modify it_data from wa_data  .
      endif.
    *endloop.
    Validate unit of measure (unit)
        READ TABLE it_t006 INTO wa_t006 WITH KEY msehi = wa_data-unit .
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-003.
        endif.
    Validate delivery location ( storage location )
        READ TABLE it_lgort INTO wa_lgort WITH KEY del_loc = wa_data-del_loc.
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-001.
             if wa_data-flag ='x' .
          delete it_data from  wa_data .
        endif.
        ENDIF.
    endloop.

    Hi Naren,
    First get the index number of the IT_data table and store it in one variable whose declaration like this.
    data: tabix type sy-tabix.
    while reading the internal table it_data set the tabix variable.
    tabix = sy-tabix.
    Instead of  the above use below one.
    Delete it_data-objek
    Use the Below statement it will delete  the row from the internal table.
    Delete it_data-objek index tabix
    Thanks,
    Chidanand

  • Delete records from internal table

    hi all,
    i want to delete records from intenal table which are starting with a particular starting number .
    eg internal table
    10000
    20000
    90000
    91000
    92000
    88880
    i want delete the records starting with 9 i.e. 90000 91000 92000.
    Thanks in Adv
            RAJ

    You can test this piece of code.
    DATA:
    i_tab TYPE STANDARD TABLE OF mara,
    wa_tab TYPE mara.
    wa_tab-matnr = '1000'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1002'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '1003'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '2001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '3001'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    wa_tab-matnr = '4010'.
    APPEND wa_tab TO i_tab.
    CLEAR wa_tab.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Aug 8, 2008 4:49 PM

  • How to know no of records(in Internal Table) modified after using Modify statement

    Hi Experts ,
    I am using statement Modify internal table transporting XYZ FIELD.
    I just wanted to know how many Records/Count (assuming more then 1 ) get updated just after successful execution of this command.
    Is there any system field exist?
    if yes please let me know?
    Warm Regards,
    Santosh

    Hello Santosh,
    Try like below and it works for me.
    Count will have the number rows changed.
    DATA: itab_mara TYPE STANDARD TABLE OF mara,
          itab_mara1 TYPE STANDARD TABLE OF mara,
          str_mara TYPE mara,
          str_mara1 TYPE mara,
          diff LIKE IREF-IIND,
          count TYPE int2.
    SELECT * FROM mara INTO TABLE itab_mara UP TO 10 ROWS.
      itab_mara1[] = itab_mara[].
      str_mara-lvorm = 'X'.
    MODIFY itab_mara FROM str_mara TRANSPORTING lvorm WHERE VPSTA = 'KVB'.
    LOOP AT itab_mara INTO str_mara.
      READ TABLE itab_mara1 INTO str_mara1 WITH KEY matnr = str_mara-matnr.
    CALL FUNCTION 'COMPARE_STRUCTURE_DATA'
      EXPORTING
        i_ddic_name       = 'MARA'
        i_rec_old         = str_mara
        i_rec_new         = str_mara1
       I_CHECK_MODE      = 'Y'
    IMPORTING
       E_IS_DIFF         = diff.
    IF diff = 'X'.
      count = count + 1.
    ENDIF.
    ENDLOOP.
    WRITE:/ count.
    Regards,
    Thanga

  • Maximum records an internal table can hold?

    Hi All,
        Van you tell me maximum capacity of a standard internal table and that of an extract?   How do we increase the capacity of the internal table if it is flooded?
    Thanks a lot - Chandan

    hi Chandan,
    Storage in internal Table does not depend on the number of records but depend on the memory they will be using.
    An internal table allows maximum of 2GB of storage, this can be increased by applying some patch up to 4 GB but that will degrade the programs performance.
    To resolve this limit the number of records while selecting and rerun the program as per required number of times.
    <b>
    Reward if usefull</b>

  • How to upload the flat file records into internal table by position?

    Hi
    I have a flat file which has 7 records in each row and they are NOT provided with CSV or Tab demilited...
    They are continous text without spaces....
    but i know the fixed length of each field Eg : 1st field 7 char and seconc field 3 char and so on...
    How can i upload this file into internal table by reading positions of each field...I know we can use GUI_UPLOAD and Read dataset and Open dataset...
    But please let me know to read the file with the fixed postions and load into internal table...
    Thanks in advance
    MM

    Hi
    As per my knowledge i dont think thr is some function module or so to read with a fixed positions.
    You can use the below method if you think this is the best way.
    Suppose your file has
    types : begin of ty_itab,
                field1 type char7,
                field2 type char3,
                field3 type chat3,
                field4 type char3,
                end of ty_itab.
    types : begin of ty_upload,
                 str type string,
                end of ty_upload.
    data : it_itab type standatd table of ty_itab,
              it_upload type standard table ot ty_upload,
              wa_itab type ty_itab,
              wa_upload type ty_upload.
    use gui_upload.get the data in it_upload.
    here you know that u have first 16 charcters makes a first row n then next 16 charcters next row
      Loop at it_upload into wa_upload.
       v_len =  strlen ( wa_upload ).
       v_len = v_len / 16.
        You get number of rows per record ,if it is decimal value make it final value if 3.9 make to 4.
        do v_len times.
          wa_itab = wa_upload.
          By this only first 16 characters are moved and respective fields will get a value.or else u can use offset
           wa_upload+0(16).
          append wa_itab to it_itab.
          Now shift 16 characters using shift command in wa_upload.
        enddo.
      endloop.
    Hope this syntax help you to resolve your issue.May be something i have missed .Right now i don't have sap system to send you the full correct syntax code.
    Cheers
    Joginder

  • How to get multiple records from internal table through BDC

    PERFORM DYNPRO USING:
      'X'  'SAPMM61L'  '0500',
      ' '  'BDC_OKCODE'  '=NEWC',
      'X'  'SAPMM61L'  '0500',
      ' '  'BDC_CURSOR'  'PLPTU-PLWRK(01)',
      ' '  'BDC_OKCODE'  '=TAKE',
      ' '  'PLPTU-PLWRK(01)' '2531'. (2531 is a plant)
    This is the recording used to get plant via BDC of MS31.
    Using this code i can get only single plant...
    If i want to get multiple plants from an internal table,how i can change this code?
    Since it is a recording i cant put this code in LOOP..ENDLOOP.
    Suggest any method for doing this....
    Awaiting for ur reply...

    Hi,
    While recording also record the scroll down button.
    The you can place different plant in the BDC using loop and endloop
    Regards
    Arun

  • How to fetch previous record from internal table?

    Hi,
    My final internal table (it_final) has all the data month wise year wise.(opening and closing qty)
    but if
    Material   Batch    Month   Year        opening_qty         closing_qty
    FC5431   abc        08        2008        100                       50
    FC5431   ABC       09        2009         0                          100
    Suppose I want to take PREVIOUS record(closing_qty = 50  in my 09/2009  openin_qty = 50)  how will Ido this?
    Any solution????????? BTW i m using S033 for opening an closing qt monthwise.
    Plz reply soon if anyone knows.
    Thanks and Regards,
    Archana

    Hi,
    Test the following Sample code hope will solve out your problem,
    TYPES:  BEGIN OF ty_test,
            m(3),
            open_qty TYPE i,
            close_qty TYPE i,
            END OF ty_test.
    DATA: it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE,
          wa_test LIKE LINE OF it_test,
          ctabix LIKE sy-tabix,
          ptabix LIKE sy-tabix.
    it_test-m = 'AAA'. it_test-open_qty = 100. it_test-close_qty = 50. append it_test.
    it_test-m = 'AAA'. it_test-open_qty =  0. it_test-close_qty = 100. append it_test.
    LOOP AT it_test.
      ctabix = sy-tabix.
      IF sy-tabix > 1.
        ptabix = sy-tabix - 1.
        READ TABLE it_test into wa_test INDEX ptabix.
        IF sy-subrc = 0.
          it_test-open_qty = wa_test-close_qty.
        ENDIF.
        MODIFY it_test INDEX ctabix.
      ENDIF.
    ENDLOOP.
    LOOP AT it_test.
      WRITE: it_test-m, it_test-open_qty, it_test-close_qty, /.
    ENDLOOP.
    Regards,
    Faisal

Maybe you are looking for