Table maintenance Validations

11-30  Source: Network gathering  Views:0 

Advertisement
Hi All,
I created a table with 2 fields, also created a maintenance generator. Now my requirement is i need to have 1-1 relation with the fields, what i mean is, no value can repeat with in either of the fields.
I need to validate this condition.
Suppose user enters a value 1234 in first field, again if he enters the same, i need to throw a error message.
I went to transaction SE54, the following is the code
PROCESS BEFORE OUTPUT.
  MODULE liste_initialisieren.
  LOOP AT extract WITH CONTROL
   tctrl_zzbank CURSOR nextline.
    MODULE liste_show_liste.
  ENDLOOP.
PROCESS AFTER INPUT.
  MODULE liste_exit_command AT EXIT-COMMAND.
  MODULE liste_before_loop.
  LOOP AT extract.
    MODULE liste_init_workarea.
    CHAIN.
      FIELD zzbank-zzau1.
      FIELD zzbank-hbkid.
      MODULE set_update_flag ON CHAIN-REQUEST.
    ENDCHAIN.
    FIELD vim_marked MODULE liste_mark_checkbox.
    CHAIN.
      FIELD zzbank-zzau1.
      MODULE liste_update_liste.
    ENDCHAIN.
  ENDLOOP.
  MODULE liste_after_loop.
<b>  MODULE check_dupe.</b>
the line in bold is what i added, how do i proceed from here, could anyone please help.
Hi Deepti,
As Jorge Alonso said, if you declare both fields as key fields then SAP will take care of the validation and raise a error message .
Assuming both fields are key fields, if the records are like this.
111 222
<b>111 222</b>
then SAP will raise a error message.
Otherwise, if you don't want first or second field to be repeated any where again, then include the code in your check_dupe module.
GET CURSOR LINE <lin> or GET CURSOR FIELD <f> LINE <lin>.
select * from ztable into itab.
loop at itab.
if itab-first_field CS table_first_field  or itab-first_field CS table_second_field or itab-second_field CS table_first_field or itab-second_field CS table_second_field.
If sy-subrc eq 0.
MESSAGE E0004 WITH 'Duplicate key'.
ENDIF.
ENDIF.
endloop.
Hope this will help you,
Regards,
Vicky
PS: Award points if helpful
Related articles
  • Table maintenance Validations 11-30

    Hi All, I created a table with 2 fields, also created a maintenance generator. Now my requirement is i need to have 1-1 relation with the fields, what i mean is, no value can repeat with in either of the fields. I need to validate this condition. Sup

  • Table Maintenance Generator : Editable Entry after validation fails 10-11

    Hi, I have created a Z table and a table maintenance generator to maintain the data. I have to carry out certain validations when user enters data on Key and Non- key fields. This is working fine, but the issue is with the key fields. If validation f

  • Validation after Excel File Upload in Table Maintenance 10-11

    Hello All, I've done extensive research on this topic and still have yet to find the answer. I have created a custom button in the TMG to upload an Excel file to the table maintenance using the FM CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD. I updated the E

  • Field validation in table maintenance generator and input value grey out. 11-30

    i have created ztable with 3 fields as em_no,em_no and addrnumber. first two fields are custom fields but the third custom field need to validate the standard table adrc contains the value of the field addrnumber. i need the query of field validation

  • Validating non key fields in table maintenance generator 11-30

    Hi, I ma using events for table maintenance generator event 05 ,there i want to validate non key fields ......i am throwing error message ....all the non key fields are getting in display mode ...i need them to enable to enter values .... please sugg

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

    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

  • Event for input validation in custom table (table maintenance generator) 11-30

    Hello all, I look for a solution to execute an event after the modification of a table field of a custom table to validate the user's input. I already tried event 07 (Execution : Before correcting the contents of a selected field) of the table mainte

  • Table maintenance events 10-11

    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, de

  • Events in Table Maintenance - How validate fields and deliver error message 10-11

    Simple transparent table.  I have generated one step table maintenance.  I use a view variant to make some fields display only.  I would like to use Events to provide some validation.  For example: If field STATUS = 'T', then field QUANTITY must be >

  • Table maintenance view -user exit 10-11

    Hello, as you all know, there is a program generated behind the table maintenance view. I want to add certain validation on the values entered in the table maintenance. I know that modifying the program is not the best practice. Is there any user exi

  • Validate field in the pop up for a Table Maintenance View 10-11

    Hi, I have created a maintenance view for a Z table. Among the many fields the table, I needed to display the records based on a selection criterion. So, I have enabled a popup for sales org and customer no'. Now the sales org and cust no' are being

  • Purpose of table maintenance generator 10-11

    wht is the purpose of table maintenance generatorHi Pavan, The purpose of table maintainence generator is to enable the table maintenance through SM30, and to implement and validation etc on table field inputs. SE11->Utillities->table maintainence g

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

    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 curren

  • Change in table maintenance generator 11-30

    Hi All, I have created one table. While creating data through table maintenace, if for values of nonkey fields are same then it should give some error? How to achieve this functionality? Regards, JeetuFor Performing validations for the table entries,

  • Adding F4 help to a field in a table maintenance dialog 11-30

    I have used SE54 to create a maintenance dialog for my table. I need to be able to use F4 in a field in the maintenance dialog that will read several values that have been entered into the table (in the same row) but not yet saved and then execute an

  • Modify Key Field Values of a table through Table Maintenance Generator 11-30

    Hi All,    I have created a z table with below structure. In this fields upto Valid To are all key fields. This is to ensure that consistant valid record get stored in the table. MANDT     MANDT     CLNT     3     0     Client VKORG     VKORG     CHA

  • How to pre-populate fields for new entry in table maintenance 11-30

    Hey everyone, I have a table maintenance set up that I would like to pre-populate two date fields when the user creates a new entry or copies an existing entry. I can do this by adding a PBO module for the maintenance screen but then if the screens a

  • ABAP Table Maintenance Events 11-30

    Hello All , I have created the Table Maintenance with Events . When the user enter the sales order number  & item in the Txn code screen of the table  .The Event  05  triggers & pulls out information for Sales Order Customer ,Material ,Plant  &

  • Table Maintenance events and field focus 11-30

    Hi all, In event 01(save data) of table maintenance, I have the code to ensure some fields are not left blank: When testing the creation of table records in SM31, it gives me the error msg successfully, but after that greys out all fields in that row

  • How to use table maintenance view in module pool screen 10-11

    hi , want to use table maintenance view in a module pool screen so that i can edit, insert, delete and update date in to the ztable.please help.You can simply call it via SM30.   Or you can call the table maintence view from any program(report or mod