How to compare records in singe internal table

Hi Folks,
iam having 3 records in my first itab( T_FINAL) with fields
material no,  descrip ,  mat type and  group.
and 16 records in second itab(T_MVKE ) with fields
mat no ,  distri.chanel  and division
now I want to fetch the records from T_MVKE  by comparing the records in
T_FINAL .my requirement is to check the given mat no. in sales org.2000,2100.  if yes then i have to consider 2000 only, if it is in only 2100 then consider 2100 only . is it is in 2000 only then consider 2100 only
my code is
LOOP AT T_FINAL.
    READ TABLE T_MVKE WITH KEY MATNR = T_FINAL-MATNR.
   IF SY-SUBRC = 0.
   ON CHANGE OF T_MVKE-MATNR OR T_MVKE-VKORG.
IF T_MVKE-VKORG = '2000' and SY-TABIX > 1.
      CONCATENATE '2000' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
ELSEIF T_MVKE-VKORG = '2000' AND SY-TABIX = 1.
     CONCATENATE '2000' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
ELSE.
    CONCATENATE '2100' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
    ENDIF.
this logic fails ,. could tell me how to compare values in single itab?
Thanks
neha

Hi ,
if i've understand you correctly , try that:
LOOP AT t_final.
  AT NEW matnr.
    CLEAR: v_2000, v_2100.
*1) 2000
    READ TABLE  t_mvke    WITH KEY matnr = t_final-matnr
                                   vkorg = 2000.
    IF sy-subrc = 0.
      v_2000 = 'X'.
    ENDIF.
*2) 2100
    READ TABLE  t_mvke    WITH KEY matnr = t_final-matnr
                                   vkorg = 2100.
    IF sy-subrc = 0.
      v_2100 = 'X'.
    ENDIF.
*compare
    IF v_2000 = 'X' AND  v_2100 = 'X'.
*read 2000 only
    ELSEIF v_2000 = ' '  AND v_2100 = ' '.
*nothing found
    ELSE.
*all other combinations
*read 2100 only
    ENDIF.
  ENDAT.
ENDLOOP.
regards Andreas

