‎2008 Nov 18 6:21 PM
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.
‎2008 Nov 18 8:44 PM
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
‎2008 Nov 18 6:35 PM
‎2008 Nov 18 6:39 PM
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.
‎2008 Nov 18 8:44 PM
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