‎2008 Apr 21 12:08 PM
hi ,
some validation need to be performed while entering data in the custom table, validation requires to check the same custom table enteries earlier saved in the custom table- this can be met
but if the requirement is also to validate the new enteries
with not just the saved enteries but also the previous entered
enteries( which are not saved)
please suggest
‎2008 Apr 21 12:35 PM
Hi saurabh,
Are you saving it through a custom program?
If so you will be fetching all data entered by the user in an internal table ...in the internal table you can search for duplicates based on the key of the table you need to save into
Do the following...When the user press 'SAVE" or other custom button write the code as below
imagine the data to be stored in int_tab1
declare int_tab2 as same type of int_tab2..and that the final table you are saving has 2 keyfields keyfield1 and keyfield2
also use a workarea of type int_table1
sort the internal table by all the key fields so that delete adjacent duplicate ABAP statement will work correctly
sort int_tab1 by key1 descending key2 descending.
clear the table to be copied into initially
clear int_tab2[].
create an exact copy on the initial internal table and pass all the values from internal table1 to internal table2
int_tab2[ ] = int_tab1[ ].
loop in workarea
loop at int_tab1 into workarea.
take the first line and check if duplicate records are there in the copy table we are using
if duplicate records are there sy-subrc = 0 otherwise sy-subrc = 4.
delete adjacent duplicates from int_tab2
comparing keyfield1 = workarea-keyfield1 and
keyfield2 = workarea-keyfield2.
if sy-subrc = 0.
Message 'The entry for Key field already exists' type 'E'.
endif.
endloop.
Please check and revert
<REMOVED BY MODERATOR>
Regards
Byju
Edited by: Alvaro Tejada Galindo on Apr 22, 2008 11:07 AM
‎2008 Apr 22 3:53 PM
hi,
my question is how to validate the newly entered enteries with the enteries in the table which are not saved but entered in the table.
regrads,
saurabh