Similar Messages

  • 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

  • How to insert record inside the internal table in below code

    Hi all,
    My requirement is to find the sub-total and need to insert in between the internal table.
    You can see the output ....where I want the sub-total F2 when 1 & 2 combindely , 3 , 4& 5 combindely .Please check it and let me know is it possible
    when i am using modification  it is not creating extra row inside the table instead it is modifying one row and putting the total there.
    For ex: the origianl output is
    F1   F2       F3
    A      1          1
    B      1          1
    F      2          1
    D      3          1
    E      4          1
    C      5          1
    We want to display all the total of f2 of 1-2 , 3 , 4-5
    so expcected output is
    F1   F2       F3
    A      1          1
    B      1          1
    F      2          1
         *              3  ->This is the sub-total of 1& 2 of f2
    D      3          1
            *           1 ->this is the sub-total of 3
    E      4          1
    C      5          1
          *             2 -> this is the sub-total of 4 & 5
    = space
    But coming output is
    A 1          1
    B 1          1
    *             3 -> it is modifying the F row and inserting the total .Total is comong correct but is shoule insert  instead of modifying the record!!
      *           1
    E  4          1
    *             2
    Please help how to insert the row total at the end of the chage of field
    Please find the below code ..Due to space problem i am attaching below
    Sas

    Here is the solution ....i Got the answer Thanks for your helping hands friends
    REPORT  YTEST_MODIFY.
    DATA: BEGIN OF ITAB OCCURS 1,
    TOT TYPE C,
    F1 TYPE C,
    F2 TYPE C,
    F3 TYPE I ,
    END OF ITAB.
    DATA: BEGIN OF JTAB OCCURS 1,
    F1 TYPE C,
    F2 TYPE C,
    F3 TYPE I ,
    END OF JTAB.
    START-OF-SELECTION.
      ITAB-F1 = 'A'.
      ITAB-F2 =  1.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'B'.
      ITAB-F2 =  1.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'C'.
      ITAB-F2 =  5.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'D'.
      ITAB-F2 =  3.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'E'.
      ITAB-F2 =  4.
      ITAB-F3 =  1.
      APPEND ITAB.
      ITAB-F1 = 'F'.
      ITAB-F2 =  2.
      ITAB-F3 =  1.
      APPEND ITAB.
      SORT ITAB BY F2.
      LOOP AT ITAB.
        WRITE:/1 ITAB-F1 ,
              8 ITAB-F2 ,
              10 ITAB-F3 .
      ENDLOOP.
      LOOP AT ITAB.
        IF ITAB-F2 = 1 OR ITAB-F2 = 2.
          ITAB-TOT = 1.
          MODIFY ITAB.
        ELSEIF ITAB-F2 = 3.
          ITAB-TOT = 3.
          MODIFY ITAB.
        ELSEIF ITAB-F2 = 4 OR ITAB-F2 = 5.
          ITAB-TOT = 4.
          MODIFY ITAB.
        ENDIF.
      ENDLOOP.
      SKIP 2.
      SORT ITAB BY TOT.
      DATA : L_SUM(2) TYPE C,
             L_ROW(2) TYPE C.
      LOOP AT ITAB.
        MOVE-CORRESPONDING ITAB TO JTAB.
        APPEND JTAB.
        L_SUM = L_SUM + ITAB-F3 .
        AT END OF TOT.
          CLEAR JTAB.
          JTAB-F3 = L_SUM .
          APPEND JTAB.
          CLEAR L_SUM.
        ENDAT.
      ENDLOOP.
      LOOP AT JTAB.
        WRITE:/1 JTAB-F1 ,
              8 JTAB-F2 ,
              10 JTAB-F3 .
      ENDLOOP.
    *  DATA: a TYPE i , b .
    *  LOOP AT itab.
    *    IF b = 0.
    *      a = a + itab-f3.
    *    ENDIF.
    *    AT END OF tot.
    *      MOVE space TO itab-f1.
    *      MOVE space TO itab-f2.
    *      MOVE a TO itab-f3.
    *      MODIFY itab .
    *      CLEAR a.
    *      b = 1.
    *    ENDAT.
    *    b = 0.
    *  ENDLOOP.
    *  LOOP AT itab.
    *    MOVE-CORRESPONDING itab TO jtab.
    *    APPEND jtab.
    *  ENDLOOP.
    *  ULINE.
    *  LOOP AT jtab.
    *    WRITE: / jtab-f1 , jtab-f2 , jtab-f3.
    *  ENDLOOP.

  • How to append records between two internal tables

    hi all,
    im trying to append from an internal table to another internal table with same structure. i tried the following but it overwrites previous contents of i_dest:
    move i_src to i_dest
    thanks,
    sid

    hey u try to move it record by record
    <b>itab2 = itab.
    append itab2.</b>
    This should work I guess
    just check the code below, if u want to move the whole itab into itab2 then use <b>itab2[] = itab.</b>
    <b>loop at it_pgm.
      read table itab with key obj_name = it_pgm-pgm_name.
      if sy-subrc = 0.
        itab_final-obj_name = itab-obj_name.
        itab_final-func_spec = itab-func_spec.
        itab_final-func_area = itab-func_area.
        itab_final-dev_class = itab-dev_class.
        append itab_final.
    else.
       itab_alt-pgm_name = it_pgm-pgm_name.
       append itab_alt.
      endif.</b>
    please reward points if found helpful

  • How to get records into two internal tables from 1 internal table?

    VERME                                                                     LGPLA
    252.000  EA  300     0149A                                  410     0149
    276.000  EA  300     0149A                                  410     0107
    516.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    I have above records in my one internal table ITAB.
    I want to divide these records in to two internal tables ITAB1 and ITAB2. and this is based on LGPLA and VERME.
    If there is same LGPLA (last column) and different VERME (1st column) available, then it should append ITAB1
    Otherwise it should append ITAB2.
    ITAB1 should contain ,
    516.000  EA  300     0149A                                  400     3013
    ITAB2 should contain ,
    252.000  EA  300     0149A                                  410     0149
    276.000  EA  300     0149A                                  410     0107
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    528.000  EA  300     0149A                                  400     3013
    I have tried with this code
    Loop at itab….
    IF lv_prev_lgpla = wa-lgpla and lv_prev_verme <> wa-verme.
          APPEND wa TO itab1.
    else.
          APPEND wa TO itab2.
    endif.
    lv_prev_lgpla = wa-vlpla.
    lv_prev_verme = wa-anfme.
    Endloop.
    But it contains,
    516.000  EA  300     0149A                                  400     3013
    in table ITAB2 which I don’t want.
    Points rewarded soon.
    Regards,
    Ronn

    Dear Ronny,
    i am gining the solution below.But would request you to change your ITAB STRUCTURE LIKE THIS BEFORE USING THE CODE
    VERME LGPLA
    252.000 EA 300 0149A  0149 410
    276.000 EA 300 0149A  0107 410
    516.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    528.000 EA 300 0149A  3013 400
    then do as follows.
    SORT ITAB BY LGPLA VERME.
    LOOP AT ITAB INTO WITAB.
    W_INDEX = SY-TABIX.
    here take all the abOve fields in temp fieds.
    LW_VERME = WITAB-VERME..AND SO ON.
      AT END OF LGPLA.
       MOVE: all LW fields to work area of ITAB1
       APPEND work area of ITAB1 TO ITAB1.
       DELETE ITAB INDEX W_INDEX
      ENDAT.
    ENDLOOP.
    Basically what u r doing here is thet u r using processing event.
    So whenerv VERME changes this event will be triggered.
    Just try this out...something like this only will be he logic.
    Please let me know further

  • How to compare record count of two tables?

    Hi,
    i am in need of simple sql script where i can compare two table record count.
    i have something like below:
    (select count(*) from table1) minus (select count(*) from table2)
    now the problem is if the table1 count greater then table2 count the output is fine.
    If the table2 record count is more then i am getting zero as the output.
    how can i get the difference in two tables record count?
    Thanks a lot in advance.
    --Raman.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Doing a MINUS between the counts does not yield the diff.
    e.g. if table A has 100 records and table B has 70 records then,
    SELECT count(*) FROM A
    minus
    SELECT count(*) from B
    will give 100 and not 30.
    Try this:
    SELECT (
    CASE WHEN ((select count(*) cnt from A) - (select count(*) cnt from B)) <0
    THEN ((select count(*) cnt from A) - (select count(*) cnt from B))* -1
    ELSE ((select count(*) cnt from A) - (select count(*) cnt from B)) END) Difference
    FROM dualor this is simpler
    SELECT abs(((select count(*) cnt from A) - (select count(*) cnt from B))) difference FROM dualEdited by: Caitanya on Jan 9, 2009 7:12 AM
    Applied abs function after seeing BluShadow's post :)

  • How to compare records in the same table?

    I have a table of course registrations.  I would like to select course registrations as of a certain date that do not have a dropped status against it.
    CREATE TABLE REGISTRATIONS
    (ID VARCHAR(7) ,
    COURSE VARCHAR(4),
    CURRENT_STATUS VARCHAR(10),
    STATUS_DATE VARCHAR(10))
    INSERT INTO REGISTRATIONS
    (ID, COURSE, CURRENT_STATUS, STATUS_DATE)
    VALUES
    ('1111111','ADMN', 'REGISTERED', '2014-04-10'),
    ('1111111','MATH', 'REGISTERED', '2014-04-10'),
    ('1111111','ADMN', 'DROPPED', '2014-04-10'),
    ('1111111','MATH', 'DROPPED', '2014-04-12'),
    ('1111111','BIOL', 'REGISTERED', '2014-04-10')
    SELECT * FROM REGISTRATIONS
    ORDER BY COURSE, CURRENT_STATUS
    drop table REGISTRATIONS
    ID COURSE CURRENT_STATUS STATUS_DATE
    1111111 ADMN DROPPED 2014-04-10
    1111111 ADMN REGISTERED 2014-04-10
    1111111 BIOL REGISTERED 2014-04-10
    1111111 MATH DROPPED 2014-04-12
    1111111 MATH REGISTERED 2014-04-10
    The above example shows that ID '1111111' has registered for ADMN and BIOL on April 10th but dropped ADMN the same day.  It also shows that they registered for MATH on April 10th but dropped it on the 12th.
    If I were to select course registrations to date as of April 10 I would see both ADMN records, BIOL and MATH.  BIOL and MATH would be OK but I don't want to see the ADMN data in the result because they have essentially cancelled themselves out. 
    In saying that, how do I write a script to select all course registrations as of a certain date but omit the ones that have been dropped at anytime before the select date?

    check below,
    SELECT * FROM REGISTRATIONS a
    WHERE CURRENT_STATUS <> 'DROPPED' AND STATUS_DATE <= '2014-04-12'
    AND COURSE NOT IN (
    SELECT COURSE FROM REGISTRATIONS
    WHERE CURRENT_STATUS = 'DROPPED' AND STATUS_DATE <= '2014-04-12')
    ORDER BY a.COURSE, a.CURRENT_STATUS

  • How to display first three records of an internal table

    hi,
    I have a requirement, in which i want to display the first 3 records of an internal table.
    Pls help me.
    Regards,
    Vipin

    Hi,
    data: count type sy-tabix.
    count = 1.
    if count <  4.
    loop at itab.
    write: / Field.
    endloop.
    endif.
    Reward if helpful.
    Regards.

  • How to collect similar record from the internal table

    I need to collect exact matched records from 1 internal table to another internal table by searching 5 fields. I need to have records which are exactly matched for 5 fields. i have written a code wich is mention below it gave me only similar records but not 100% matched record.. would you like to help me. any correction, suggetion,. Will be great help to me.

    To get exact match of 5 records, do as follows.
    Check whether internal table gives only one record or not after READ statement.If internal table gives more than one entry for READ then the results will be improper.
    I think there is no need of READ statement on same internal table within LOOP. I commented the same in code.
    sort i_bp_p by title initials name_last idnumber idtype f50code rbcode. "acc_num.
    loop at i_bp_p into wa_i_bp_p.
    *lv_tabix = sy-tabix.
    *read table i_bp_p index lv_tabix into wa_i_bp_p.read table i_but0id into wa_but0id with key idnumber = wa_i_bp_p-idnumber
    idtype = wa_i_bp_p-idtype binary search.
    if sy-subrc = 0.
    read table i_but000 into wa_but000 with key title = wa_i_bp_p-title
    initials = wa_i_bp_p-initials
    name_last = wa_i_bp_p-name_last binary search.
    if sy-subrc = 0.
    read table i_but0is into wa_but0is with key f50code = wa_i_bp_p-f50code
    rbcode = wa_i_bp_p-rbcode binary search.
    if sy-subrc = 0.
    move-corresponding wa_i_bp_p to i_bp_p100.
    append i_bp_p100.
    endif.
    endif.
    endif.
    endloop.
    sort i_bp_p100 by partner.
    loop at i_bp_p100.
    write : /10 i_bp_p100-partner,
    20 i_bp_p100-title,
    30 i_bp_p100-initials,
    40 i_bp_p100-name_last,
    53 i_bp_p100-idnumber,
    70 i_bp_p100-idtype,
    85 i_bp_p100-rbcode,
    95 i_bp_p100-f50code.
    endloop.
    sort i_bp_p by title initials name_last idnumber idtype f50code rbcode. "acc_num.
    loop at i_bp_p into wa_i_bp_p.
    lv_tabix = sy-tabix.
    read table i_bp_p index lv_tabix into wa_i_bp_p.
    if sy-subrc = 0.
    read table i_but0id into wa_but0id with key idnumber = wa_i_bp_p-idnumber
    idtype = wa_i_bp_p-idtype binary search.
    if sy-subrc = 0.
    read table i_but000 into wa_but000 with key title = wa_i_bp_p-title
    initials = wa_i_bp_p-initials
    name_last = wa_i_bp_p-name_last binary search.
    if sy-subrc = 0.
    read table i_but0is into wa_but0is with key f50code = wa_i_bp_p-f50code
    rbcode = wa_i_bp_p-rbcode binary search.
    if sy-subrc = 0.
    move-corresponding wa_i_bp_p to i_bp_p100.
    append i_bp_p100.
    endif.
    endif.
    endif.
    endif.
    endloop.

  • 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

  • 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.

  • Comparing Duplicates in an internal table

    Hi ,
    Can anyone let me know , how to compare two duplicate records in an internal table.
    is there any Function Module or Command for it.
    Please let me know .
    Thank you ,
    Regards,
    Roby

    Check this logic works:
    REPORT  yspra_sample89.
    TYPES: BEGIN OF ty_data,
              column1 TYPE char10,
              column2 TYPE char10,
           END OF ty_data.
    DATA: i_data TYPE ty_data OCCURS 0 WITH HEADER LINE,
          i_data_repeat TYPE ty_data OCCURS 0 WITH HEADER LINE.
    DATA: wa_data TYPE ty_data,
          wa_data1 TYPE ty_data.
    DATA: lines TYPE sy-tabix.
    i_data-column1 = '10'.
    i_data-column2 = '20'.
    APPEND i_data.
    i_data-column1 = '10'.
    i_data-column2 = '20'.
    APPEND i_data.
    i_data-column1 = '10'.
    i_data-column2 = '20'.
    APPEND i_data.
    i_data-column1 = '10'.
    i_data-column2 = '20'.
    APPEND i_data.
    SORT i_data BY column1 column2.
    LOOP AT i_data INTO wa_data.
      lines = sy-tabix + 1.
      READ TABLE i_data INTO wa_data1 INDEX lines.
      IF sy-subrc = 0.
        IF wa_data = wa_data1.
          APPEND wa_data1 TO i_data_repeat.
        ENDIF.
      ENDIF.
      CLEAR: lines, wa_data, wa_data1.
    ENDLOOP.
    LOOP AT i_data_repeat.
      WRITE: / i_data_repeat-column1 , i_data_repeat-column2.
    ENDLOOP.
    Sort ur table first and read the next row if it duplicate append it to some internal. In this way u can take all the duplicate records.
    Regards,
    Prakash.

  • Filtering records from one internal table based on ranges in another itab

    Hi guys,
    I have 1 internal table with set of GL accounts. I have 2nd internal table where lower interval  and upper interval of GL accounts
    How to filter out records from 1 internal table by comparing with the GL account ranges present in 2nd internal table.
    Please reply.

    Hi
    Create a RANGE for GL Accounts.
    LOOP the second Internal Table.
    And assign HIGH & LOW to ranges from second ITAB.
    And Delete the accounts which are not there in the range.
    Use the below code as reference.
    DATA: itab TYPE TABLE OF mara WITH HEADER LINE.
    DATA: r_matnr TYPE RANGE OF matnr WITH HEADER LINE.
      SELECT * FROM mara INTO TABLE itab UP TO 10 ROWS.
      r_matnr-sign = 'I'.
      r_matnr-option = 'BT'.
      r_matnr-low  = '000000000016900036'.
      r_matnr-high = '000000000016900040'.
      APPEND r_matnr.
      DELETE itab WHERE matnr NOT IN r_matnr.

  • 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 entries in an internal table except for one entry

    Hi all,
    I have 4 records in my internal table and I need to delete all the  records in the internal table except the last one.How do i do this?Any sample code?
    Thanks.
    Moderator message - Please do not ask or answer basic questions - thread locked
    Edited by: Rob Burbank on Dec 16, 2009 3:23 PM

    Hi,
      use following logic:
    DATA: lt_itab type standard table.
    DATA: l_lines type i.
    DESCRIBE TABLE lt_itab lines l_lines.
    l_lines = l_lines - 1.
    delete lt_itab from 1 to l_lines.
    Regards,
      Karol

Maybe you are looking for

  • HELP! Time Capsule painfully slow

    OK, so I bought a new 1TB Time Capsule yesterday. I installed it yesterday and during configuration, it copied over the profile from my old Airport Base Station. My internet slowed down dramatically (1.5B per dsl reports) and I started my Time Machin

  • Adobe Photoshop Incompatible with Windows 7 ?

    I typically do not have problems installing Microsoft products, Corel products, HP products, AV software, dozens of other companies products on my Windows 7 Home Premium computer. I have never had problems installing Adobe products on ME, XP, Vista.

  • Null pointer exception in the morning

    Hi all, I have built a custom JSP DYN page application that for the most part works ok. However, I've found on occassion that when I arrive in the morning, the application errors out in our dev and qa portal environments with a null pointer exception

  • App Store says 8 updates. When I select App Store the button says 8 updates but screen is white (blank)

    App Store says I need 9 updates but the screen is blank (white)

  • Problem in archiving change document

    Hi Experts, While doing function ' check in archive ' (CV02N) I am getting error that "problem in archive path" Can anybody tell me what may be the problem for this and how to overcome the same? Please do the needful. Thanks and best regards, Pravee