How to delete blank records in internal table

Hi.
please tell me how can i delete blank records in an internal table.
thnx

In that case
Suppose you have 10 fields in internal table and if any of them is blank, you need to delete record.
Try this command
delete itab where field1 is initial or
                  field2 is initial or
                  field10 is initial.

Similar Messages

  • 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

  • How to Delete a Column in Internal Table

    Hi All,
    Does any one know ,How to Delete a Column in Internal Table?

    Hi,
       For deleting the column in the internal table, you have to eliminate the field which you want to delete.
    loop at itab into wa.
      move corresponding wa to wa1.
    append wa1 to itab1.
    clear wa1.
    clear wa.
    endloop.
    wa1 is the workarea without the field which you want to delete.
    itab1 is the internal table which consists of the deleted column.

  • How to delete a record from BSEG table

    Dear Experts,
    How to delete a record from BSEG table.
    If there possible to delete some records from transparent table ?
    Please help.
    Regards,
    Tan

    Hi,
    Deleting a record from a standard table can be done only if table maintenance exists - Cehck tcode - SM30.  But it is not advisable to delete records, coz the records may be dependent on many other tables.  If u delete in a single place, there may be chance that inconsistency in the data happens and hence will affect ur financial statements.
    Pls. assign points, if useful
    Regards,
    Sridevi

  • 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

  • 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

  • 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 delete data from dynamic internal table

    Hi,
    I have dynamic internal table and I have some slection screen fields , using these selection screen fields
    (select -options), I have to filter the data? assigning will work with READ , but I have select options not the parametre,
    and also delete will not work for dynamic table..
    as we cannot use assigning with delete..
    So how to do this?
    and one more thing is , I cannot filter the data while selection( in select, I cannot filter the data-> as it's not coming directly from table, it's coming from buffer),
    so now after selection of data, I need to filter the data from dynamic table.
    Is there any way to do this?
    Regards,
    Mrunal

    Hi matt,
    I tried with below code as  you said. But I am getting dump. can you help?
    here is my piece of code.
    FIELD-SYMBOLS: <LS_DATA> type any,
                               <LT_DATA> TYPE table,
                                <L_FIELD> type any.
        ASSIGN <l_buffer_entry>-dataptr->* TO <LS_DATA>.
        ASSIGN <l_buffer_entry>-dataptr->* TO <LT_DATA>.
    LOOP AT <LT_DATA> ASSIGNING <LS_DATA>.
    ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
    IF <L_FIELD> NOT IN SO_BUKRS.
    DELETE <LT_DATA>.
    ENDIF.
    UNASSIGN <L_FIELD>.
    ASSIGN COMPONENT 'BELNR' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
    IF <L_FIELD> NOT IN SO_BELNR.
    DELETE <LT_DATA>.
    ENDIF.
    UNASSIGN <L_FIELD>.
    ENDLOOP.
    and here is the description of my dump:->>>
    You attempted to access an unassigned field symbol
    (data segment 32772).
    This error may occur for any of the following reasons:
    - You address a typed field symbol before it is set using ASSIGN
    - You address a field symbol that points to a line in an internal table
      that has been deleted
    - You address a field symbol that had previously been reset using
      UNASSIGN, or that pointed to a local field that no longer exists
    - You address a global function interface parameter, even
      though the relevant function module is not active,
      that is it is not in the list of active calls. You can get the list
      of active calls from the this short dump.

  • 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

  • How to delete the record in the table without using lead selection?

    hi,
    I have added the separate column "delete" to the table uielement and so for each record or row of the table the appropriate "delete" link to action will be there................the code below works when the particular row is selected through lead selection only.......
    help me how to delete without using lead selection.....
      DATA:
      NODE_MODULE                         TYPE REF TO IF_WD_CONTEXT_NODE,
      ELEM_MODULE                         TYPE REF TO IF_WD_CONTEXT_ELEMENT,
      STRU_MODULE                         TYPE IF_V_MODULE=>ELEMENT_MODULE .
       data itab TYPE TABLE OF zac_modules.
      navigate from <CONTEXT> to <MODULE> via lead selection
      NODE_MODULE = WD_CONTEXT->GET_CHILD_NODE( NAME = `MODULE` ).
      get element via lead selection
      ELEM_MODULE = NODE_MODULE->GET_ELEMENT(  ).
      get all declared attributes
      ELEM_MODULE->GET_STATIC_ATTRIBUTES(
        IMPORTING
          STATIC_ATTRIBUTES = STRU_MODULE ).
    NODE_MODULE->GET_STATIC_ATTRIBUTES_TABLE(
        IMPORTING
         TABLE  = itab )
    DELETE itab WHERE zmodule_id = STRU_MODULE-zmodule_id.
    CALL METHOD NODE_MODULE->BIND_TABLE
        EXPORTING
          NEW_ITEMS            = itab
       SET_INITIAL_ELEMENTS = ABAP_TRUE
       INDEX                =
    ENDMETHOD.

    Hi  ,
    The onclick event provides you with a standard paramater "CONTEXT_ELEMENT" which has the element from which the event is triggered.
    so you can declare this in the handler(if it is not there) and use it as follows.
    CONTEXT_ELEMENT  TYPE REF TO IF_WD_CONTEXT_ELEMENT  an importing paramater.
    DATA:
    NODE_MODULE TYPE REF TO IF_WD_CONTEXT_NODE,
    ELEM_MODULE TYPE REF TO IF_WD_CONTEXT_ELEMENT,
    STRU_MODULE TYPE IF_V_MODULE=>ELEMENT_MODULE .
    data itab TYPE TABLE OF zac_modules.
    CONTEXT_ELEMENT->GET_STATIC_ATTRIBUTES(
    IMPORTING
    STATIC_ATTRIBUTES = STRU_MODULE ). "Using the context_element paramater to get the static attributes.
    NODE_MODULE->GET_STATIC_ATTRIBUTES_TABLE(
    IMPORTING
    TABLE = itab )   "getting all the data.
    DELETE itab WHERE zmodule_id = STRU_MODULE-zmodule_id. "deleting the particular row from the table and binding it.
    CALL METHOD NODE_MODULE->BIND_TABLE
    EXPORTING
    NEW_ITEMS = itab
    * SET_INITIAL_ELEMENTS = ABAP_TRUE
    * INDEX =
    thanks,
    Aditya.

  • How to delete space in an internal table

    Hi All,
    In internal table I want to compress the leading space
    After searching I found Condense and SHIFT LEFT DELETE leading space commands work it is written...
    but when I write code A single space is appreaing in between the two fields...can any body help me where I am going wrong??
    Ex:
    data: begin of itab occurs 1 ,
    PSAtext TYPE CHAR15,
    psa type btrtl,
    end of itab.
    now o/p BEFORE CHANGE IS :
    SBI-CT    |1023
    After condense is SBI-CT |1023
    bETWEEN SBI-CT AND | there is a additional space. How can we avoid that?
    Sas
    Edited by: saslove sap on Sep 29, 2010 7:43 AM

    Well this is what I am going to solve this
    data:begin of STRING OCCURS 1 ,
    S1 TYPE STRING,
    END OF STRING.
    loop at itab.
    concatenate itab-f1 itab-f2 into string-s1 seperated by '|'.
    append string.
    end of itab.
    then I can transfer this string to Application server.
    Thanks for all the contributions.
    Regards
    sas

  • Unable to delete double records from internal table

    Hi all,
    The internal table is like this
    begin of ta_itab1 occurs 0,
          mark type c,
          cnt_hedg type c,
          kunnr like vbak-kunnr,
          vbeln like vbak-vbeln,
          posnr like vbap-posnr,
          matnr like vbap-matnr,
          kwmeng like vbap-kwmeng,
          h_kwmeng like vbap-kwmeng,
          spart like vbap-spart,
          werks like vbap-werks,
          component like bom_item_api01-component,
          comp_qty like bom_item_api01-comp_qty,
          comp_qty1 like bom_item_api01-comp_qty,
          base_quan like stko_api02-base_quan,
          comp_unit like bom_item_api01-comp_unit,
          base_unit like bom_item_api01-comp_unit,
          bukrs_vf like vbak-bukrs_vf,
          end of ta_itab1.
    and used the sytax:
    sort ta_itab6 by kunnr vbeln.
    DELETE ADJACENT DUPLICATES FROM ta_itab6 comparing COMP_QTY COMP_QTY1.
    but Im unable to delete duplicate record .
    Thank You.
    anu

    Hi ,
    You need to use the fields in sort statement on whichyiu wnat to perform Delete Adjacent duplicates..
    sort ta_itab6 by kunnr vbeln COMP_QTY COMP_QTY1.
    DELETE ADJACENT DUPLICATES FROM ta_itab6 comparing COMP_QTY COMP_QTY1.

  • Deleting blank spaces in internal table

    Hi Gurus,
    I want to delete the empty spaces of a particular field in internal table.I used condense and shift statements but didnt work because the work area value is already condensed.I am not sure why the internal table field is having so much of empty spaces to its left.It's a character field with length 60.
    Please suggest.

    Hi,
    This is the rellevant code   
    LOOP AT IT_HIER INTO WFL_HIER.
            WFL_FINAL-NODEID = WFL_HIER-NID.
            WFL_FINAL-IOBJNM = WFL_HIER-IOBJ.
            WFL_FINAL-NODENAME = WFL_HIER-NNAME.
            WFL_FINAL-PID = WFL_HIER-PID.
            condense wfl_hier-desc.
            WFL_FINAL-DESCRIPTION = WFL_HIER-DESC.
            SHIFT WFL_FINAL-DESCRIPTION LEFT DELETING LEADING SPACE.
            APPEND WFL_FINAL TO E_T_DATA.
            CLEAR WFL_FINAL.
            CLEAR: WFL_HIER,OUT.
          ENDLOOP.
    The problem is not with the work area.
    Say if I have a value apple in the work area wa, (wa - 'apple').
    It doesnt have any leading sapces to the left.
    But when I am appending it to the internal table it gets posted at the last say like this (it -  '                                       apple'.
    It occupies the last five characters.
    Not sure how to resolve this.

  • Delete matching records from internal table

    I have two internal tables.
    say :
    1)zsd80
    2)i_vbrk
    i want to delete records from i_vbrk which are not in zsd80.
    this is my code. but it shows dump error after executing. please help.
    LOOP AT i_zsd80 INTO zsd80.
                LOOP AT i_konv INTO w_konv FROM w_index.
                  IF w_konv-kschl NE zsd80-kschl.
                    DELETE i_konv FROM w_konv.
                  ENDIF.
                ENDLOOP.
              ENDLOOP.

    Hi,
    Do like this...
    1. Loop at the where u want to delete..
    2. store the sy-index...
    3. read the other table....
    4. if nothing found  in read then delete that index...
    LOOP AT i_vbrk.
      TABIX = SY-TABIX.
      READ TABLE zsd80 WITH KEY .......
      IF SY-SUBRC NE 0.
        DELETE IT_VBRK INDEX TABIX.
      ENDIF.
    ENDLOOP.
    regards
    Sukriti.....
    Edited by: Sukriti Saha on Nov 3, 2008 1:19 PM

  • How to delete the entries in internal table

    Hi Experts,
    I have 2 internal tables ,
    if i find any same entries of 2 internal tables,  i have to delete that entries in first internal table.
    Regards,
    Srinivasu

    hi check this..
    report .
    data:begin of itab occurs 0,
         f1 type c ,
         f2 type i,
         end of itab .
    data:begin of itab1 occurs 0,
         f1 type c ,
         end of itab1 .
         itab-f1 = 'A'.
         itab-f2 = 12.
         append itab .
         itab-f1 = 'b'.
         itab-f2 = 12.
         append itab .
         itab-f1 = 'c'.
         itab-f2 = 12.
         append itab .
         itab1-f1 = 'A'.
         append itab1 .
    loop at itab1 .
    read table itab with key f1 = itab1-f1 .
    if sy-subrc  = 0.
    delete itab where  f1 = itab1-f1 .
    endif .
    endloop.
    loop at itab.
    write:/ itab-f1,itab-f2.
    endloop.

Maybe you are looking for