Application Development and Automation 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: 
Read only

capturing missing info. in dbtable vs internal table

Former Member
0 Likes
928

i have an internal table with few thousand entries depending on which i'm selection data from database table.

my internal table contains 'number' field.

im selecting data from database from db table as follows.

SELECT number field1 field2...FROM dbtable into....

for all entries in itab WHERE

NUMBER = ITAB-NUMBER.

this works fine. but i need to capture the 'numbers' that doen't exits in database. i dont want to open an SELECT...ENDSELECT or anyo ther loop. is there any other way to do this.

thanks,

kranthi.

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
907

You could probably use a subquery here. You would add this subquery to the first select statement, the one that fill ITAB.

http://help.sap.com/saphelp_46c/helpdata/en/dc/dc7614099b11d295320000e8353423/frameset.htm

Regards,

Rich Heilman

Read only

Former Member
0 Likes
907

Hi kranthi,

Probably you can populate those numbers into a range as a exluding(Not include) option and do the select using IN option

Cheers,

Satya

Read only

Former Member
0 Likes
907

Do you mean that you want to know the numbers that are in your file that are not in the database?

Rob

Read only

0 Likes
907

Rob,

yes,with out querying on the db(another time apart from fetching data ) and with out a loop or select..endselect.

Thanks,

kranthi.

Read only

0 Likes
907

Delete the internal table where the numbers field is in the dataset returned by your select statement.

Read only

0 Likes
907

Copy the table that was returned from the database select to another table (itab2[] = itab1[]).

    • Sorry - I meant say - copy the original table used in the where clause to another internal table. **

loop at the original table and create a range table from it (using 'I' and 'EQ'). I think you do have to use a loop here.

    • and use the table returned from the select in the range.**

delete itab2 where not number in range table.

    • delete itab2 where number in range table **

Rob

Message was edited by: Rob Burbank

Read only

Former Member
0 Likes
907

Hi, you can try this.

loop at itab.

r_number-sign = 'E'.

r_number-option = 'EQ'.

r_number-low = itab-number.

append r_number.

endloop.

SELECT number field1 field2...FROM dbtable into....

WHERE

NUMBER in R_NUMBER.

Since we use exluding option it will fetch only those are not in the r_number.

Cheers,

Satya