‎2009 Oct 26 10:54 AM
Hi All,
I have to select entries from table iclpay looping it_dfkkop and delete the entries in it_dfkkop_tmp which are not present in iclpay.
For this If use below code its working fine, but there is performance issue
CLEAR: it_iclpay[],it_iclpay.
LOOP AT it_dfkkop_tmp.
SELECT claim documentref paycat status FROM iclpay
APPENDING CORRESPONDING FIELDS OF TABLE it_iclpay
WHERE
active = c_active AND
claim = it_dfkkop_tmp-claim AND
documentref = it_dfkkop_tmp-opbel.
IF sy-subrc NE 0.
DELETE it_dfkkop_tmp.
ENDIF.
ENDLOOP.
If I write the code like below its not working
SELECT claim documentref paycat status FROM iclpay
INTO TABLE it_iclpay
FOR ALL ENTRIES IN it_dfkkop_tmp WHERE
active = c_active AND
claim = it_dfkkop_tmp-claim AND
documentref = it_dfkkop_tmp-opbel.
Can anyone help on this.
‎2009 Oct 26 11:07 AM
What do you mean by not working? The purpose of using FOR ALL ENTRIES is to avoid select query within loop. Are you getting any error or dump with your second select query?
‎2009 Oct 26 12:04 PM
It did not dump but did not get final(required) output.
I got the solution now.
Thanks a lot for responding.
I have written the below code
SELECT claim
documentref
paycat
status
FROM
iclpay
APPENDING CORRESPONDING FIELDS OF TABLE it_iclpay
FOR ALL ENTRIES IN it_dfkkop_tmp WHERE
active = c_active AND
claim = it_dfkkop_tmp-claim AND
documentref = it_dfkkop_tmp-opbel.
SORT it_dfkkop_tmp BY claim opbel.
LOOP AT it_dfkkop_tmp.
READ TABLE it_iclpay INTO wa_iclpay WITH KEY
claim = it_dfkkop_tmp-claim
documentref = it_dfkkop_tmp-opbel.
IF sy-subrc NE 0.
DELETE it_dfkkop_tmp.
ENDIF.
ENDLOOP.
‎2009 Oct 26 12:05 PM
‎2009 Oct 26 12:08 PM
if it selects nothing, then there probably nothing to delete.
Your FAE looks fine to me:
What you need is:
define itab1 as SORTED TABLE ...
if NOT ( itab IS INITIAL).
SELECT
INTO TABLE itab1
...
FOR ALL ENTRIES itab0
...
ENDIF.
if NOT ( itab1 IS INITIAL).
LOOP AT itab0 INTO wa0.
READ TABLE itab1 WITH KEY ...
IF ( sy/subrc ne 0 ).
APPEND wa TO itab2.
ENDIF.
ENDLOOP.
DELETE dbtab FROM TABLE itab2.
ENDIF.
ELSE
DELETE dbtab FROM TABLE itab0.
ENDIF.
details are not hard to figure out!
‎2009 Oct 26 12:09 PM