Table maintenance in a loop?

I have a situation that I'm having trouble resolving.
I'm looping through this list, each time getting a table of keys and offsets. But each time I loop through it, I only want to retain the records that are common and get rid of new or unique records.
I'm thinking the code should be something like:
Loop at itab1.
  call function ...
     exporting
        e_result = reference []
  if count = 0.
     master_list = reference.
     count = count + 1.
  ELSE.
     DELETE FROM MASTER_LIST WHERE RECORDS DON'T MATCH UP IN reference. ???
  ENDIF.
ENDLOOP.
Please help out,
Natasha

Not the prettiest way of doing it, but here is a sample program.
report zrich_0002 .
data: begin of itab occurs 0,
      field1 type c,
      field2 type c,
      field3 type c,
      end of itab.
start-of-selection.
  itab-field1 = 'A'.
  itab-field2 = 'B'.
  itab-field3 = 'C'.
  append itab.
  append itab.
  itab-field1 = 'C'.
  itab-field2 = 'D'.
  itab-field3 = 'E'.
  append itab.
  itab-field1 = 'F'.
  itab-field2 = 'G'.
  itab-field3 = 'H'.
  append itab.
  append itab.
  data: counter type i.
  loop at itab.
    clear counter.
    loop at itab where field1 = itab-field1.
      counter =  counter + 1.
    endloop.
    if counter =  1.
      delete itab.
      continue.
    endif.
  endloop.
  check sy-subrc  = 0.
Regards,
Rich Heilman

