01-22-2007 6:00 PM
01-22-2007 6:08 PM
Hi,
The following are required when you are using FOR ALL ENTRIES..
1)
Remove the duplicate entries for the key that you are selecting on.
2)
Check if the internal table is populated before using FOR ALL ENTRIES.
3)
Select all the key fields of the table that you are going to select..
Example
-
DATA: ITAB_VBAK LIKE VBAK OCCURS 0 WITH HEADER LINE.
DATA: ITAB_VBAP LIKE VBAP OCCURS 0 WITH HEADER LINE.
DATA: ITAB_VBAP_TMP LIKE VBAP OCCURS 0 WITH HEADER LINE.
SELECT MANDT VBELN POSNR INTO TABLE ITAB_VBAP
FROM VBAP
WHERE MATNR IN SO_MATNR.
IF SY-SUBRC = 0.
ITAB_VBAP_TMP = ITAB_VBAP.
SORT ITAB_VBAP_TMP BY VBELN.
DELETE ADJACENT DUPLICATES FROM ITAB_VBAP_TMP
COMPARING VBELN.
IF NOT ITAB_VBAP_TMP[] IS INITIAL.
SELECT MANDT VBELN
INTO TABLE ITAB_VBAK
FROM VBAK
FOR ALL ENTRIES IN ITAB_VBAP_TMP
WHERE VBELN = ITAB_VBAP_TMP-VBELN.
ENDIF.
Thanks,
Naren
01-22-2007 6:05 PM
hi instead of using for all entries with select stmt
move the contents of that table into another internal table and remove the duplicate entries & then select contents
Remove all the duplicate entries before using the select statement.
itab2[] = itab1[].
sort itab1.
delete adjacent dupilcates from itab1.
then use the for all entries
01-22-2007 6:08 PM
Hi,
The following are required when you are using FOR ALL ENTRIES..
1)
Remove the duplicate entries for the key that you are selecting on.
2)
Check if the internal table is populated before using FOR ALL ENTRIES.
3)
Select all the key fields of the table that you are going to select..
Example
-
DATA: ITAB_VBAK LIKE VBAK OCCURS 0 WITH HEADER LINE.
DATA: ITAB_VBAP LIKE VBAP OCCURS 0 WITH HEADER LINE.
DATA: ITAB_VBAP_TMP LIKE VBAP OCCURS 0 WITH HEADER LINE.
SELECT MANDT VBELN POSNR INTO TABLE ITAB_VBAP
FROM VBAP
WHERE MATNR IN SO_MATNR.
IF SY-SUBRC = 0.
ITAB_VBAP_TMP = ITAB_VBAP.
SORT ITAB_VBAP_TMP BY VBELN.
DELETE ADJACENT DUPLICATES FROM ITAB_VBAP_TMP
COMPARING VBELN.
IF NOT ITAB_VBAP_TMP[] IS INITIAL.
SELECT MANDT VBELN
INTO TABLE ITAB_VBAK
FROM VBAK
FOR ALL ENTRIES IN ITAB_VBAP_TMP
WHERE VBELN = ITAB_VBAP_TMP-VBELN.
ENDIF.
Thanks,
Naren