Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

regading internaltable records

Former Member
0 Kudos

how can we find whether the records present in internal table same r not ?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

14 REPLIES 14

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

0 Kudos

suppose in an internal table we are having 5 records how can we check whether thse 5 recods are having same value or not?

0 Kudos

you mean... you want to compare 5 records with data base table or with another internal table?

Satish

0 Kudos

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.

0 Kudos

i just want to know whethe the values in internal table are unique are not

0 Kudos

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

Former Member
0 Kudos

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

former_member386202
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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