10-30-2007 11:49 AM
how can we find whether the records present in internal table same r not ?
10-30-2007 11:57 AM
itab1[] = itab[].
describe table itab lines var1.
delete adjacent duplicates from itab1 comparing all fields.
describe table itab1 lines var2.
if var1<>var2.
*---there are dupliacte records
endif.
if var1 ne 1 and var2 = 1.
*--all records in original internal table are same.....
endif.
10-30-2007 11:54 AM
Hi,
Once select statement is executed, check for sy-subrc, if it is zero then internal has values in it.
If not from Select statement try this :
data : begin of itab occurs 0,
hkont like bsis-hkont,
end of itab.
itab-hkont = '123546'.
append itab.
clear itab.
itab-hkont = '123546'.
append itab.
clear itab.
itab-hkont = '123546'.
append itab.
clear itab.
if sy-tabix GT 1.
write : 'values'.
else.
write : 'No values'.
endif.
OR
describe lines of itab.
Thanks,
Sri.
10-30-2007 11:54 AM
Prasad,
Can you give more details of what exactly you want to know.
Once the select query executed you can chack the sy-dbcnt value to find how many records has been fetched.
Satish
Message was edited by:
Satish Panakala
10-30-2007 11:59 AM
suppose in an internal table we are having 5 records how can we check whether thse 5 recods are having same value or not?
10-30-2007 12:02 PM
you mean... you want to compare 5 records with data base table or with another internal table?
Satish
10-30-2007 12:04 PM
suppose itab is ur internal table with 5 records....move it to itab1......
itab1[] = itab[].
describe table itab lines var1.
delete adjacent duplicates from itab1 comparing all fields.
describe table itab1 lines var2.
if var1<>var2.
*---there are dupliacte records
endif.
if var1 ne 1 and var2 = 1.
*--all 5 records in original internal table are same.....
endif.
10-30-2007 12:06 PM
i just want to know whethe the values in internal table are unique are not
10-30-2007 12:18 PM
Prasad,
once the select query is executed, you will have the data in internal table.
check each entry with database table by providing the same selections which you have given for select query.
<b>Reward for helpful answers</b>
Satish
10-30-2007 11:56 AM
HI ,
by putting read statement u can try this , by copying the records to one more internal table of same structure.
loop at second table.
loop at first table.
read
try this logic
regards
karthik
10-30-2007 11:57 AM
Hi,
After select statement check sy-subrc, if it is equal to zero then table contains the data. You can write like this also
If not itab[] is inital.
staement
endif.
Regards,
prashant
10-30-2007 11:57 AM
There are many ways to find records are present or not..
for example...
DATA : lin TYPE i.
DESCRIBE TABLE itab LINES lin.
Here lin returns number of records present in itab.
10-30-2007 11:57 AM
itab1[] = itab[].
describe table itab lines var1.
delete adjacent duplicates from itab1 comparing all fields.
describe table itab1 lines var2.
if var1<>var2.
*---there are dupliacte records
endif.
if var1 ne 1 and var2 = 1.
*--all records in original internal table are same.....
endif.
10-30-2007 12:01 PM
Hi,
After Select statement check if not itab is initial.
then check if sy-subrc equal to 0.if it is 0 then records are present in internal table.
Reward if useful.
Regards,
Shilpi
10-30-2007 12:05 PM
Hi,
Its very simple procedure.
After filling internal table with data from Database table using SELECT stmt or some other internal table we have to use IS INITIAL[] statement for internal table.
For example if we want to print internal table data and we want to check whether internal table contains some data or not we will check as shown below.
REPORT ZSDNTEST_NOV .
DATA:itab LIKE mara OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
SELECT * FROM mara INTO TABLE itab UP TO 10 ROWS.
IF NOT itab[] IS INITIAL. "checking internal table contains data
LOOP AT itab.
WRITE:/ itab-matnr, itab-mtart.
ENDLOOP.
ENDIF.
10-30-2007 12:06 PM
Hi,
look at this short example.
tables: mara.
*
data: itab type table of mara with header line.
data: stru type mara.
*
select * from mara up to 10 rows into table itab.
select * from mara up to 05 rows APPENDING table itab.
select * from mara up to 05 rows APPENDING table itab.
*
sort itab.
*
loop at itab.
if itab = stru. write: / sy-tabix. endif.
stru = itab.
endloop.
Regards, Dieter