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

Select statement doubt...

Former Member
0 Likes
527

Hello,

I am doing a select query as following:

SELECT * from RBKP into table it_RBKP where RBSTAT = '3'.

I have one more internal table called it_t01[] which I have prefilled with values of BELNR and GJAHR based on some predefined criteria.

I want to do above select on RBKP only for those BELNR and GJAHR that do not exist in it_t01[] internal table.

How can I do this ?

Thanks.

Regards,

Rajesh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
503

You can use FOR ALL ENTRIES with NE operator to exclude the entries in the it_t01.

try:

select *

from RBKP

into table it_xx

for all entries in it_t01 where belnr <> it_t01-belnr and

gjahr <> ti_t01-gjahr.

look at this example:

data:

lt_mara like mara OCCURS 0 WITH HEADER LINE,

lt_mara2 like mara OCCURS 0 WITH HEADER LINE,

lv_lines like sy-tabix.

lt_mara-matnr = '000000000000233334'.

append lt_mara.

select matnr INTO CORRESPONDING FIELDS OF TABLE lt_mara2

from mara

FOR ALL ENTRIES IN lt_mara

WHERE matnr <> lt_mara-matnr.

DESCRIBE TABLE lt_mara2 lines lv_lines.

write lv_lines.

Regards

3 REPLIES 3
Read only

Former Member
0 Likes
503

By using code?

Rob

Read only

Former Member
0 Likes
503

Just Hint(Copyright material for code will not be given )

Loop at it_t01.

SELECT single * from RBKP where RBSTAT = '3' and belnr nq = it_t01-belnr and GJAHR ne it_t01-GJAHR .

collect into it_rbkp.

endloop.

either first get SELECT * from RBKP into table it_RBKP where RBSTAT = '3' , and than delete by reading it_t01 with key BELNR and GJAHR .

if sy-subrc ne 0.

delete it_rbkp.

Read only

Former Member
0 Likes
504

You can use FOR ALL ENTRIES with NE operator to exclude the entries in the it_t01.

try:

select *

from RBKP

into table it_xx

for all entries in it_t01 where belnr <> it_t01-belnr and

gjahr <> ti_t01-gjahr.

look at this example:

data:

lt_mara like mara OCCURS 0 WITH HEADER LINE,

lt_mara2 like mara OCCURS 0 WITH HEADER LINE,

lv_lines like sy-tabix.

lt_mara-matnr = '000000000000233334'.

append lt_mara.

select matnr INTO CORRESPONDING FIELDS OF TABLE lt_mara2

from mara

FOR ALL ENTRIES IN lt_mara

WHERE matnr <> lt_mara-matnr.

DESCRIBE TABLE lt_mara2 lines lv_lines.

write lv_lines.

Regards