Similar Messages

  • How to use the table maintenance events for validating the input entries..?

    Hi,
    I have created a Z table with 6 fields in which all are KEY fields. All are of CHAR type. I have created the Table Maintenance Generator for the same. While maintaining the entries in the table, even though I maintain a blank entry for a field it is saving the entry. But, I don't want that way. All the fields are mandatory in my table. One should enter all the fields. Otherwise it should not allow to save the entry. So, I think it can be done using the Table Maintenance Events. can someone tell me how to use the Table Maintenance Events. and which event to use for my reuqirement and what is the logic to be written.
    Or Is there any other way to solve my problem.
    Please share your inputs. Thanks in advance.
    Best regards,
    paddu.

    In the table maintenance generator, Environment --> Modifications --> Events then a screen will be appear here,we need to create the Events.In the EVENTS screen, press new Entries, there give 01(Before Saving the Data in the Database) and give a name(This will become a PERFORM), then click the Editor pushbutton, this will be there at the right side of the entry, then a popup will be appear, you can create an include program, there inside of the include program write ur code.
    Here is documentation for Event 01(Before Saving the Data in the Database )
    Event 01: Before Saving the Data in the Database
    Use
    This event occurs before new, changed or deleted entries are written to the database. Other activities can be performed, for example:
    hidden entry processing
    fill hidden fields
    flag data to be written to hidden tables after the database change.
    To have the changes saved by the central maintenance dialog routines, SY-SUBRC must be set to 0 at the end of the routine.
    Realization
    This event has no standard routine. The following global data is available for the realization of the user routine:
    internal table TOTAL
    field symbols
    field symbols <ACTION> and <ACTION_TEXT>
    <STATUS>-UPD_FLAG
    If internal table data are to be changed before saving, t he changes should be made in both the internal table TOTAL and in the internal table EXTRACT.
    FORM abc.
    DATA: F_INDEX LIKE SY-TABIX. "Index to note the lines found
    LOOP AT TOTAL.
    IF <ACTION> = desired constant.
    READ TABLE EXTRACT WITH KEY <vim_xtotal_key>.
    IF SY-SUBRC EQ 0.
    F_INDEX = SY-TABIX.
    ELSE.
    CLEAR F_INDX.
    ENDIF.
    (make desired changes to the line TOTAL)
    MODIFY TOTAL.
    CHECK F_INDX GT 0.
    EXTRACT = TOTAL.
    MODIFY EXTRACT INDEX F_INDX.
    ENDIF.
    ENDLOOP.
    SY-SUBRC = 0.
    ENDFORM.
    Regards,
    Joy.

  • Events in table maintenance generator 01

    Hi all,
           I have an urgent requirement regarding the events in table maintenance generator.The requirement is i have a qty field in table i want to change the existing value it should allow only a lesser value.How to use TOTAL and EXTRACT structures.
    it is urgent.please help me out.
    Thanks & regards,
    Kranthi

    Follow the example below:
    form get_vendor_name.
      data w_extract type z_table.
      data begin of w_total.
              include structure z_table.
      data: action,
            mark,
      end of w_total.
      loop at extract into w_extract.
        check not w_extract-z_vend_no is initial.
        select single name1 from lfa1
                           into  w_extract-z_vend_name
                           where lifnr = w_extract-z_vend_no.
        modify extract from w_extract.
      endloop.
      loop at total into w_total.
        check not w_total-z_vend_no is initial.
        select single name1 from lfa1
                           into  w_total-z_vend_name
                           where lifnr eq w_total-z_vend_no.
        modify total from w_total.
      endloop.
    endform.
    Reward points if useful.
    Regards.

  • Table maintenance events

    Hello,
    Does anyone has a code example of table maintenance events?
    I have a custom table ( zitab ) , with a maintenance view in SM30. I would like to use the table maintenance events for some authorisation check before the data is displayed, then, depending on the authorisation, display what the user is authorised to see. After data input, perform validation, if errors occur, inform the user what the problem is, if not, save in tha z table.
    Can this be done in sm30 or I need to write a new program?
    Thank you!

    Can someone please explain me why I have this short dump (before save event)?
    Error analysis
        The statement
          "MOVE src TO dst"
        requires the operands "dst" and "src" to be comvertible.
        Since this statement occurs in a Unicode program, the special
        convertibility rules for Unicode programs apply. In this case, the
        following rules have been broken:
    Source Code Extract
    Line  SourceCde
        1 ----
        2 ***INCLUDE LYTableF04 .
        3 ----
        4
        5 form before_save.
        6
        7 DATA: l_field_is_blank.
        8   DATA: BEGIN OF s_ytable.
        9           INCLUDE STRUCTURE ytable.
       10           INCLUDE STRUCTURE vimtbflags.
       11   DATA: END OF s_ytable.
       12
       13   LOOP AT total.
       14     CLEAR s_ytable.
    >>>>>     MOVE total TO s_table.
       16
       17   ENDLOOP.
       18
       19 endform.
    In all examples that i read on this forum this code works, I don't know why it fails for me.

  • Issuing an Error in Table Maintenance Event

    Hi,
    How can I issue an error in the table maintenance event without exiting the screen.
    When an event is triggered (Before Save), it will perform a check in the data changed or created. It will issue an error when the changes are not correct. But when I press enter or click on the check button, it will exit the table maintenance screen.
    What do I have to do in order to issue an error but will still go back to the table maintenance view.
    Making the message as information or type I, will not work because it will still save.

    Hi,
    I came to the same problem, maybe this will help someone.
    You can move check into view cluster event.
    1. load the view
         PERFORM vcl_set_table_access_for_obj
              USING 'view'
              CHANGING error_flag.
    2. assing to structure
         LOOP AT <vcl_total> INTO ls_view
    3. perform check, set VCL_STOP which will stop saving and will display message
         VCL_STOP = 'X'.
         MESSAGE ....

  • SELECT-OPTIONS in table maintenance generator screen

    Hi
    Is it possible to create SELECT-OPTIONS in table maintenance screen?
    My requirement is to allow the user to enter single Company code and Range of G/L Accounts in the Table Maintenance input screen. Please let me know.
    Thanks
    Abdul Hakim

    Hello Tamas,
    As a matter of fact we can add a custom selection-screen to the TMG screen & without manually modifying the TMG
    You can do so by using the [Event AA: Instead of the Standard Data Read Routine|http://help.sap.com/saphelp_nw04s/helpdata/en/91/ca9f56a9d111d1a5690000e82deaaa/content.htm].
    Please check the code snippet:
    DATA: gv_fldate TYPE s_date.
    * User-defined selection-screen
    SELECTION-SCREEN: BEGIN OF SCREEN 9000.
    PARAMETERS:     p_carrid TYPE s_carr_id OBLIGATORY.
    SELECT-OPTIONS: s_fldate FOR gv_fldate OBLIGATORY.
    SELECTION-SCREEN: END OF SCREEN 9000.
    *&      Form  sub_yvsflight_event_aa
    *       text
    FORM sub_yvsflight_event_aa.
      DATA: ls_temp_data TYPE yvsflight,
            lt_temp_data TYPE STANDARD TABLE OF yvsflight.
    * Call the user-defined selection-screen
      CALL SELECTION-SCREEN 9000 STARTING AT 25 10.
    * Populate the int. table TOTAL
      PERFORM get_data_yvsflight.
    * Delete the records which are not required
      LOOP AT total.
        ls_temp_data = <vim_total_struc>. "Copy to local struct.
        IF ls_temp_data-carrid NE p_carrid OR
           ls_temp_data-fldate NOT IN s_fldate.
          DELETE total. "Remove the record from the TOTAL
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "sub_yvsflight_event_aa
    BR,
    Suhas

  • Event 03 in table maintenance generator

    Hello All,
    I have created a event 03 in table maintenance generator. Because I need to check if the deleted key is still referenced in an other table.
    I tried the following code, but only if I use the message the entry will not be deleted.
      MOVE uebergehen TO <mark>.
      MODIFY total INDEX sy-tabix.
      <xmark> = <mark>.
      MODIFY extract INDEX nextline.
      IGNORED_ENTRIES_EXIST = abap_true.
    *  MESSAGE e000 WITH 'Entry not allowed to delete'.
    Thanks in advance.
    Marcus

    had to put it in a generic form, hope it still works:
    FORM event_03.
      TYPES: BEGIN OF typ_extract,
               zview TYPE zview,   "or ztable, the one with the maintenance dialog!
               flags TYPE vimtbflags,
             END OF typ_extract.
      DATA: ls_extract TYPE typ_extract.
    * loop at marked lines
      LOOP AT extract INTO ls_extract.
        CHECK ls_extract-flags-vim_mark EQ 'M'.
    *   place existence check here!
    *   using the values in ls_extract-zview-...
    *   if value still being used, send message
        IF sy-dbcnt > 0.
          MESSAGE i...
          ls_extract-flags-vim_mark = '*'.
          MODIFY extract FROM ls_extract.
        ENDIF.
      ENDLOOP.
    ENDFORM.

  • How to validate data entered in table maintenance for Z table?

    Hi,
    I created a Z-table with table maintenance. I'd like to perform some validation on the entered data.
    I know there are events for these : "If this pre-defined time is reached in extended table maintenance, the FORM routine specified for the current view and for this time is processed. This is useful, for example, for performing consistency checks before saving or specific actions when creating new entries."
    I also found some info in the Online help:
    http://help.sap.com/saphelp_47x200/helpdata/en/91/ca9f0ea9d111d1a5690000e82deaaa/frameset.htm
    However it's not clear which event I can use for validation.
    I tried event 01, however when I added a message, in the SM30 in case of message, I got the SM30 initial screen.
    Do you have any example about validation?
    Thanks in advance,
    Peter

    Hi,
    Once you are on the table maintenance generator screen.
    GOTO --> Enviornment --> Modification --> Events.
    Here specify Event as '01' and the Subroutine name that will hold the data for the validation.
    As you know we need to specify a function group.
    GOTO SE80 and Open your function group.
    Now in the PBO of the screen write a subroutine for the validation before saving an entry in the table.
    Refer the code below for validation.
    *&      Form  F9000_CHECK_BEFORE_SAVE
          Subroutine called dynamically to check values before saving
    FORM f9000_check_before_save.
      TYPES : BEGIN OF ty_flmt,
              zz_flmt_type     TYPE zz_flmt_type,
              zz_gsm_flmt_code TYPE zz_flmt_code,
              END OF ty_flmt.
    Internal Table
      DATA : lit_flmt_code TYPE TABLE OF ty_flmt,
             wa_flmt_code  LIKE LINE  OF lit_flmt_code.
      DATA: lv_subrc TYPE sy-subrc VALUE '0',
            lv_tabix TYPE sy-tabix,
            lv_total_rec TYPE i,
            lv_rec       TYPE i,
            flg_upd      TYPE flag.
      DESCRIBE TABLE total LINES lv_total_rec.
      LOOP AT total.
        lv_tabix = sy-tabix.
        READ TABLE extract WITH KEY total.
        IF sy-subrc EQ 0.
          IF extract+3(10) IS INITIAL.
            DELETE total.
            DELETE extract INDEX sy-tabix.
           DELETE extract INDEX lv_tabix.
            lv_subrc = '4'.
            flg_upd = 'X'.
            MESSAGE s119(zcrm_appl) DISPLAY LIKE 'S'.
            SET SCREEN 0.
          ENDIF.
        ENDIF.
        wa_flmt_code-zz_flmt_type = total+13(3).
        wa_flmt_code-zz_gsm_flmt_code = total+16(10).
        APPEND wa_flmt_code TO lit_flmt_code.
      ENDLOOP.
      IF flg_upd IS INITIAL.
        SORT lit_flmt_code BY zz_flmt_type zz_gsm_flmt_code.
        DELETE ADJACENT DUPLICATES FROM lit_flmt_code.
        DESCRIBE TABLE lit_flmt_code LINES lv_rec.
        IF lv_total_rec <> lv_rec.
          LOOP AT extract.
            READ TABLE total WITH KEY extract.
            IF sy-subrc EQ 0.
              DELETE total INDEX sy-tabix.
              DELETE extract INDEX 1.
              lv_subrc = '4'.
              MESSAGE s289(zcrm_appl) DISPLAY LIKE 'S'.
              SET SCREEN 0.
            ENDIF.
          ENDLOOP.
        ENDIF.
      ENDIF.
      sy-subrc = lv_subrc.
    ENDFORM.    
    <b>Please reward points and close the thread.</b>
    Regards,
    Amit Mishra

  • Add field in table maintenance generator screen of maintenance view

    Hi,
    I am having a table with field user-id. I want to generate a maintenance view which will have corresponding user name as input disabled field. Since there are two tables USR21 and ADRP I need to access(not a direct check table) I will have to modify the code generated by the table maintenance generator.
    Problem is that it is having one internal table EXTRACT at table control loop. That internal table cannot be accessed if you write a module inside the table control loop and try to catch. The error coming as EXTRACT is not object of structure and therefore no component. I tried to capture the value of the Loop but could not be successful. Any suggestion please.
    Thanks,
    Atanu

    Hi,
    sample:
          MODULE LISTE_UPDATE_LISTE.
        ENDCHAIN.
    *--->begin of your change
        CHAIN.
          FIELD YTAB1-BILKS .
          FIELD YTAB1-BILKH .
           module check_bewar  ON CHAIN-input. "your checks
        ENDCHAIN.
    *-----> end of your change
      ENDLOOP.
      MODULE LISTE_AFTER_LOOP.
    ->  module check_bewar  is in an includ z123_INCL
    Regards Andreas

  • EVENT problem in Table maintenance generator

    Hello all
                 I m working on 4.6C sytem. I m facing  2 problems in events in table maintenance generator
    (1) I am using 04 event (After deleting records from table)   I have written BREAK-POINT in the Form .....ENDFORM... But the control doesnt stop there , when i select  an existing record and press delete record button? not able to understand  this
    (2) When i implement even t 03( Before deleting records from table) , and select  an existing record and press delete record button . Control successfully Go  to corresponding FORM ...   BREAK-POINT ENDFORM . 
    But now the problem is.. in debuggin i can see the contents in TOTAL table  but when i try to code LOOP at TOTAL ..ENDLOOP...it gives me syntax error saying "  table TOTAL doesnot exists or not defined..but similar field TOTAL_S , TOTAL_M , TOTAL_L  exists.. ???
      how come i can see the same during debugging but cannot code it ?
    Plese help
    Nilesh

    Hi Nilesh,
    (1)  I think the control will stop there after you delete AND save. Not sure about that but give it a try.
    (2) I believe you are trying to access fields inside table TOTAL, is that right?
    Actually you have to declare a work area with your Z table type.
    DATA: w_workarea type ztable.
    LOOP at total.
      w_workarea = total.
    endoop.
    Then you can work with w_workarea.
    Best regards.

  • Disabling fields in table Maintenance generator

    Hi Experts,
    I would like to restrict some fields in table maintenance generator dynamically/ statically.
    Here is the situation.
    I have generated table maintenance for the table ZMARA and I have created three transactions for the above single table maintenance generator.
    i.e .. Transaction      ---        Table
              ZT1                  ---         ZMARA
              ZT2                  ---          ZMARA
              ZT3                  ---          ZMARA
    I am using above three transactions in my module pool program. Based on the certain conditions I am calling different transactions i.e ZT1, ZT2, etc
    Here is my requirement:
    Suppose if I call ZT1 transaction, I need to display only few fields. i.e ZMATNR, ZMTART, ZPRODH.
    or remaining fields should disable. User should not allow to change the content, even if it is new entries/existing entries. only ZMATNR, ZMTART, ZPRODH.
    Suppose if I call ZT2 transaction, I need to display only few fields. i.e ZMATNR, ZMTART, ZHTSCODE
    How can we restrict dynamically when you call table maintenance generator table through transaction
    or
    How can we generate table maintenance for few fields?
    Edited by: r badveli on Mar 16, 2009 4:27 PM
    Edited by: r badveli on Mar 16, 2009 4:27 PM
    Edited by: r badveli on Mar 16, 2009 4:28 PM

    Hi ,
    go to Se11->Table maintenace generation. Double click on screen to edit and assign the field you want to display/hide to groups. In PBO , after the following lines..
    LOOP AT EXTRACT WITH CONTROL
    TCTRL_ZMARA                         CURSOR NEXTLINE.
       MODULE LISTE_SHOW_LISTE.
    ENDLOOP.
    Write a new module in PBO and edit the SCREEN as per the Tcode, you are calling,,'
    Hope this helps you
    Rj

  • Event code in table maintenance generator

    Hi All,       Need to call event in Table maintenance generator of the z table. I have to use 1st event (Select ’01’ – Before saving data in the database).     Need to do fallowing job: Table cleaning : Delete all records with value year =< 2011 -New rule :      No save can be done with value (Pst Var, PA,PSA, Cost = ‘ *,*,*,*’). I am attaching table entry with this mail, I have written the code for this but not sure please suggest me modification if required for this.Because i have never done this before. Thanks and Regards Sankil     

    hi Sankil
    Some variable is not available in your code and you did not modify EXTRACT table.
    Try to modify your code as blow:
    This event has no standard routine. The following global data is available for the realization of the user routine:
    •internal table TOTAL
    •field symbols
    •field symbols <ACTION> and <ACTION_TEXT>
    •<STATUS>-UPD_FLAG
    If internal table data are to be changed before saving, t he changes should be made in both the internal table
    TOTAL and in the internal table EXTRACT.
    FORM abc.
    DATA: F_INDEX LIKE SY-TABIX. "Index to note the lines found
    LOOP AT TOTAL.
    IF <ACTION> = desired constant.
    READ TABLE EXTRACT WITH KEY <vim_xtotal_key>.
    IF SY-SUBRC EQ 0.
    F_INDEX = SY-TABIX.
    ELSE.
    CLEAR F_INDX.
    ENDIF.
    (make desired changes to the line TOTAL)
    MODIFY TOTAL.
    CHECK F_INDX GT 0.
    EXTRACT = TOTAL.
    MODIFY EXTRACT INDEX F_INDX.
    ENDIF.
    ENDLOOP.
    SY-SUBRC = 0.
    ENDFORM
    refer event 01: http://help.sap.com/saphelp_nw04/helpdata/en/91/ca9f0ea9d111d1a5690000e82deaaa/frameset.htm
    regards,
    Archer

  • Table Maintenance- Condition Records

    Hi Friends,
    I have created a custom table and i have done a Table Maintenance for that custom Table..
    In that i have one field called DATBI(which is To-date).
    My Requirement is how to set condition in this table maintenance where IF TO-DATE < SYSDATE
    those records should not be displayed in Table maintenance but that should be there in Data base table..
    Can anyone help me on this.. I think something need to be done in PBO.
    Plz help me on this..
    Sample code will be helpful.
    Thanks in advance.
    kishore

    Hi genji,
    Goto ur table and then utilities----
    >table maintenance generator .
    Then double click on the overview screen u specifed..It will direct u to PBO screen.
    There inside PBO in the beginning create one module X(some name).
    inside that specify ur condition whichever you want to..
    piece of code which i have done for my condition records inside PBO
    module modif_screen output.
    data:  datbi type datbi.
    clear total.
    loop at total.
      move total+32(8) to datbi.
       if datbi < sy-datum.
       delete total.
       endif.
      clear : datbi.
    endloop.
    Here total is the internal table from where values are populated.
    Think this wil solve ur issue.

  • Error in flow logic of table maintenance generator

    Hi,
    While activating the flow logic of  table maintenance generator I am getting this error 'Table control TCTRL_ZUPP2P_PIBAYCNT must have atleast 2 loop lines.' and in layout I am able to see only 2 rows.Can anyone tell me why am I getting this error.

    hi,
    Take the function group and goto SE80 and activate the function group to avoid the error...
    Regards,
    Santosh

  • Include a field in the table maintenance generator

    Hi All,
    There is a Z table with MATNR and another numeric field and the table maintenance generator exists for the table. The requirement is to include another field for MAKTX ( Material description) in the table maintenance generator with input disabled. Is it possible to do the same in the table maintenance generator else please suggest me the best solution.
    Thanks in Advance.

    Hi Srinivasa,
    This is quite simple, first add the field MAKTX into the Table and activate it .
    Now again generate the Table maintainence for the table.
    from Table maintainence generator go to the main program
    there click the screen maintained for Table maintainence generator .
    in the Pbo of the screen write the following code.
    assume table name is table1.
    Loop at screen.
    if screen-name = table1-maktx.
    screen-input = '0'.
    modify screen.
    endif.
    endloop.
    this will automatically disable the material description field in the Table Maintainence Generator.
    This is will solve your problem
    Regards,
    Madhavi

Maybe you are looking for

  • Can anyone suggest a select case statement in place of my if statements?

    I am having a little trouble switching my if statements to select case. Any help would be appreciated Option Strict On Option Explicit On Public Class Form1 Private Player1 As String Private Player2 As String Private Player1Wins As Integer = 1 Privat

  • How to set up Airport Express in Bridge mode for hotel use

    Please provide step by step instructions on how to set up Airport Express in Bridge mode for hotel use. I do not have a computer with me, only an iPhone and AEX 802.11n.

  • Arial Unicode Arabic text in Flash CS4

    Hi, I am facing a strange issue. I have a flash file where Arabic text is written using Arial Unicode MS and is displayed properly, but when i try to update the text field with new arabic content, the words split up into characters. The image below s

  • MS word document is not opening in front of one of the application window

    Hi All, we have application which is for creating proposals for business, in that application we have a Key/tab that is "generate proposal" when we click on that key it will create the poroposal in MS word format, now our issue is that when we click

  • Some Extensions deasappear from Toolbar

    I have Firefox 3.6.15 and Firefox 4.0b12 loaded on same Mac ( OS X 10.6.6) V. 3 has some extension that I use and are not (yet) available in the latest Firefox. All Extensions was working well. Today, I update some extension into Firefox 4, surprised